use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method changeUserGivenName.
protected void changeUserGivenName(String oid, String newValue) throws FaultMessage {
Document doc = ModelClientUtil.getDocumnent();
ObjectDeltaType userDelta = new ObjectDeltaType();
userDelta.setOid(oid);
userDelta.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
userDelta.setChangeType(ChangeTypeType.MODIFY);
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(ModificationTypeType.REPLACE);
itemDelta.setPath(ModelClientUtil.createItemPathType("givenName"));
itemDelta.getValue().add(ModelClientUtil.createPolyStringType(newValue, doc));
userDelta.getItemDelta().add(itemDelta);
ObjectDeltaListType deltaList = new ObjectDeltaListType();
deltaList.getDelta().add(userDelta);
modelPort.executeChanges(deltaList, null);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method modifyObject.
// values: path -> value or collection of values
protected ObjectDeltaOperationType modifyObject(Class objectType, String oid, ModificationTypeType modType, Map<String, Object> values, ModelExecuteOptionsType optionsType, boolean assertSuccess) throws Exception {
System.out.println("Modifying " + objectType.getSimpleName() + " " + oid + " (values: " + values + ")");
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(objectType));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
for (Map.Entry<String, Object> entry : values.entrySet()) {
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(modType);
itemDelta.setPath(createNonDefaultItemPathType(entry.getKey()));
if (!(entry.getValue() instanceof Collection)) {
itemDelta.getValue().add(entry.getValue());
} else {
itemDelta.getValue().addAll((Collection) (entry.getValue()));
}
deltaType.getItemDelta().add(itemDelta);
}
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType odolist = modelPort.executeChanges(deltaListType, optionsType);
return assertExecuteChangesSuccess(odolist, deltaType, assertSuccess);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TestSanityLegacy method test502NotifyChangeModifyAccountPassword.
@Test
public void test502NotifyChangeModifyAccountPassword() throws Exception {
TestUtil.displayTestTile("test502NotifyChangeModifyAccountPassword");
OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
assertNotNull("User with the name angelika must exist.", userAngelika);
UserType user = userAngelika.asObjectable();
assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
String oid = user.getLinkRef().get(0).getOid();
// PrismObject<ShadowType> angelicaAcc = modelService.getObject(ShadowType.class, oid, null, taskManager.createTaskInstance(), parentResult);
// ShadowType angelicaShadowType = angelicaAcc.asObjectable();
String newPassword = "newPassword";
// ProtectedStringType decrypted= ModelClientUtil.createProtectedString(newPassword);
// protector.encrypt(decrypted);
// angelicaShadowType.getCredentials().getPassword().setValue(decrypted);
ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
ObjectDeltaType delta = new ObjectDeltaType();
delta.setChangeType(ChangeTypeType.MODIFY);
delta.setObjectType(ShadowType.COMPLEX_TYPE);
Document doc = DOMUtil.getDocument();
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
RawType passwordValue = new RawType(((PrismContextImpl) prismContext).getBeanMarshaller().marshall(ModelClientUtil.createProtectedString(newPassword)), prismContext);
passwordDelta.getValue().add(passwordValue);
// ItemDeltaType mod1 = new ItemDeltaType();
// mod1.setModificationType(ModificationTypeType.REPLACE);
// ModelClientUtil.createProtectedString(clearValue)
// XPathHolder xpath = new XPathHolder(SchemaConstants.PATH_PASSWORD);
// Element path = xpath.toElement(SchemaConstantsGenerated.NS_TYPES, "path");
// mod1.setPath(path);
// String newPassword = "newPassword";
// ItemDeltaType.Value value = new ItemDeltaType.Value();
// Document doc = DOMUtil.getDocument();
// Element el = DOMUtil.createElement(doc, SchemaConstantsGenerated.C_VALUE);
// Element passwdEl = DOMUtil.createElement(doc, new QName(SchemaConstants.NS_C, "clearValue"));
// passwdEl.setTextContent(newPassword);
// el.appendChild(passwdEl);
// value.getAny().add(el);
// mod1.setValue(value);
// delta.getModification().add(mod1);
delta.getItemDelta().add(passwordDelta);
delta.setOid(oid);
LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(passwordDelta));
LOGGER.info("delta: {}", DebugUtil.dump(passwordDelta));
changeDescription.setObjectDelta(delta);
changeDescription.setOldShadowOid(oid);
// changeDescription.setCurrentShadow(angelicaShadowType);
changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
TaskType task = modelWeb.notifyChange(changeDescription);
OperationResult result = OperationResult.createOperationResult(task.getResult());
display(result);
assertSuccess(result);
PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
assertPassword(userAngelikaAfterSync, newPassword);
// UserType userAfterSync = userAngelikaAfterSync.asObjectable();
// PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class Main method changeUserPassword.
private static void changeUserPassword(ModelPortType modelPort, String oid, String newPassword) throws FaultMessage {
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
passwordDelta.getValue().add(ModelClientUtil.createProtectedString(newPassword));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
deltaType.getItemDelta().add(passwordDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
modelPort.executeChanges(deltaListType, null);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class Main method modifyRoleModifyInducement.
private static void modifyRoleModifyInducement(ModelPortType modelPort, String roleOid) throws IOException, SAXException, FaultMessage {
ItemDeltaType inducementDelta = new ItemDeltaType();
inducementDelta.setModificationType(ModificationTypeType.ADD);
inducementDelta.setPath(ModelClientUtil.createItemPathType("inducement[3]/construction/attribute"));
inducementDelta.getValue().add(ModelClientUtil.parseElement("<value>\n" + " <ref xmlns:ri=\"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3\">ri:pager</ref>\n" + " <outbound>\n" + " <expression>\n" + " <value>00-000-001</value>\n" + " <value>00-000-003</value>\n" + " </expression>\n" + " </outbound>\n" + " </value>"));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(roleOid);
deltaType.getItemDelta().add(inducementDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, null);
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
}
}
}
Aggregations