public static <T> PropertyDelta<T> findPropertyDelta(Collection<? extends ItemDelta> modifications, ItemPath propertyPath) { for (ItemDelta delta: modifications) { if (delta instanceof PropertyDelta && delta.getPath().equivalent(propertyPath)) { return (PropertyDelta) delta; } } return null; }
public static Collection<? extends ItemDelta<?,?>> findItemDeltasSubPath(Collection<? extends ItemDelta<?, ?>> deltas, ItemPath itemPath) { Collection<ItemDelta<?,?>> foundDeltas = new ArrayList<>(); if (deltas == null) { return foundDeltas; } for (ItemDelta<?,?> delta : deltas) { if (itemPath.isSubPath(delta.getPath())) { foundDeltas.add(delta); } } return foundDeltas; }
private RObjectExtensionType computeObjectExtensionType(ItemDelta delta) { if (isObjectExtensionDelta(delta.getPath())) { return RObjectExtensionType.EXTENSION; } else if (isShadowAttributesDelta(delta.getPath())) { return RObjectExtensionType.ATTRIBUTES; } throw new IllegalStateException("Unknown extension type, shouldn't happen"); }
@Override public void modifyExtension(ItemDelta itemDelta) throws SchemaException { if (ItemPath.isEmpty(itemDelta.getPath()) || !itemDelta.getPath().startsWithName(TaskType.F_EXTENSION)) { throw new IllegalArgumentException( "modifyExtension must modify the Task extension element; however, the path is " + itemDelta.getPath()); } processModificationBatched(modifyExtensionAndPrepareDelta(itemDelta)); }
private <T extends ObjectType> boolean containsPhotoModification(Collection<? extends ItemDelta> modifications) { for (ItemDelta delta : modifications) { ItemPath path = delta.getPath(); if (path.isEmpty()) { throw new UnsupportedOperationException("Focus cannot be modified via empty-path modification"); } else if (FocusType.F_JPEG_PHOTO.isSubPathOrEquivalent(path)) { // actually, "subpath" variant should not occur return true; } } return false; }
protected boolean deltaContainsOtherPathsThan(ObjectDelta<? extends ObjectType> delta, List<ItemPath> paths) { for (ItemDelta itemDelta : delta.getModifications()) { if (!NotificationFunctionsImpl.isAmongHiddenPaths(itemDelta.getPath(), paths)) { return true; } } return false; }
public static boolean isAttributeModification(ItemDelta modification) { QName firstPathName = modification.getPath().firstName(); return isAttributeModification(firstPathName); }
private void formatItemDeltaContent(StringBuilder sb, ItemDelta itemDelta, PrismObject objectOld, List<ItemPath> hiddenPaths, boolean showOperationalAttributes) { formatItemDeltaValues(sb, "ADD", itemDelta.getValuesToAdd(), false, itemDelta.getPath(), objectOld, hiddenPaths, showOperationalAttributes); formatItemDeltaValues(sb, "DELETE", itemDelta.getValuesToDelete(), true, itemDelta.getPath(), objectOld, hiddenPaths, showOperationalAttributes); formatItemDeltaValues(sb, "REPLACE", itemDelta.getValuesToReplace(), false, itemDelta.getPath(), objectOld, hiddenPaths, showOperationalAttributes); }
private boolean isOperationResult(ItemDelta delta) throws SchemaException { ItemDefinition def = delta.getDefinition(); if (def == null) { throw new SchemaException("No definition in delta for item " + delta.getPath()); } return OperationResultType.COMPLEX_TYPE.equals(def.getTypeName()); }
public static boolean isResourceModification(ItemDelta modification) { QName firstPathName = modification.getPath().firstName(); return isAttributeModification(firstPathName) || isNonAttributeResourceModification(firstPathName); }
public void applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force) throws SchemaException { if (objectToAdd != null) { objectToAdd.applyDefinition(objectDefinition, force); } for (ItemDelta modification: modifications) { ItemPath path = modification.getPath(); ItemDefinition itemDefinition = objectDefinition.findItemDefinition(path); modification.applyDefinition(itemDefinition, force); } }
private ItemDelta createNewDelta(FactorOutResultMulti<O> rv, ItemDelta<?, ?> modification) throws SchemaException { ObjectDeltaImpl<O> offspring = createOffspring(); ItemDelta delta = modification.getDefinition().instantiate().createDelta(modification.getPath()); offspring.addModification(delta); rv.offsprings.add(offspring); return delta; }
public static <O extends Objectable> void setDeltaOldValue(PrismObject<O> oldObject, ItemDelta<?,?> itemDelta) { if (oldObject == null) { return; } Item<PrismValue, ItemDefinition> itemOld = oldObject.findItem(itemDelta.getPath()); if (itemOld != null) { itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); } }
public static void applyDefinitionIfPresent(Collection<? extends ItemDelta> deltas, PrismObjectDefinition definition, boolean tolerateNoDefinition) throws SchemaException { for (ItemDelta itemDelta : deltas) { ItemPath path = itemDelta.getPath(); ItemDefinition itemDefinition = ((ItemDefinition) definition).findItemDefinition(path, ItemDefinition.class); if (itemDefinition != null) { itemDelta.applyDefinition(itemDefinition); } else if (!tolerateNoDefinition) { throw new SchemaException("Object type " + definition.getTypeName() + " doesn't contain definition for path " + path); } } }
private <F extends ObjectType> AuthorizationDecisionType evaluateCredentialDecision(LensContext<F> context, ObjectSecurityConstraints securityConstraints, ItemDelta credentialChange) { return securityConstraints.findItemDecision(credentialChange.getPath().namedSegmentsOnly(), ModelAuthorizationAction.CHANGE_CREDENTIALS.getUrl(), getRequestAuthorizationPhase(context)); }
public static void accept(Collection<? extends ItemDelta> modifications, Visitor visitor, ItemPath path, boolean recursive) { for (ItemDelta modification: modifications) { ItemPath modPath = modification.getPath(); ItemPath.CompareResult rel = modPath.compareComplex(path); if (rel == ItemPath.CompareResult.EQUIVALENT) { modification.accept(visitor, null, recursive); } else if (rel == ItemPath.CompareResult.SUBPATH) { modification.accept(visitor, path.remainder(modPath), recursive); } } }
public static void clearCacheForDelta(Collection<? extends ItemDelta> modifications) { if (modifications == null) { return; } for (ItemDelta itemDelta : modifications) { if (ObjectType.F_NAME.equivalent(itemDelta.getPath())) { clearCacheForValues(itemDelta.getValuesToAdd()); // these may present a conflict clearCacheForValues(itemDelta.getValuesToReplace()); // so do these } } }
public <T> void normalizeDelta(ItemDelta<PrismPropertyValue<T>,PrismPropertyDefinition<T>> delta, RefinedObjectClassDefinition objectClassDefinition) throws SchemaException { if (!delta.getPath().startsWithName(ShadowType.F_ATTRIBUTES)) { return; } RefinedAttributeDefinition rAttrDef = objectClassDefinition.findAttributeDefinition(delta.getElementName()); if (rAttrDef == null){ throw new SchemaException("Failed to normalize attribute: " + delta.getElementName()+ ". Definition for this attribute doesn't exist."); } normalizeDelta(delta, rAttrDef); }
@Override public RObjectReference map(Referencable input, MapperContext context) { ObjectReferenceType objectRef = buildReference(input); ObjectTypeUtil.normalizeRelation(objectRef, context.getRelationRegistry()); RObject owner = (RObject) context.getOwner(); Class<? extends ObjectType> jaxbObjectType = RObjectType.getType(owner.getClass()).getJaxbClass(); RReferenceOwner refType = RReferenceOwner.getOwnerByQName(jaxbObjectType, context.getDelta().getPath().lastName()); return RUtil.jaxbRefToRepo(objectRef, owner, refType, context.getRelationRegistry()); } }