/** * Returns intent from the shadow. Backwards compatible with older accountType. May also adjust for default * intent if necessary. */ public static String getIntent(ShadowType shadow) { if (shadow == null) { return null; } String intent = shadow.getIntent(); if (intent != null) { return intent; } return null; }
private boolean isShadowUnknown(ShadowType shadowType) { if (ShadowKindType.UNKNOWN == shadowType.getKind()) { return true; } if (SchemaConstants.INTENT_UNKNOWN.equals(shadowType.getIntent())) { return true; } return false; } }
private String getIntent(PrismObject<ShadowType> shadow, String objectSynchronizationIntent) { String shadowIntent = shadow.asObjectable().getIntent(); if (shadowIntent != null) { return shadowIntent; } return objectSynchronizationIntent; }
private <F extends FocusType> boolean shouldSaveIntent(SynchronizationContext<F> syncCtx) throws SchemaException { ShadowType shadow = syncCtx.getCurrentShadow().asObjectable(); if (shadow.getIntent() == null) { return true; } if (SchemaConstants.INTENT_UNKNOWN.equals(shadow.getIntent())) { return true; } if (syncCtx.isForceIntentChange()) { String objectSyncIntent = syncCtx.getIntent(); if (!MiscSchemaUtil.equalsIntent(shadow.getIntent(), objectSyncIntent)) { return true; } } return false; }
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 + ")"; }
public void setIntentIfNecessary(ShadowType repoShadowType, RefinedObjectClassDefinition objectClassDefinition) { if (repoShadowType.getIntent() == null && objectClassDefinition.getIntent() != null) { repoShadowType.setIntent(objectClassDefinition.getIntent()); } }
public static boolean isConflicting(ShadowType shadow1, ShadowType shadow2) { if (!shadow1.getResourceRef().getOid().equals(shadow2.getResourceRef().getOid())) { return false; } if (!MiscUtil.equals(getKind(shadow1), getKind(shadow2))) { return false; } return ResourceShadowDiscriminator.equalsIntent(shadow1.getIntent(), shadow2.getIntent()); }
public static <F extends FocusType> LensProjectionContext getProjectionContext(LensContext<F> context, PrismObject<ShadowType> equivalentAccount, ProvisioningService provisioningService, PrismContext prismContext, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ShadowType equivalentAccountType = equivalentAccount.asObjectable(); ShadowKindType kind = ShadowUtil.getKind(equivalentAccountType); return getProjectionContext(context, ShadowUtil.getResourceOid(equivalentAccountType), kind, equivalentAccountType.getIntent(), provisioningService, prismContext, task, result); }
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 static boolean matches(ShadowType shadowType, String resourceOid, ShadowKindType kind, String intent) { if (shadowType == null) { return false; } if (!resourceOid.equals(shadowType.getResourceRef().getOid())) { return false; } if (!MiscUtil.equals(kind, shadowType.getKind())) { return false; } if (intent == null) { return true; } return MiscUtil.equals(intent, shadowType.getIntent()); }
public ShadowAsserter<RA> assertIntent(String expected) { assertEquals("Wrong intent in "+desc(), expected, getObject().asObjectable().getIntent()); 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()); }
protected void assertShadowKindIntent(PrismObject<ShadowType> shadow, ShadowKindType expectedKind, String expectedIntent) { assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); }
@Override public boolean matches(ShadowType shadowType) { if (shadowType == null) { return false; } if (!QNameUtil.match(getObjectClassDefinition().getTypeName(), shadowType.getObjectClass())) { return false; } if (shadowType.getKind() == null) { if (kind != ShadowKindType.ACCOUNT) { return false; } } else { if (!MiscUtil.equals(kind, shadowType.getKind())) { return false; } } if (shadowType.getIntent() != null) { // if (isDefault) { // return true; // } else { // return false; // } // } else { return MiscUtil.equals(intent, shadowType.getIntent()); } return true; }
/** * Strict mathcing. E.g. null discriminator kind is intepreted as ACCOUNT and it must match the kind * in the shadow. */ public static boolean matches(ShadowType shadowType, ResourceShadowDiscriminator discr) { if (shadowType == null) { return false; } if (!discr.getResourceOid().equals(shadowType.getResourceRef().getOid())) { return false; } if (!MiscUtil.equals(discr.getKind(), shadowType.getKind())) { return false; } return ResourceShadowDiscriminator.equalsIntent(shadowType.getIntent(), discr.getIntent()); }
protected <F extends FocusType> String getLinkRefOid(PrismObject<F> focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { F focusType = focus.asObjectable(); for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { String linkTargetOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); PrismObject<ShadowType> account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); ShadowType shadowType = account.asObjectable(); if (kind != null && !kind.equals(shadowType.getKind())) { continue; } if (!MiscUtil.equals(intent, shadowType.getIntent())) { continue; } if (resourceOid.equals(shadowType.getResourceRef().getOid())) { // This is noFetch. Therefore there is no fetchResult return linkTargetOid; } } AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); return null; // Never reached. But compiler complains about missing return }
/** * Interprets ResourceShadowDiscriminator as a pattern. E.g. null discriminator kind is * interpreted to match any shadow kind. */ public static boolean matchesPattern(ShadowType shadowType, ShadowDiscriminatorType discr) { if (shadowType == null) { return false; } if (!discr.getResourceRef().getOid().equals(shadowType.getResourceRef().getOid())) { return false; } if (discr.getKind() != null && !MiscUtil.equals(discr.getKind(), shadowType.getKind())) { return false; } if (discr.getIntent() == null) { return true; } return ResourceShadowDiscriminator.equalsIntent(shadowType.getIntent(), discr.getIntent()); }
private RefinedObjectClassDefinition determineObjectClassDefinition(PrismObject<ShadowType> shadow, ResourceType resource) throws SchemaException, ConfigurationException { ShadowType shadowType = shadow.asObjectable(); RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext); if (refinedSchema == null) { throw new ConfigurationException("No schema definied for "+resource); } RefinedObjectClassDefinition objectClassDefinition = null; ShadowKindType kind = shadowType.getKind(); String intent = shadowType.getIntent(); QName objectClass = shadow.asObjectable().getObjectClass(); if (kind != null) { objectClassDefinition = refinedSchema.getRefinedDefinition(kind, intent); } else { // Fallback to objectclass only if (objectClass == null) { throw new SchemaException("No kind nor objectclass definied in "+shadow); } objectClassDefinition = refinedSchema.findRefinedDefinitionByObjectClassQName(null, objectClass); } if (objectClassDefinition == null) { throw new SchemaException("Definition for "+shadow+" not found (objectClass=" + PrettyPrinter.prettyPrint(objectClass) + ", kind="+kind+", intent='"+intent+"') in schema of " + resource); } return objectClassDefinition; }
@Test public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { final String TEST_NAME = "test100FixDuplicatesWithDifferentObjectClasses"; TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // GIVEN SearchResultList<PrismObject<ShadowType>> shadowsBefore = repositoryService .searchObjects(ShadowType.class, null, null, result); display("shadows before", shadowsBefore); assertEquals("Wrong # of shadows before", 3, shadowsBefore.size()); repoAddObjectFromFile(TASK_SHADOW_INTEGRITY_CHECK_FILE, result); // WHEN displayWhen(TEST_NAME); waitForTaskCloseOrSuspend(TASK_SHADOW_INTEGRITY_CHECK_OID); // THEN displayThen(TEST_NAME); PrismObject<TaskType> taskAfter = getTask(TASK_SHADOW_INTEGRITY_CHECK_OID); display("task after", taskAfter); SearchResultList<PrismObject<ShadowType>> shadowsAfter = repositoryService .searchObjects(ShadowType.class, null, null, result); display("shadows after", shadowsAfter); assertEquals("Wrong # of shadows after", 2, shadowsAfter.size()); PrismObject<ShadowType> intent1 = shadowsAfter.stream() .filter(o -> "intent1".equals(o.asObjectable().getIntent())).findFirst().orElse(null); assertNotNull("intent1 shadow was removed", intent1); }