private <F extends FocusType> void consolidateAssociations(LensContext<F> context, LensProjectionContext projCtx, boolean addUnchangedValues, RefinedObjectClassDefinition rOcDef, ObjectDelta<ShadowType> objectDelta, ObjectDelta<ShadowType> existingDelta, StrengthSelector strengthSelector) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { for (Entry<QName, DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>,PrismContainerDefinition<ShadowAssociationType>>>> entry : projCtx.getSqueezedAssociations().entrySet()) { QName associationName = entry.getKey(); DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>,PrismContainerDefinition<ShadowAssociationType>>> triple = entry.getValue(); ContainerDelta<ShadowAssociationType> containerDelta = consolidateAssociation(rOcDef, projCtx.getResourceShadowDiscriminator(), existingDelta, projCtx, addUnchangedValues, associationName, triple, strengthSelector); if (containerDelta != null) { objectDelta.addModification(containerDelta); } } }
public static <O extends Objectable> void fillInModificationAddReference(ObjectDelta<O> objectDelta, ItemPath refPath, PrismReferenceValue... refValues) { ReferenceDelta refDelta = objectDelta.createReferenceModification(refPath); if (refValues != null) { refDelta.addValuesToAdd(refValues); objectDelta.addModification(refDelta); } }
static <O extends Objectable> void fillInModificationDeleteReference(ObjectDelta<O> objectDelta, ItemPath refPath, PrismReferenceValue... refValues) { ReferenceDelta refDelta = objectDelta.createReferenceModification(refPath); if (refValues != null) { refDelta.addValuesToDelete(refValues); objectDelta.addModification(refDelta); } }
public static <O extends Objectable> void fillInModificationReplaceReference(ObjectDelta<O> objectDelta, ItemPath refPath, PrismReferenceValue... refValues) { ReferenceDelta refDelta = objectDelta.createReferenceModification(refPath); if (refValues != null) { refDelta.setValuesToReplace(refValues); objectDelta.addModification(refDelta); } }
private <F extends FocusType> void consolidateAttributes(LensContext<F> context, LensProjectionContext projCtx, boolean addUnchangedValues, RefinedObjectClassDefinition rOcDef, ObjectDelta<ShadowType> objectDelta, ObjectDelta<ShadowType> existingDelta, StrengthSelector strengthSelector) throws SchemaException, ExpressionEvaluationException, PolicyViolationException { Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>, PrismPropertyDefinition<?>>>> squeezedAttributes = projCtx.getSqueezedAttributes(); // Iterate and process each attribute separately. Now that we have squeezed the data we can process each attribute just // with the data in ItemValueWithOrigin triples. for (Map.Entry<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>,PrismPropertyDefinition<?>>>> entry : squeezedAttributes.entrySet()) { QName attributeName = entry.getKey(); DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>,PrismPropertyDefinition<?>>> triple = entry.getValue(); PropertyDelta<?> propDelta = consolidateAttribute(rOcDef, projCtx.getResourceShadowDiscriminator(), existingDelta, projCtx, addUnchangedValues, attributeName, (DeltaSetTriple)triple, strengthSelector); if (propDelta != null) { objectDelta.addModification(propDelta); } } }
@SafeVarargs static <O extends Objectable, X> void fillInModificationAddProperty(ObjectDelta<O> objectDelta, ItemPath propertyPath, X... propertyValues) { PropertyDelta<X> propertyDelta = objectDelta.createPropertyModification(propertyPath); if (propertyValues != null) { Collection<PrismPropertyValue<X>> valuesToAdd = PrismValueCollectionsUtil .toPrismPropertyValues(objectDelta.getPrismContext(), propertyValues); propertyDelta.addValuesToAdd(valuesToAdd); objectDelta.addModification(propertyDelta); } }
@SafeVarargs public static <O extends Objectable, X> PropertyDelta<X> fillInModificationReplaceProperty(ObjectDelta<O> objectDelta, ItemPath propertyPath, X... propertyValues) { PropertyDelta<X> propertyDelta = objectDelta.createPropertyModification(propertyPath); if (propertyValues != null) { Collection<PrismPropertyValue<X>> valuesToReplace = PrismValueCollectionsUtil .toPrismPropertyValues(objectDelta.getPrismContext(), propertyValues); propertyDelta.setValuesToReplace(valuesToReplace); objectDelta.addModification(propertyDelta); } return propertyDelta; }
@SafeVarargs public static <O extends Objectable, X> void fillInModificationDeleteProperty(ObjectDelta<O> objectDelta, ItemPath propertyPath, X... propertyValues) { PropertyDelta<X> propertyDelta = objectDelta.createPropertyModification(propertyPath); if (propertyValues != null) { Collection<PrismPropertyValue<X>> valuesToDelete = PrismValueCollectionsUtil .toPrismPropertyValues(objectDelta.getPrismContext(), propertyValues); propertyDelta.addValuesToDelete(valuesToDelete); objectDelta.addModification(propertyDelta); } }
@SafeVarargs private static <O extends Objectable, C extends Containerable> void fillInModificationReplaceContainer( ObjectDelta<O> objectDelta, ItemPath propertyPath, C... containerValues) throws SchemaException { if (containerValues != null) { ContainerDelta<C> containerDelta = objectDelta.createContainerModification(propertyPath); Collection<PrismContainerValue<C>> valuesToReplace = PrismValueCollectionsUtil .toPrismContainerValues(objectDelta.getObjectTypeClass(), propertyPath, objectDelta.getPrismContext(), containerValues); containerDelta.setValuesToReplace(valuesToReplace); objectDelta.addModification(containerDelta); } }
private <T> void compareUpdateProperty(ObjectDelta<ShadowType> shadowDelta, ItemPath itemPath, PrismObject<ShadowType> currentResourceShadow, PrismObject<ShadowType> oldRepoShadow) { PrismProperty<T> currentProperty = currentResourceShadow.findProperty(itemPath); PrismProperty<T> oldProperty = oldRepoShadow.findProperty(itemPath); PropertyDelta<T> itemDelta = ItemUtil.diff(oldProperty, currentProperty); if (itemDelta != null && !itemDelta.isEmpty()) { shadowDelta.addModification(itemDelta); } }
private <O extends ObjectType> void computeItemDeltas(final ObjectDelta<O> leftObjectDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, final List<ItemPath> processedPaths, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException { for (ItemRefMergeConfigurationType itemMergeConfig: mergeConfiguration.getItem()) { ItemPath itemPath = prismContext.toPath(itemMergeConfig.getRef()); processedPaths.add(itemPath); ItemDelta itemDelta = mergeItem(objectLeft, objectRight, mergeConfigurationName, itemMergeConfig, itemPath, task, result); LOGGER.trace("Item {} delta: {}", itemPath, itemDelta); if (itemDelta != null && !itemDelta.isEmpty()) { leftObjectDelta.addModification(itemDelta); } } }
private ObjectDelta<UserType> createAssignTwoResourcesDelta(String badResourceOid) throws SchemaException { ObjectDelta<UserType> userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, badResourceOid, null, true); userDelta.addModification(createAccountAssignmentModification(RESOURCE_DUMMY_OID, null, true)); display("input delta", userDelta); return userDelta; }
public static <T extends Objectable> ObjectDelta<T> createObjectDelta(ObjectModificationType objectModification, PrismObjectDefinition<T> objDef) throws SchemaException { ObjectDelta<T> objectDelta = objDef.getPrismContext().deltaFactory().object().create(objDef.getCompileTimeClass(), ChangeType.MODIFY); objectDelta.setOid(objectModification.getOid()); for (ItemDeltaType propMod : objectModification.getItemDelta()) { ItemDelta itemDelta = createItemDelta(propMod, objDef); objectDelta.addModification(itemDelta); } return objectDelta; }
protected ObjectDelta<UserType> createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String accountOid = getLinkRefOid(userOid, resourceOid); PrismObject<ShadowType> account = getShadowModel(accountOid); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); return userDelta; }
protected ObjectDelta<UserType> createModifyUserUnlinkAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String accountOid = getLinkRefOid(userOid, resource.getOid()); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setOid(accountOid); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); return userDelta; }
protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismObject<ShadowType> account = prismContext.parseObject(accountFile); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection)MiscUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); }
private <O extends ObjectType> void applyLastProvisioningTimestamp(LensContext<O> context, ObjectDelta<O> focusDelta) throws SchemaException { if (!context.hasProjectionChange()) { return; } if (focusDelta.isAdd()) { PrismObject<O> objectToAdd = focusDelta.getObjectToAdd(); PrismContainer<MetadataType> metadataContainer = objectToAdd.findOrCreateContainer(ObjectType.F_METADATA); metadataContainer.getRealValue().setLastProvisioningTimestamp(clock.currentTimeXMLGregorianCalendar()); } else if (focusDelta.isModify()) { PropertyDelta<XMLGregorianCalendar> provTimestampDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( ItemPath.create(ObjectType.F_METADATA, MetadataType.F_LAST_PROVISIONING_TIMESTAMP), context.getFocusContext().getObjectDefinition(), clock.currentTimeXMLGregorianCalendar()); focusDelta.addModification(provTimestampDelta); } }
protected <T> ObjectDelta<ShadowType> createAccountDelta(LensProjectionContext accCtx, String accountOid, String attributeLocalName, T... propertyValues) throws SchemaException { ResourceType resourceType = accCtx.getResource(); QName attrQName = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), attributeLocalName); ItemPath attrPath = ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName); RefinedObjectClassDefinition refinedAccountDefinition = accCtx.getCompositeObjectClassDefinition(); RefinedAttributeDefinition attrDef = refinedAccountDefinition.findAttributeDefinition(attrQName); assertNotNull("No definition of attribute "+attrQName+" in account def "+refinedAccountDefinition, attrDef); ObjectDelta<ShadowType> accountDelta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountOid); PropertyDelta<T> attrDelta = prismContext.deltaFactory().property().create(attrPath, attrDef); attrDelta.setValuesToReplace(PrismValueCollectionsUtil.createCollection(prismContext, propertyValues)); accountDelta.addModification(attrDelta); return accountDelta; }
protected ObjectDelta<UserType> createModifyUserAddAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException { PrismObject<ShadowType> account = getAccountShadowDefinition().instantiate(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); account.asObjectable().setResourceRef(resourceRef); RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); account.asObjectable().setObjectClass(refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT).getObjectClassDefinition().getTypeName()); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); return userDelta; }
private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, ObjectSource<PrismObject<ShadowType>> accountSource, ObjectChecker<ModelContext<UserType>> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitSameReverse"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<ShadowType> account = accountSource.get(); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object() .createEmptyModifyDelta(UserType.class, USER_JACK_OID); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountRefDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountRefDelta); ObjectDelta<ShadowType> accountDelta = account.createAddDelta(); Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(accountDelta, userDelta); doPreview(deltas, checker, task, result); }