/** * Returns a delta that is a "sum" of all the deltas in the collection. * The deltas as processed as an ORDERED sequence. Therefore it correctly processes item overwrites and so on. * It also means that if there is an ADD delta it has to be first. */ @SafeVarargs public static <T extends Objectable> ObjectDelta<T> summarize(ObjectDelta<T>... deltas) throws SchemaException { return summarize(Arrays.asList(deltas)); }
/** * Returns user delta, both primary and secondary (merged together). * The returned object is (kind of) immutable. Changing it may do strange things (but most likely the changes will be lost). */ public ObjectDelta<O> getDelta() throws SchemaException { return ObjectDeltaCollectionsUtil.union(primaryDelta, getSecondaryDelta()); }
return mergeToDelta(addDelta, modifyDeltas); } else { if (modifyDeltas.size() == 0) { return modifyDeltas.get(0).clone(); return mergeToDelta(modifyDeltas.get(0), modifyDeltas.subList(1, modifyDeltas.size()));
@Override protected ObjectDelta<UserType> getFocusDelta() throws Exception { return ObjectDeltaCollectionsUtil.summarize(deltaToApprove, delta0); }
public ObjectDelta<O> getFixedDelta() throws SchemaException { return ObjectDeltaCollectionsUtil.union(getFixedPrimaryDelta(), getSecondaryDelta()); }
@Override protected ObjectDelta<UserType> getFocusDelta() throws Exception { return ObjectDeltaCollectionsUtil.summarize(deltaToApprove, delta0); }
public ObjectDelta<O> getWaveDelta(int wave) throws SchemaException { if (wave == 0) { // Primary delta is executed only in the first wave (wave 0) return ObjectDeltaCollectionsUtil.union(getFixedPrimaryDelta(), getWaveSecondaryDelta(wave)); } else { return getWaveSecondaryDelta(wave); } }
@Override protected ObjectDelta<UserType> getFocusDelta() throws Exception { return ObjectDeltaCollectionsUtil.summarize(deltaToApprove, delta0); }
private <AH extends AssignmentHolderType> boolean modificationConstraintMatches(JAXBElement<ModificationPolicyConstraintType> constraintElement, ObjectPolicyRuleEvaluationContext<AH> ctx, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { ModificationPolicyConstraintType constraint = constraintElement.getValue(); if (!operationMatches(ctx.focusContext, constraint.getOperation())) { LOGGER.trace("Rule {} operation not applicable", ctx.policyRule.getName()); return false; } if (!ctx.focusContext.hasAnyDelta()) { return false; } if (!constraint.getItem().isEmpty()) { ObjectDelta<?> summaryDelta = ObjectDeltaCollectionsUtil.union(ctx.focusContext.getPrimaryDelta(), ctx.focusContext.getSecondaryDelta()); if (summaryDelta == null) { return false; } boolean exactPathMatch = isTrue(constraint.isExactPathMatch()); for (ItemPathType path : constraint.getItem()) { if (!pathMatches(summaryDelta, ctx.focusContext.getObjectOld(), prismContext.toPath(path), exactPathMatch)) { return false; } } } return expressionPasses(constraintElement, ctx, result); }
@Override protected ObjectDelta<UserType> getFocusDelta() throws Exception { return ObjectDeltaCollectionsUtil.summarize(deltaToApprove, delta0); }
/** * MODIFY/replace + MODIFY/replace */ @Test public void testObjectDeltaUnion02() throws Exception { final String TEST_NAME="testObjectDeltaUnion02"; displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta<UserType> userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME); ObjectDelta<UserType> userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); // THEN PropertyDelta<PolyString> fullNameDeltaUnion = getCheckedPropertyDeltaFromUnion(userDeltaUnion); Collection<PrismPropertyValue<PolyString>> valuesToReplace = fullNameDeltaUnion.getValuesToReplace(); assertNotNull("No valuesToReplace in fullName delta after union", valuesToReplace); assertEquals("Unexpected size of valuesToReplace in fullName delta after union", 1, valuesToReplace.size()); PrismPropertyValue<PolyString> valueToReplace = valuesToReplace.iterator().next(); assertEquals("Unexcted value in valueToReplace in fullName delta after union", PrismTestUtil.createPolyString("baz"), valueToReplace.getValue()); }
@Override protected ObjectDelta<UserType> getFocusDelta() throws Exception { return ObjectDeltaCollectionsUtil.summarize(deltaToApprove, delta0); }
/** * MODIFY/replace + MODIFY/add */ @Test public void testObjectDeltaUnion03() throws Exception { final String TEST_NAME="testObjectDeltaUnion03"; displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta<UserType> userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME); ObjectDelta<UserType> userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); // THEN PropertyDelta<PolyString> fullNameDeltaUnion = getCheckedPropertyDeltaFromUnion(userDeltaUnion); Collection<PrismPropertyValue<PolyString>> valuesToReplace = fullNameDeltaUnion.getValuesToReplace(); assertNotNull("No valuesToReplace in fullName delta after union", valuesToReplace); assertEquals("Unexpected size of valuesToReplace in fullName delta after union", 1, valuesToReplace.size()); PrismPropertyValue<PolyString> valueToReplace = valuesToReplace.iterator().next(); assertEquals("Unexcted value in valueToReplace in fullName delta after union", PrismTestUtil.createPolyString("baz"), valueToReplace.getValue()); }
public ObjectDelta<? extends FocusType> getSummarizedFocusDeltas() throws SchemaException { return ObjectDeltaCollectionsUtil.summarize(getFocusDeltas()); }
/** * MODIFY/add + MODIFY/add */ @Test public void testObjectDeltaUnion01Simple() throws Exception { final String TEST_NAME="testObjectDeltaUnion01Simple"; displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta<UserType> userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); ObjectDelta<UserType> userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); // THEN assertUnion01Delta(userDeltaUnion); }
@Override public ObjectDeltaType getResourceDelta(ModelContext context, String resourceOid) throws SchemaException { List<ObjectDelta<ShadowType>> deltas = new ArrayList<>(); for (Object modelProjectionContextObject : context.getProjectionContexts()) { LensProjectionContext lensProjectionContext = (LensProjectionContext) modelProjectionContextObject; if (lensProjectionContext.getResourceShadowDiscriminator() != null && resourceOid.equals(lensProjectionContext.getResourceShadowDiscriminator().getResourceOid())) { deltas.add(lensProjectionContext.getDelta()); // union of primary and secondary deltas } } ObjectDelta<ShadowType> sum = ObjectDeltaCollectionsUtil.summarize(deltas); return DeltaConvertor.toObjectDeltaType(sum); }
/** * MODIFY/add + MODIFY/add */ @Test public void testObjectDeltaUnion01Metadata() throws Exception { final String TEST_NAME="testObjectDeltaUnion01Metadata"; displayTestTitle(TEST_NAME); // GIVEN ObjectDelta<UserType> userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); PropertyDelta<PolyString> fullNameDelta2 = getPrismContext().deltaFactory().property().createDelta(UserType.F_FULL_NAME, UserType.class); PrismPropertyValue<PolyString> fullNameValue2 = new PrismPropertyValueImpl<>(PrismTestUtil.createPolyString("baz")); // Set some metadata to spoil usual equals fullNameValue2.setOriginType(OriginType.OUTBOUND); fullNameDelta2.addValueToAdd(fullNameValue2); ObjectDelta<UserType> userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModifyDelta(USER_FOO_OID, fullNameDelta2, UserType.class ); // WHEN ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); // THEN assertUnion01Delta(userDeltaUnion); }
ObjectDelta<FocusType> delta = ObjectDeltaCollectionsUtil.summarize(modelEvent.getFocusDeltas());
ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2);
deltas.add((ObjectDelta) DeltaConvertor.createObjectDelta(change.getValue(), prismContext)); ObjectDelta<ShadowType> summarizedDelta = ObjectDeltaCollectionsUtil.summarize(deltas); rv.append(textFormatter.formatObjectModificationDelta(summarizedDelta, hiddenPaths, showAuxiliaryAttributes, event.getAccountOperationDescription().getCurrentShadow(), null));