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); } }
protected void assertUserProperty(PrismObject<UserType> user, QName propertyName, Object... expectedPropValues) { PrismProperty<Object> property = user.findProperty(ItemName.fromQName(propertyName)); assert property != null : "No property "+propertyName+" in "+user; PrismAsserts.assertPropertyValue(property, expectedPropValues); }
private <T> PrismProperty<T> findProperty(PrismObject<UserType> user, ItemPath path) { System.out.println("Path:"); System.out.println(path); // WHEN PrismProperty<T> property = user.findProperty(path); // THEN System.out.println("Found:"); System.out.println(property); return property; }
protected void assertIncompleteShadowPassword(PrismObject<ShadowType> shadow) { PrismProperty<PolyStringType> passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); assertNotNull("No password value property in "+shadow, passValProp); assertTrue("Password value property does not have 'incomplete' flag in "+shadow, passValProp.isIncomplete()); }
public static String getStageUri(Task task) { PrismObject<TaskType> taskType = task.getTaskPrismObject(); PrismProperty<String> stageType = taskType.findProperty(ItemPath.create(TaskType.F_STAGE, TaskStageType.F_STAGE)); if (stageType == null) { return ModelPublicConstants.RECONCILIATION_TASK_HANDLER_URI + "#execute"; } return stageType.getRealValue(); }
@Override protected void assertShadowPassword(PrismObject<ShadowType> shadow) { // CSV password is readable PrismProperty<PolyStringType> passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); assertNotNull("No password value property in "+shadow+": "+passValProp, passValProp); }
private void validateName(PrismObject object) throws SchemaException { PrismProperty name = object.findProperty(ObjectType.F_NAME); if (name == null || ((PolyString) name.getRealValue()).isEmpty()) { throw new SchemaException("Attempt to add object without name."); } }
@Override protected void assertShadowPassword(PrismObject<ShadowType> shadow) { // CSV password is readable PrismProperty<PolyStringType> passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); assertNotNull("No password value property in "+shadow+": "+passValProp, passValProp); }
public ObjectTreeDeltas retrieveResultingDeltas(Task task) throws SchemaException { PrismProperty<ObjectTreeDeltasType> deltaTypePrismProperty = task.getTaskPrismObject().findProperty(ItemPath.create(F_WORKFLOW_CONTEXT, F_PROCESSOR_SPECIFIC_STATE, F_RESULTING_DELTAS)); if (deltaTypePrismProperty == null) { return null; } return ObjectTreeDeltas.fromObjectTreeDeltasType(deltaTypePrismProperty.getRealValue(), prismContext); }
protected void assertPolyStringProperty(QName propName, String expectedOrig) { PrismProperty<PolyString> prop = getObject().findProperty(ItemName.fromQName(propName)); assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); PrismAsserts.assertEqualsPolyString("Wrong "+propName.getLocalPart()+" in "+desc(), expectedOrig, prop.getRealValue()); }
protected void assertPolyStringPropertyMulti(QName propName, String... expectedOrigs) { PrismProperty<PolyString> prop = getObject().findProperty(ItemName.fromQName(propName)); assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); PrismAsserts.assertEqualsPolyStringMulti("Wrong "+propName.getLocalPart()+" in "+desc(), prop.getRealValues(), expectedOrigs); }
@Test public void test100FindNameProperty() throws Exception { System.out.println("===[ test100FindNameProperty ]==="); PrismObject<UserType> jack = getJack(); measure("findProperty(name)", () -> jack.findProperty(UserType.F_NAME)); }
protected <T> void assertPropertyEquals(QName propName, T expected) { PrismProperty<T> prop = getObject().findProperty(ItemName.fromQName(propName)); if (prop == null && expected == null) { return; } assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); T realValue = prop.getRealValue(); assertNotNull("No value in "+propName.getLocalPart()+" in "+desc(), realValue); assertEquals("Wrong "+propName.getLocalPart()+" in "+desc(), expected, realValue); }
@Test public void test120FindExtensionProperty() throws Exception { System.out.println("===[ test120FindExtensionProperty ]==="); PrismObject<UserType> jack = getJack(); ItemPath bar23 = ItemPath.create(UserType.F_EXTENSION, "bar23"); measure("findProperty(extension/bar23)", () -> jack.findProperty(bar23)); }
public ObjectTreeDeltas retrieveDeltasToProcess(Task task) throws SchemaException { PrismProperty<ObjectTreeDeltasType> deltaTypePrismProperty = task.getTaskPrismObject().findProperty(ItemPath.create(F_WORKFLOW_CONTEXT, F_PROCESSOR_SPECIFIC_STATE, F_DELTAS_TO_PROCESS)); if (deltaTypePrismProperty == null) { throw new SchemaException("No deltas to process in task extension; task = " + task); } return ObjectTreeDeltas.fromObjectTreeDeltasType(deltaTypePrismProperty.getRealValue(), prismContext); }
public static void deleteSchema(PrismObject<ResourceType> resource, ModelService modelService, PrismContext prismContext, Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismProperty<SchemaDefinitionType> definition = resource.findProperty(SCHEMA_PATH); if (definition != null && !definition.isEmpty()) { ObjectDelta<ResourceType> delta = prismContext.deltaFor(ResourceType.class) .item(SCHEMA_PATH).replace() .asObjectDelta(resource.getOid()); modelService.executeChanges(singleton(delta), null, task, parentResult); } } }
private <O extends ObjectType,T> void checkObjectProperty(PrismObject<O> object, QName propQName, OperationResult parentResult, T... expectedValues) { String propName = propQName.getLocalPart(); OperationResult result = parentResult.createSubresult(parentResult.getOperation() + ".checkObjectProperty." + propName); PrismProperty<T> prop = object.findProperty(ItemName.fromQName(propQName)); Collection<T> actualValues = prop.getRealValues(); result.addArbitraryObjectCollectionAsParam("actualValues", actualValues); assertMultivalue("User, property '"+propName+"'", expectedValues, actualValues, result); result.recordSuccessIfUnknown(); }
@Test public void test220SetExtensionItemString() throws Exception { System.out.println("===[ test220SetExtensionItemString ]==="); PrismObject<UserType> jack = getJack(); ItemPath bar23 = ItemPath.create(UserType.F_EXTENSION, "bar23"); measure("findProperty(extension/bar23).setRealValue", () -> { jack.findProperty(bar23).setRealValue("jack_" + Math.random()); return 1; }); }
@Test public void test210SetNameViaProperty() throws Exception { System.out.println("===[ test210SetNameViaProperty ]==="); PrismObject<UserType> jack = getJack(); measure("findProperty(name).setRealValue", () -> { jack.findProperty(UserType.F_NAME).setRealValue(PolyString.fromOrig("jack_" + Math.random())); return true; }); }
private <O extends ObjectType, T> void checkUserProperty(PrismObject<O> object, QName propQName, OperationResult parentResult, T... expectedValues) { String propName = propQName.getLocalPart(); OperationResult result = parentResult.createSubresult(parentResult.getOperation() + "." + propName); PrismProperty<T> prop = object.findProperty(ItemName.fromQName(propQName)); Collection<T> actualValues = prop.getRealValues(); result.addArbitraryObjectCollectionAsParam("actualValues", actualValues); assertMultivalue("User, property '" + propName + "'", expectedValues, actualValues, result); result.recordSuccessIfUnknown(); }