protected void closeCase(String caseOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { OperationResult result = new OperationResult("closeCase"); Collection modifications = new ArrayList<>(1); PrismPropertyDefinition<String> statePropertyDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(CaseType.class).findPropertyDefinition(CaseType.F_STATE); PropertyDelta<String> statusDelta = statePropertyDef.createEmptyDelta(CaseType.F_STATE); statusDelta.setRealValuesToReplace(SchemaConstants.CASE_STATE_CLOSED); modifications.add(statusDelta); PrismPropertyDefinition<String> outcomePropertyDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(CaseType.class).findPropertyDefinition(CaseType.F_OUTCOME); PropertyDelta<String> outcomeDelta = outcomePropertyDef.createEmptyDelta(CaseType.F_OUTCOME); outcomeDelta.setRealValuesToReplace(OperationResultStatusType.SUCCESS.value()); modifications.add(outcomeDelta); repositoryService.modifyObject(CaseType.class, caseOid, modifications, null, result); PrismObject<CaseType> caseClosed = repositoryService.getObject(CaseType.class, caseOid, null, result); display("Case closed", caseClosed); }
public static PropertyDelta<XMLGregorianCalendar> createActivationTimestampDelta(ActivationStatusType status, XMLGregorianCalendar now, PrismContainerDefinition<ActivationType> activationDefinition, OriginType origin, PrismContext prismContext) { ItemName timestampPropertyName; if (status == null || status == ActivationStatusType.ENABLED) { timestampPropertyName = ActivationType.F_ENABLE_TIMESTAMP; } else if (status == ActivationStatusType.DISABLED) { timestampPropertyName = ActivationType.F_DISABLE_TIMESTAMP; } else if (status == ActivationStatusType.ARCHIVED) { timestampPropertyName = ActivationType.F_ARCHIVE_TIMESTAMP; } else { throw new IllegalArgumentException("Unknown activation status "+status); } PrismPropertyDefinition<XMLGregorianCalendar> timestampDef = activationDefinition.findPropertyDefinition(timestampPropertyName); PropertyDelta<XMLGregorianCalendar> timestampDelta = timestampDef.createEmptyDelta(FocusType.F_ACTIVATION.append(timestampPropertyName)); timestampDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(now, origin, null)); return timestampDelta; }
private void resetFailedLogins(LensFocusContext<UserType> focusContext, AbstractCredentialType credentialTypeNew, ItemPath path) throws SchemaException{ if (credentialTypeNew != null) { Integer failedLogins = credentialTypeNew.getFailedLogins(); if (failedLogins != null && failedLogins != 0) { PrismPropertyDefinition<Integer> failedLoginsDef = getFailedLoginsDefinition(); PropertyDelta<Integer> failedLoginsDelta = failedLoginsDef.createEmptyDelta(path); failedLoginsDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(0, OriginType.USER_POLICY, null)); focusContext.swallowToProjectionWaveSecondaryDelta(failedLoginsDelta); } } }
private <T> PropertyDelta<T> createShadowPropertyReplaceDelta(PrismObject<ShadowType> repoShadow, QName propName, T value) { PrismPropertyDefinition<T> def = repoShadow.getDefinition().findPropertyDefinition(ItemName.fromQName(propName)); PropertyDelta<T> delta = def.createEmptyDelta(ItemPath.create(propName)); if (value == null) { delta.setValueToReplace(); } else { delta.setRealValuesToReplace(value); } return delta; }
private void addModifyMetadataDeltas(PrismObject<ShadowType> repoShadow, Collection<ItemDelta> shadowChanges) { PropertyDelta<XMLGregorianCalendar> modifyTimestampDelta = ItemDeltaCollectionsUtil .findPropertyDelta(shadowChanges, SchemaConstants.PATH_METADATA_MODIFY_TIMESTAMP); if (modifyTimestampDelta != null) { return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Metadata not found, adding minimal metadata. Modifications:\n{}", DebugUtil.debugDump(shadowChanges, 1)); } PrismPropertyDefinition<XMLGregorianCalendar> def = repoShadow.getDefinition().findPropertyDefinition(SchemaConstants.PATH_METADATA_MODIFY_TIMESTAMP); modifyTimestampDelta = def.createEmptyDelta(SchemaConstants.PATH_METADATA_MODIFY_TIMESTAMP); modifyTimestampDelta.setRealValuesToReplace(clock.currentTimeXMLGregorianCalendar()); shadowChanges.add(modifyTimestampDelta); } }
private <F extends ObjectType> void recordValidityDelta(LensFocusContext<F> focusContext, TimeIntervalStatusType validityStatusNew, XMLGregorianCalendar now) throws SchemaException { PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition(); PrismPropertyDefinition<TimeIntervalStatusType> validityStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_STATUS); PropertyDelta<TimeIntervalStatusType> validityStatusDelta = validityStatusDef.createEmptyDelta(ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_STATUS)); if (validityStatusNew == null) { validityStatusDelta.setValueToReplace(); } else { validityStatusDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(validityStatusNew, OriginType.USER_POLICY, null)); } focusContext.swallowToProjectionWaveSecondaryDelta(validityStatusDelta); PrismPropertyDefinition<XMLGregorianCalendar> validityChangeTimestampDef = activationDefinition.findPropertyDefinition(ActivationType.F_VALIDITY_CHANGE_TIMESTAMP); PropertyDelta<XMLGregorianCalendar> validityChangeTimestampDelta = validityChangeTimestampDef.createEmptyDelta(ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALIDITY_CHANGE_TIMESTAMP)); validityChangeTimestampDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(now, OriginType.USER_POLICY, null)); focusContext.swallowToProjectionWaveSecondaryDelta(validityChangeTimestampDelta); }
private <X> PropertyDelta<X> resolveStructuredPropertyDelta(PropertyDelta<Structured> sourceDelta, ItemPath resolvePath, PrismPropertyDefinition outputDefinition, ItemPath outputPath, PrismContext prismContext) { if (sourceDelta == null) { return null; } PropertyDelta<X> outputDelta = (PropertyDelta<X>) outputDefinition.createEmptyDelta(outputPath); Collection<PrismPropertyValue<X>> outputValuesToAdd = resolveStructuredDeltaSet(sourceDelta.getValuesToAdd(), resolvePath, prismContext); if (outputValuesToAdd != null) { outputDelta.addValuesToAdd(outputValuesToAdd); } Collection<PrismPropertyValue<X>> outputValuesToDelete = resolveStructuredDeltaSet(sourceDelta.getValuesToDelete(), resolvePath, prismContext); if (outputValuesToDelete != null) { outputDelta.addValuesToDelete(outputValuesToDelete); } Collection<PrismPropertyValue<X>> outputValuesToReplace = resolveStructuredDeltaSet(sourceDelta.getValuesToReplace(), resolvePath, prismContext); if (outputValuesToReplace != null) { outputDelta.setValuesToReplace(outputValuesToReplace); } return outputDelta; }
throw new SchemaException("No definition for item "+mappingOutputPath+" in "+targetObjectDefinition); PropertyDelta<T> targetItemDelta = targetItemDefinition.createEmptyDelta(mappingOutputPath);
public static Object getIterationVariableValue(LensProjectionContext accCtx) { Integer iterationOld = null; PrismObject<ShadowType> shadowCurrent = accCtx.getObjectCurrent(); if (shadowCurrent != null) { iterationOld = shadowCurrent.asObjectable().getIteration(); } if (iterationOld == null) { return accCtx.getIteration(); } PrismPropertyDefinition<Integer> propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_ITERATION, DOMUtil.XSD_INT); PrismProperty<Integer> propOld = propDef.instantiate(); propOld.setRealValue(iterationOld); PropertyDelta<Integer> propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION); propDelta.setRealValuesToReplace(accCtx.getIteration()); PrismProperty<Integer> propNew = propDef.instantiate(); propNew.setRealValue(accCtx.getIteration()); ItemDeltaItem<PrismPropertyValue<Integer>,PrismPropertyDefinition<Integer>> idi = new ItemDeltaItem<>(propOld, propDelta, propNew); return idi; }
public static Object getIterationTokenVariableValue(LensProjectionContext accCtx) { String iterationTokenOld = null; PrismObject<ShadowType> shadowCurrent = accCtx.getObjectCurrent(); if (shadowCurrent != null) { iterationTokenOld = shadowCurrent.asObjectable().getIterationToken(); } if (iterationTokenOld == null) { return accCtx.getIterationToken(); } PrismPropertyDefinition<String> propDef = accCtx.getPrismContext().definitionFactory().createPropertyDefinition( ExpressionConstants.VAR_ITERATION_TOKEN, DOMUtil.XSD_STRING); PrismProperty<String> propOld = propDef.instantiate(); propOld.setRealValue(iterationTokenOld); PropertyDelta<String> propDelta = propDef.createEmptyDelta(ExpressionConstants.VAR_ITERATION_TOKEN); propDelta.setRealValuesToReplace(accCtx.getIterationToken()); PrismProperty<String> propNew = propDef.instantiate(); propNew.setRealValue(accCtx.getIterationToken()); ItemDeltaItem<PrismPropertyValue<String>,PrismPropertyDefinition<String>> idi = new ItemDeltaItem<>(propOld, propDelta, propNew); return idi; }
= effectiveStatusDef.createEmptyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); effectiveStatusDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(effectiveStatusNew, OriginType.USER_POLICY, null)); if (!focusContext.alreadyHasDelta(effectiveStatusDelta)){
throw new SchemaException("No definition for property "+itemPath+" in "+focusDefinition+" as specified in object policy"); PropertyDelta<Object> propDelta = propDef.createEmptyDelta(itemPath); if (String.class.isAssignableFrom(propDef.getTypeClass())) { propDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(newValue, OriginType.USER_POLICY, null)); PrismObjectDefinition<AH> focusDefinition = focusContext.getObjectDefinition(); PrismPropertyDefinition<PolyString> focusNameDef = focusDefinition.findPropertyDefinition(FocusType.F_NAME); PropertyDelta<PolyString> nameDelta = focusNameDef.createEmptyDelta(FocusType.F_NAME); nameDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(new PolyString(newValue), OriginType.USER_POLICY, null)); focusContext.swallowToSecondaryDelta(nameDelta);
if (!expectedEffectiveStatus.equals(currentEffectiveStatus)) { PrismPropertyDefinition<ActivationStatusType> effectiveStatusPropertyDef = focusContext.getObjectDefinition().findPropertyDefinition(SchemaConstants.PATH_ASSIGNMENT_ACTIVATION_EFFECTIVE_STATUS); PropertyDelta<ActivationStatusType> effectiveStatusDelta = effectiveStatusPropertyDef.createEmptyDelta( ItemPath.create(FocusType.F_ASSIGNMENT, assignmentType.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS)); effectiveStatusDelta.setRealValuesToReplace(expectedEffectiveStatus);
disableReasonDelta = disableReasonDef.createEmptyDelta( ItemPath.create(FocusType.F_ACTIVATION, ActivationType.F_DISABLE_REASON)); disableReasonDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(disableReason, OriginType.OUTBOUND, null));
PropertyDelta<String> lifeCycleDelta = propDef.createEmptyDelta(SchemaConstants.PATH_LIFECYCLE_STATE); PrismPropertyValue<String> pval = prismContext.itemFactory().createPropertyValue(lifecycle); pval.setOriginType(OriginType.OUTBOUND);
PrismPropertyDefinition<XMLGregorianCalendar> lockoutExpirationTimestampDef = activationDefinition.findPropertyDefinition(ActivationType.F_LOCKOUT_EXPIRATION_TIMESTAMP); PropertyDelta<XMLGregorianCalendar> lockoutExpirationTimestampDelta = lockoutExpirationTimestampDef.createEmptyDelta(ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_LOCKOUT_EXPIRATION_TIMESTAMP)); lockoutExpirationTimestampDelta.setValueToReplace(); focusContext.swallowToProjectionWaveSecondaryDelta(lockoutExpirationTimestampDelta);