/** * Create an instance of {@link ObjectModificationType } * */ public ObjectModificationType createObjectModificationType() { return new ObjectModificationType(); }
/** * Creates a new {@code ObjectModificationType} instance by deeply copying a given {@code ObjectModificationType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public ObjectModificationType(final ObjectModificationType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'ObjectModificationType' from 'null'."); } // CBuiltinLeafInfo: java.lang.String this.oid = ((o.oid == null)?null:o.getOid()); // 'ItemDelta' collection. if (o.itemDelta!= null) { copyItemDelta(o.getItemDelta(), this.getItemDelta()); } }
public ObjectModificationType oid(String value) { setOid(value); return this; }
/** * Converts this delta to ObjectModificationType (XML). */ public static <T extends Objectable> ObjectModificationType toObjectModificationType(ObjectDelta<T> delta) throws SchemaException { if (delta.getChangeType() != ChangeType.MODIFY) { throw new IllegalStateException("Cannot produce ObjectModificationType from delta of type " + delta.getChangeType()); } ObjectModificationType modType = new ObjectModificationType(); modType.setOid(delta.getOid()); List<ItemDeltaType> propModTypes = modType.getItemDelta(); for (ItemDelta<?,?> propDelta : delta.getModifications()) { Collection<ItemDeltaType> propPropModTypes; try { propPropModTypes = toItemDeltaTypes(propDelta); } catch (SchemaException e) { throw new SchemaException(e.getMessage() + " in " + delta.toString(), e); } propModTypes.addAll(propPropModTypes); } return modType; }
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { String theOid; theOid = this.getOid(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "oid", theOid), currentHashCode, theOid); } { List<ItemDeltaType> theItemDelta; theItemDelta = (((this.itemDelta!= null)&&(!this.itemDelta.isEmpty()))?this.getItemDelta():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "itemDelta", theItemDelta), currentHashCode, theItemDelta); } return currentHashCode; }
ObjectModificationType modType = new ObjectModificationType(); modType.setOid(objectDelta.getOid()); for (ItemDelta<?,?> propDelta : objectDelta.getModifications()) { Collection<ItemDeltaType> propPropModTypes;
@Test public void test150ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext()); display("Object change",delta); try { provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result); AssertJUnit.fail("addObject succeeded unexpectedly"); } catch (ConfigurationException e) { // This is expected display("Expected exception", e); } result.computeStatus(); TestUtil.assertFailure(result); }
public ObjectModificationType itemDelta(ItemDeltaType value) { getItemDelta().add(value); return this; }
public int hashCode() { final HashCodeStrategy strategy = DomAwareHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); }
public boolean equals(Object object) { final EqualsStrategy strategy = DomAwareEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); }
@Test public void testAccountRefDelta() throws Exception { System.out.println("===[ testAccountRefDelta ]===="); // GIVEN ObjectModificationType objectChange = new ObjectModificationType(); objectChange.setOid("12345"); ItemDeltaType modificationDeleteAccountRef = new ItemDeltaType(); modificationDeleteAccountRef.setModificationType(ModificationTypeType.DELETE); ObjectReferenceType accountRefToDelete = new ObjectReferenceType(); accountRefToDelete.setOid("54321"); PrismContext prismContext = getPrismContext(); RawType modificationValue = new RawType(prismContext.xnodeSerializer().root(new QName("dummy")).serializeRealValue(accountRefToDelete).getSubnode(), prismContext); modificationDeleteAccountRef.getValue().add(modificationValue); objectChange.getItemDelta().add(modificationDeleteAccountRef); ItemPathType itemPathType = new ItemPathType(UserType.F_LINK_REF); modificationDeleteAccountRef.setPath(itemPathType); PrismObjectDefinition<UserType> objDef = PrismTestUtil.getObjectDefinition(UserType.class); // WHEN Collection<? extends ItemDelta> modifications = DeltaConvertor.toModifications(objectChange, objDef); // THEN assertNotNull("Null modifications", modifications); assertFalse("Empty modifications", modifications.isEmpty()); // TODO: more asserts }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof ObjectModificationType)) { return false; } if (this == object) { return true; } final ObjectModificationType that = ((ObjectModificationType) object); { String lhsOid; lhsOid = this.getOid(); String rhsOid; rhsOid = that.getOid(); if (!strategy.equals(LocatorUtils.property(thisLocator, "oid", lhsOid), LocatorUtils.property(thatLocator, "oid", rhsOid), lhsOid, rhsOid)) { return false; } } { List<ItemDeltaType> lhsItemDelta; lhsItemDelta = (((this.itemDelta!= null)&&(!this.itemDelta.isEmpty()))?this.getItemDelta():null); List<ItemDeltaType> rhsItemDelta; rhsItemDelta = (((that.itemDelta!= null)&&(!that.itemDelta.isEmpty()))?that.getItemDelta():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "itemDelta", lhsItemDelta), LocatorUtils.property(thatLocator, "itemDelta", rhsItemDelta), lhsItemDelta, rhsItemDelta)) { return false; } } return true; }
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); ShadowType repoShadow = getShadowRepo(objectChange.getOid()).asObjectable(); String name = ShadowUtil.getSingleStringAttributeValue(repoShadow, getSecondaryIdentifierQName()); assertEquals("After rename, dn is not equal.", "uid=rename,ou=people,dc=example,dc=com", name);
public static <T extends Objectable> Collection<? extends ItemDelta> toModifications(ObjectModificationType objectModification, PrismObjectDefinition<T> objDef) throws SchemaException { return toModifications(objectModification.getItemDelta(), objDef); }
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; }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public ObjectModificationType clone() { try { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final ObjectModificationType clone = ((ObjectModificationType) super.clone()); // CBuiltinLeafInfo: java.lang.String clone.oid = ((this.oid == null)?null:this.getOid()); // 'ItemDelta' collection. if (this.itemDelta!= null) { clone.itemDelta = null; copyItemDelta(this.getItemDelta(), clone.getItemDelta()); } return clone; } } catch (CloneNotSupportedException e) { // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ throw new AssertionError(e); } }
/** * Create an instance of {@link ObjectModificationType } * */ public ObjectModificationType createObjectModificationType() { return new ObjectModificationType(); }
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result);
@Test(expectedExceptions = ObjectAlreadyExistsException.class) public void test010ModifyWithExistingName() throws Exception { final String TEST_NAME = "test010ModifyWithExistingName"; TestUtil.displayTestTitle(TEST_NAME); OperationResult result = new OperationResult("MODIFY"); File userFile = new File(TEST_DIR, "modify-user.xml"); //add first user PrismObject<UserType> user = prismContext.parseObject(userFile); user.setOid(null); user.asObjectable().setName(PolyStringType.fromOrig("existingName")); repositoryService.addObject(user, null, result); //add second user user = prismContext.parseObject(userFile); user.setOid(null); user.asObjectable().setName(PolyStringType.fromOrig("otherName")); String oid = repositoryService.addObject(user, null, result); //modify second user name to "existingName" ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, "change-name.xml"), ObjectModificationType.COMPLEX_TYPE); modification.setOid(oid); Collection<? extends ItemDelta> deltas = DeltaConvertor.toModifications(modification, UserType.class, prismContext); repositoryService.modifyObject(UserType.class, oid, deltas, result); }
private void assertXmlPolyMod(ObjectModificationType objectModificationType, QName propertyName, ModificationTypeType modType, PolyStringType... expectedValues) throws SchemaException { //FIXME: for (ItemDeltaType mod : objectModificationType.getItemDelta()) { if (!propertyName.equals(mod.getPath().getItemPath().last())) { continue; } assertEquals(modType, mod.getModificationType()); for (RawType val : mod.getValue()){ assertModificationPolyStringValue(val, expectedValues); } } }