public static <T extends Objectable> ObjectDelta<T> createObjectDelta(ObjectDeltaType objectDeltaType, PrismContext prismContext) throws SchemaException { return createObjectDelta(objectDeltaType, prismContext, false); }
public static Collection<ObjectDelta> createObjectDeltas(ObjectDeltaListType deltaList, PrismContext prismContext) throws SchemaException { List<ObjectDelta> retval = new ArrayList<>(); for (ObjectDeltaType deltaType : deltaList.getDelta()) { retval.add(createObjectDelta(deltaType, prismContext)); } return retval; } }
public ObjectDelta getFocusPrimaryDelta(WfContextType workflowContext, boolean mayBeNull) throws JAXBException, SchemaException { ObjectDeltaType objectDeltaType = getFocusPrimaryObjectDeltaType(workflowContext, mayBeNull); return objectDeltaType != null ? DeltaConvertor.createObjectDelta(objectDeltaType, prismContext) : null; }
public static <T extends Objectable> ObjectDelta<T> createObjectDelta(ObjectModificationType objectModification, Class<T> type, PrismContext prismContext) throws SchemaException { Validate.notNull(prismContext, "No prismContext in DeltaConvertor.createObjectDelta call"); PrismObjectDefinition<T> objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(type); if (objectDefinition == null) { throw new SchemaException("No object definition for class "+type); } return createObjectDelta(objectModification, objectDefinition); }
private <T extends ObjectType> ObjectDelta<T> createDeltaFromTask(Task task) throws SchemaException { PrismProperty<ObjectDeltaType> objectDeltaType = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA); if (objectDeltaType != null && objectDeltaType.getRealValue() != null) { return DeltaConvertor.createObjectDelta(objectDeltaType.getRealValue(), prismContext); } else { return null; } }
private ObjectDelta<UserType> parseDelta(String filename) throws JAXBException, SchemaException, IOException { ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(new File(filename), ObjectModificationType.COMPLEX_TYPE); return DeltaConvertor.createObjectDelta(modElement, UserType.class, prismContext); }
public static ObjectTreeDeltas fromObjectTreeDeltasType(ObjectTreeDeltasType deltasType, PrismContext prismContext) throws SchemaException { Validate.notNull(prismContext, "prismContext"); if (deltasType == null) { return null; } ObjectTreeDeltas deltas = new ObjectTreeDeltas(prismContext); if (deltasType.getFocusPrimaryDelta() != null) { deltas.setFocusChange(DeltaConvertor.createObjectDelta(deltasType.getFocusPrimaryDelta(), prismContext)); } for (ProjectionObjectDeltaType projectionObjectDeltaType : deltasType.getProjectionPrimaryDelta()) { ResourceShadowDiscriminator rsd = ResourceShadowDiscriminator.fromResourceShadowDiscriminatorType( projectionObjectDeltaType.getResourceShadowDiscriminator()); ObjectDelta objectDelta = DeltaConvertor.createObjectDelta(projectionObjectDeltaType.getPrimaryDelta(), prismContext); deltas.addProjectionChange(rsd, objectDelta); } return deltas; }
protected ObjectDelta<UserType> parseDelta(String oid, File file) throws SchemaException, IOException { ObjectModificationType modification = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<UserType> delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); delta.setOid(oid); return delta; }
protected ObjectDelta<OrgType> parseDelta(String oid, File file) throws SchemaException, IOException { ObjectModificationType modification = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext); delta.setOid(oid); return delta; }
@Test public void test070ModifyBigUser() throws Exception { ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t004.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); repositoryService.modifyObject(UserType.class, userBigOid, delta.getModifications(), new OperationResult("asdf")); }
protected <O extends ObjectType> ObjectDelta<O> addFocusModificationToContext( LensContext<O> context, File file) throws JAXBException, SchemaException, IOException { ObjectModificationType modElement = PrismTestUtil.parseAtomicValue( file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<O> focusDelta = DeltaConvertor.createObjectDelta( modElement, context.getFocusClass(), prismContext); return addFocusDeltaToContext(context, focusDelta); }
@Test public void test030ModifyShadow() throws Exception { ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t003.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext); delta.setOid(userOid); repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), new OperationResult("asdf")); }
@SuppressWarnings("unchecked") public static <T extends ObjectType> T patchXml(ObjectModificationType changes, T object, Class<T> clazz) throws SchemaException { ObjectDelta<T> objectDelta = DeltaConvertor.createObjectDelta(changes, clazz, PrismTestUtil.getPrismContext()); objectDelta.applyTo((PrismObject<T>) object.asPrismObject()); return object; }
private PendingOperationType findExistingPendingOperation(PrismObject<ShadowType> currentShadow, ObjectDelta<ShadowType> proposedDelta, boolean processInProgress) throws SchemaException { for (PendingOperationType pendingOperation: currentShadow.asObjectable().getPendingOperation()) { OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); if (!isInProgressOrRequested(resultStatus, processInProgress)) { continue; } ObjectDeltaType deltaType = pendingOperation.getDelta(); if (deltaType == null) { continue; } ObjectDelta<Objectable> delta = DeltaConvertor.createObjectDelta(deltaType, prismContext); if (!matchPendingDelta(delta, proposedDelta)) { continue; } return pendingOperation; } return null; }
private void roundTrip(ObjectDelta delta) throws Exception { ObjectDeltaType deltaType = DeltaConvertor.toObjectDeltaType(delta); System.out.println("Serialized to bean"); System.out.println(deltaType); String xml = getPrismContext().xmlSerializer().serializeRealValue(deltaType, new QName("aDelta")); System.out.println("Serialized to XML"); System.out.println(xml); ObjectDeltaType deltaTypeParsed = getPrismContext().parserFor(xml).parseRealValue(); System.out.println("Parsed from XML to bean"); System.out.println(deltaTypeParsed); ObjectDelta deltaParsed = DeltaConvertor.createObjectDelta(deltaTypeParsed, getPrismContext()); System.out.println("Parsed from XML to bean to delta"); System.out.println(deltaParsed); assertTrue("Deltas (native) do not match", delta.equivalent(deltaParsed)); // note: comparing beans is problematic because e.g. item paths are not equal ({common-3}name vs {c=common-3}c:name) } }
<O extends ObjectType> ObjectDelta<O> encryptAndAddFocusModificationToContext( LensContext<O> context, File file) throws JAXBException, SchemaException, IOException { ObjectModificationType modElement = PrismTestUtil.parseAtomicValue( file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<O> focusDelta = DeltaConvertor.createObjectDelta( modElement, context.getFocusClass(), prismContext); ModelImplUtils.encrypt((Collection) Arrays.asList(focusDelta), protector, null, new OperationResult("dummy")); return addFocusDeltaToContext(context, focusDelta); } }
@Override public LensContext createModelContext(Task task, OperationResult result) throws Exception { LensContext<UserType> context = createUserLensContext(); fillContextWithUser(context, USER_JACK_OID, result); UserType jack = context.getFocusContext().getObjectCurrent().asObjectable(); AssertJUnit.assertEquals("Jack has wrong number of accounts", 1, jack.getLinkRef().size()); jackAccountShadowOid = jack.getLinkRef().get(0).getOid(); LensProjectionContext accountContext = fillContextWithAccount(context, jackAccountShadowOid, task, result); ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(REQ_SHADOW_MODIFY_ADD_ENTITLEMENT_TESTERS, ObjectModificationType.COMPLEX_TYPE); ObjectDelta shadowDelta = DeltaConvertor.createObjectDelta(modElement, ShadowType.class, prismContext); shadowDelta.setOid(jackAccountShadowOid); accountContext.setPrimaryDelta(shadowDelta); return context; }
@Override public LensContext createModelContext(Task task, OperationResult result) throws Exception { LensContext<UserType> context = createUserLensContext(); fillContextWithUser(context, USER_ELISABETH_OID, result); UserType elisabeth = context.getFocusContext().getObjectCurrent().asObjectable(); AssertJUnit.assertEquals("Elisabeth has wrong number of accounts", 1, elisabeth.getLinkRef().size()); elisabethAccountShadowOid = elisabeth.getLinkRef().get(0).getOid(); LensProjectionContext accountContext = fillContextWithAccount(context, elisabethAccountShadowOid, task, result); ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(REQ_SHADOW_MODIFY_ADD_ENTITLEMENT_TESTERS, ObjectModificationType.COMPLEX_TYPE); ObjectDelta shadowDelta = DeltaConvertor.createObjectDelta(modElement, ShadowType.class, prismContext); shadowDelta.setOid(elisabethAccountShadowOid); accountContext.setPrimaryDelta(shadowDelta); return context; }
@Test public void test105ApplyDefinitionModifyDelta() throws Exception { final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectModificationType changeAddRoleCaptain = PrismTestUtil.parseAtomicValue(MODIFY_ACCOUNT_FILE, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<ShadowType> accountDelta = DeltaConvertor.createObjectDelta(changeAddRoleCaptain, ShadowType.class, prismContext); // WHEN provisioningService.applyDefinition(accountDelta, task, result); // THEN assertSuccess(result); accountDelta.checkConsistence(true, true, true); assertSteadyResource(); }
public static ObjectDeltaOperation createObjectDeltaOperation(ObjectDeltaOperationType objectDeltaOperationType, PrismContext prismContext) throws SchemaException { ObjectDeltaOperation retval = new ObjectDeltaOperation(createObjectDelta(objectDeltaOperationType.getObjectDelta(), prismContext)); if (objectDeltaOperationType.getExecutionResult() != null) { retval.setExecutionResult(OperationResult.createOperationResult(objectDeltaOperationType.getExecutionResult())); } if (objectDeltaOperationType.getObjectName() != null) { retval.setObjectName(objectDeltaOperationType.getObjectName().toPolyString()); } retval.setResourceOid(objectDeltaOperationType.getResourceOid()); if (objectDeltaOperationType.getResourceName() != null) { retval.setObjectName(objectDeltaOperationType.getResourceName().toPolyString()); } return retval; }