default ObjectClassComplexTypeDefinition findObjectClassDefinition(@NotNull ShadowType shadow) { return findObjectClassDefinition(shadow.getObjectClass()); }
default ObjectClassComplexTypeDefinition findObjectClassDefinition(ShadowType shadow) { return findObjectClassDefinition(shadow.getObjectClass()); }
@Override public boolean matches(ShadowType shadowType) { if (shadowType == null) { return false; } if (!QNameUtil.match(getTypeName(), shadowType.getObjectClass())) { return false; } return true; }
public static void checkEntitlementShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker<ShadowType> checker, String objectClassLocalName, MatchingRule<String> uidMatchingRule, PrismContext prismContext, OperationResult parentResult) throws SchemaException { checkShadow(shadowType, resourceType, repositoryService, checker, uidMatchingRule, prismContext, parentResult); assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), objectClassLocalName), shadowType.getObjectClass()); }
public static void checkAccountShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker<ShadowType> checker, MatchingRule<String> uidMatchingRule, PrismContext prismContext, OperationResult parentResult) throws SchemaException { checkShadow(shadowType, resourceType, repositoryService, checker, uidMatchingRule, prismContext, parentResult); assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME), shadowType.getObjectClass()); }
public boolean matches(PrismObject<ShadowType> shadow) { ShadowType shadowType = shadow.asObjectable(); if (!objectClass.equals(shadowType.getObjectClass())) { return false; } Collection<ResourceAttribute<?>> shadowIdentifiers = ShadowUtil.getPrimaryIdentifiers(shadow); return ItemCollectionsUtil.compareCollectionRealValues(primaryIdentifiers, shadowIdentifiers); }
public static String getDisplayName(ShadowType shadow) { String objectName = PolyString.getOrig(shadow.getName()); QName oc = shadow.getObjectClass(); String ocName = oc != null ? oc.getLocalPart() : null; return objectName + " (" + shadow.getKind() + " - " + shadow.getIntent() + " - " + ocName + ")"; }
/** * This is not supposed to be used in production code! It is just for the tests. */ public static void applyResourceSchema(PrismObject<? extends ShadowType> shadow, ResourceSchema resourceSchema) throws SchemaException { ShadowType shadowType = shadow.asObjectable(); QName objectClass = shadowType.getObjectClass(); ObjectClassComplexTypeDefinition objectClassDefinition = resourceSchema.findObjectClassDefinition(objectClass); applyObjectClass(shadow, objectClassDefinition); }
public static void assertObjectClass(ShadowType shadow, QName expectedStructuralObjectClass, QName... expectedAuxiliaryObjectClasses) { assertEquals("Wrong object class in "+shadow, expectedStructuralObjectClass, shadow.getObjectClass()); PrismAsserts.assertEqualsCollectionUnordered("Wrong auxiliary object classes in "+shadow, shadow.getAuxiliaryObjectClass(), expectedAuxiliaryObjectClasses); }
public ShadowAsserter<RA> assertObjectClass(QName expected) { PrismAsserts.assertMatchesQName("Wrong objectClass in "+desc(), expected, getObject().asObjectable().getObjectClass()); return this; }
public static ObjectClassComplexTypeDefinition determineObjectClass(RefinedResourceSchema refinedSchema, PrismObject<ShadowType> shadow) throws SchemaException { ShadowType s = shadow.asObjectable(); return determineObjectClassInternal(refinedSchema, s.getObjectClass(), s.getKind(), s.getIntent(), s); }
public ShadowAsserter<RA> assertObjectClass() { assertNotNull("No objectClass in "+desc(), getObject().asObjectable().getObjectClass()); return this; }
private static <F extends FocusType> boolean isPolicyApplicable(ObjectSynchronizationType synchronizationPolicy, SynchronizationContext<F> syncCtx) throws SchemaException { ShadowType currentShadowType = syncCtx.getApplicableShadow().asObjectable(); // objectClass QName shadowObjectClass = currentShadowType.getObjectClass(); Validate.notNull(shadowObjectClass, "No objectClass in currentShadow"); return SynchronizationUtils.isPolicyApplicable(shadowObjectClass, currentShadowType.getKind(), currentShadowType.getIntent(), synchronizationPolicy, syncCtx.getResource()); }
public ObjectClass objectClassToConnId(PrismObject<? extends ShadowType> shadow, String schemaNamespace, ConnectorType connectorType, boolean legacySchema) { ShadowType shadowType = shadow.asObjectable(); QName qnameObjectClass = shadowType.getObjectClass(); if (qnameObjectClass == null) { ResourceAttributeContainer attrContainer = ShadowUtil.getAttributesContainer(shadowType); if (attrContainer == null) { return null; } ResourceAttributeContainerDefinition objectClassDefinition = attrContainer.getDefinition(); qnameObjectClass = objectClassDefinition.getTypeName(); } return objectClassToConnId(qnameObjectClass, schemaNamespace, connectorType, legacySchema); }
protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass()); ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next(); PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName()); assertNotNull("No secondary identifier ("+idSecDef.getName()+") attribute in shadow for "+expectedIdentifier, idProp); if (nameMatchingRule == null) { assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, expectedIdentifier, idProp.getRealValue()); } else { PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); } }
private void checkUcfShadow(PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { assertNotNull("No objectClass in shadow "+shadow, shadow.asObjectable().getObjectClass()); assertEquals("Wrong objectClass in shadow "+shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow); assertNotNull("No attributes in shadow "+shadow, attributes); assertFalse("Empty attributes in shadow "+shadow, attributes.isEmpty()); }
private void checkUcfShadow(PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { assertNotNull("No objectClass in shadow "+shadow, shadow.asObjectable().getObjectClass()); assertEquals("Wrong objectClass in shadow "+shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow); assertNotNull("No attributes in shadow "+shadow, attributes); assertFalse("Empty attributes in shadow "+shadow, attributes.isEmpty()); }
protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass()); ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next(); PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName()); assertNotNull("No secondary identifier ("+idSecDef.getName()+") attribute in shadow for "+expectedIdentifier, idProp); if (nameMatchingRule == null) { assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, expectedIdentifier, idProp.getRealValue()); } else { PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); } }
private ObjectQuery createQueryBySecondaryIdentifier(ShadowType shadow) throws SchemaException { // TODO TODO TODO set matching rule instead of null in equlas filter Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); S_AtomicFilterEntry q = prismContext.queryFor(ShadowType.class); q = q.block(); if (secondaryIdentifiers.isEmpty()) { for (ResourceAttribute<?> primaryIdentifier: ShadowUtil.getPrimaryIdentifiers(shadow)) { q = q.itemAs(primaryIdentifier).or(); } } else { // secondary identifiers connected by 'or' clause for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) { q = q.itemAs(secondaryIdentifier).or(); } } q = q.none().endBlock().and(); // resource + object class q = q.item(ShadowType.F_RESOURCE_REF).ref(shadow.getResourceRef().getOid()).and(); return q.item(ShadowType.F_OBJECT_CLASS).eq(shadow.getObjectClass()).build(); }
public static void checkRepoShadow(PrismObject<ShadowType> repoShadow, ShadowKindType kind, Integer expectedNumberOfAttributes) { ShadowType repoShadowType = repoShadow.asObjectable(); assertNotNull("No OID in repo shadow "+repoShadow, repoShadowType.getOid()); assertNotNull("No name in repo shadow "+repoShadow, repoShadowType.getName()); assertNotNull("No objectClass in repo shadow "+repoShadow, repoShadowType.getObjectClass()); assertEquals("Wrong kind in repo shadow "+repoShadow, kind, repoShadowType.getKind()); PrismContainer<Containerable> attributesContainer = repoShadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+repoShadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+repoShadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+repoShadow, (int)expectedNumberOfAttributes, attributes.size()); } }