this.name = ((o.name == null)?null:o.getName()); this.description = ((o.description == null)?null:o.getDescription()); copyObjectClass(o.getObjectClass(), this.getObjectClass()); this.kind = ((o.kind == null)?null:o.getKind()); this.intent = ((o.intent == null)?null:o.getIntent()); this.focusType = ((o.focusType == null)?null:o.getFocusType()); this.enabled = ((o.enabled == null)?null:o.isEnabled()); this.condition = ((o.condition == null)?null:((o.getCondition() == null)?null:o.getCondition().clone())); copyCorrelation(o.getCorrelation(), this.getCorrelation()); this.confirmation = ((o.confirmation == null)?null:((o.getConfirmation() == null)?null:o.getConfirmation().clone())); this.objectTemplateRef = ((o.objectTemplateRef == null)?null:((o.getObjectTemplateRef() == null)?null:o.getObjectTemplateRef().clone())); this.reconcile = ((o.reconcile == null)?null:o.isReconcile()); this.limitPropagation = ((o.limitPropagation == null)?null:o.isLimitPropagation()); this.opportunistic = ((o.opportunistic == null)?null:o.isOpportunistic()); copyReaction(o.getReaction(), this.getReaction());
/** * Create an instance of {@link ObjectSynchronizationType } * */ public ObjectSynchronizationType createObjectSynchronizationType() { return new ObjectSynchronizationType(); }
@Override public String toString() { String policyDesc = null; if (objectSynchronization != null) { if (objectSynchronization.getName() == null) { policyDesc = "(kind=" + objectSynchronization.getKind() + ", intent=" + objectSynchronization.getIntent() + ", objectclass=" + objectSynchronization.getObjectClass() + ")"; } else { policyDesc = objectSynchronization.getName(); } } return policyDesc; }
private String getName(ObjectSynchronizationType objectSync) { StringBuilder sb = new StringBuilder(); if (objectSync.getName() != null) { sb.append(objectSync.getName()); sb.append(" ("); } sb.append("kind: "); sb.append(fillDefault(objectSync.getKind())); sb.append(", intent: "); sb.append(fillDefault(objectSync.getIntent())); if (objectSync.getName() != null) { sb.append(")"); } return sb.toString(); }
public List<ConditionalSearchFilterType> getCorrelation() { return objectSynchronization.getCorrelation(); }
public static boolean isPolicyApplicable(QName objectClass, ShadowKindType kind, String intent, ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource, boolean strictIntent) throws SchemaException { List<QName> policyObjectClasses = synchronizationPolicy.getObjectClass(); ShadowKindType policyKind = synchronizationPolicy.getKind(); if (policyKind == null) { policyKind = ShadowKindType.ACCOUNT; String policyIntent = synchronizationPolicy.getIntent();
QName focusTypeQName = objSyncType.getFocusType(); if (focusTypeQName == null) { if (type != UserType.class) { if (name.equals(objSyncType.getName())) { return objSyncType;
private void checkObjectSynchronization(ResourceValidationContext ctx, ItemPath path, ObjectSynchronizationType objectSync) { Map<SynchronizationSituationType,Integer> counts = new HashMap<>(); for (SynchronizationReactionType reaction : objectSync.getReaction()) { if (reaction.getSituation() == null) { ctx.validationResult.add(Issue.Severity.WARNING, CAT_SYNCHRONIZATION, C_NO_SITUATION, getString(CLASS_DOT + C_NO_SITUATION, getName(objectSync)), ctx.resourceRef, path); } else { Integer c = counts.get(reaction.getSituation()); counts.put(reaction.getSituation(), c != null ? c+1 : 1); } } checkMissingReactions(ctx, path, objectSync, counts, Collections.singletonList(UNLINKED)); checkDuplicateReactions(ctx, path, objectSync, counts); if (objectSync.getCorrelation().isEmpty()) { ctx.validationResult.add(Issue.Severity.WARNING, CAT_SYNCHRONIZATION, C_NO_CORRELATION_RULE, getString(CLASS_DOT + C_NO_CORRELATION_RULE, getName(objectSync)), ctx.resourceRef, path); } }
private static <F extends FocusType> Boolean evaluateSynchronizationPolicyCondition(ObjectSynchronizationType synchronizationPolicy, SynchronizationContext<F> syncCtx, ExpressionFactory expressionFactory) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { if (synchronizationPolicy.getCondition() == null) { return null; } ExpressionType conditionExpressionType = synchronizationPolicy.getCondition(); String desc = "condition in object synchronization " + synchronizationPolicy.getName(); ExpressionVariables variables = ModelImplUtils.getDefaultExpressionVariables(null, syncCtx.getApplicableShadow(), null, syncCtx.getResource(), syncCtx.getSystemConfiguration(), null); try { ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(syncCtx.getTask(), syncCtx.getResult())); PrismPropertyValue<Boolean> evaluateCondition = ExpressionUtil.evaluateCondition(variables, conditionExpressionType, expressionFactory, desc, syncCtx.getTask(), syncCtx.getResult()); return evaluateCondition.getValue(); } finally { ModelExpressionThreadLocalHolder.popExpressionEnvironment(); } } }
private void assumeUserTemplate(String templateOid, ResourceType resource, String syncConfigName, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { SynchronizationType resourceSync = resource.getSynchronization(); resourceSync.getObjectSynchronization().get(0).setObjectTemplateRef(ObjectTypeUtil.createObjectRef(templateOid, ObjectTypes.OBJECT_TEMPLATE)); Collection<? extends ItemDelta> refDelta = prismContext.deltaFactory().property() .createModificationReplacePropertyCollection(ResourceType.F_SYNCHRONIZATION, resource.asPrismObject().getDefinition(), resourceSync); repositoryService.modifyObject(ResourceType.class, resource.getOid(), refDelta, result); ResourceType res = repositoryService.getObject(ResourceType.class, resource.getOid(), null, result).asObjectable(); assertNotNull(res); assertNotNull("Synchronization is not specified", res.getSynchronization()); ObjectSynchronizationType ost = determineSynchronization(res, UserType.class, syncConfigName); assertNotNull("object sync type is not specified", ost); assertNotNull("user template not specified", ost.getObjectTemplateRef()); assertEquals("Wrong user template in resource", templateOid, ost.getObjectTemplateRef().getOid()); }
public ObjectSynchronizationType objectClass(QName value) { getObjectClass().add(value); return this; }
public Class<F> getFocusClass() throws SchemaException { if (focusClass != null) { return focusClass; } if (!hasApplicablePolicy()) { throw new IllegalStateException("synchronizationPolicy is null"); } QName focusTypeQName = objectSynchronization.getFocusType(); if (focusTypeQName == null) { this.focusClass = (Class<F>) UserType.class; return focusClass; } ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName); if (objectType == null) { throw new SchemaException("Unknown focus type " + focusTypeQName + " in synchronization policy in " + resource); } this.focusClass = (Class<F>) objectType.getClassDefinition(); return focusClass; }
public void setObjectSynchronization(ObjectSynchronizationType objectSynchronization) { this.intent = objectSynchronization.getIntent(); this.objectSynchronization = objectSynchronization; }
public ObjectReferenceType getObjectTemplateRef() { if (reaction.getObjectTemplateRef() != null) { return reaction.getObjectTemplateRef(); } return objectSynchronization.getObjectTemplateRef(); }
public ExpressionType getConfirmation() { return objectSynchronization.getConfirmation(); }
public ObjectSynchronizationType correlation(ConditionalSearchFilterType value) { getCorrelation().add(value); return this; }
@Nullable public static ObjectSynchronizationType findObjectSynchronization(@Nullable ResourceType resource, @Nullable ShadowKindType kind, @Nullable String intent) { if (resource == null || resource.getSynchronization() == null) { return null; } for (ObjectSynchronizationType def : resource.getSynchronization().getObjectSynchronization()) { if (fillDefault(kind).equals(fillDefault(def.getKind())) && fillDefault(intent).equals(fillDefault(def.getIntent()))) { return def; } } return null; }