Search in sources :

Example 21 with ItemDeltaType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) Document(org.w3c.dom.Document) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 22 with ItemDeltaType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) Collection(java.util.Collection) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) Map(java.util.Map) HashMap(java.util.HashMap) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 23 with ItemDeltaType

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());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) Document(org.w3c.dom.Document) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 24 with ItemDeltaType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 25 with ItemDeltaType

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());
        }
    }
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Aggregations

ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)39 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)28 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)14 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)11 Test (org.testng.annotations.Test)11 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 QName (javax.xml.namespace.QName)8 Document (org.w3c.dom.Document)8 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)6 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)6 XNode (com.evolveum.midpoint.prism.xnode.XNode)4 ObjectModificationType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType)4 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)4 ResourceObjectShadowChangeDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType)4