Search in sources :

Example 41 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getOidFromDeltaOperationList.

/**
     * Retrieves OID and OperationResult created by model Web Service from the returned list of ObjectDeltaOperations.
     *
     * @param operationListType result of the model web service executeChanges call
     * @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
     * @param operationResultHolder where the result will be put
     * @return OID if found
     *
     * PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
     *
     * TODO move to ModelClientUtil
     */
public static String getOidFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta, Holder<OperationResultType> operationResultTypeHolder) {
    Validate.notNull(operationListType);
    Validate.notNull(originalDelta);
    if (originalDelta.getChangeType() != ChangeTypeType.ADD) {
        throw new IllegalArgumentException("Original delta is not of ADD type");
    }
    if (originalDelta.getObjectToAdd() == null) {
        throw new IllegalArgumentException("Original delta contains no object-to-be-added");
    }
    for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
        ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
        if (objectDeltaType.getChangeType() == ChangeTypeType.ADD && objectDeltaType.getObjectToAdd() != null) {
            ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
            if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
                operationResultTypeHolder.value = operationType.getExecutionResult();
                return objectAdded.getOid();
            }
        }
    }
    return null;
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)

Example 42 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method modifyObject.

protected ObjectDeltaOperationType modifyObject(Class objectType, String oid, String path, ModificationTypeType modType, Object value, ModelExecuteOptionsType optionsType, boolean assertSuccess) throws Exception {
    System.out.println("Modifying " + objectType.getSimpleName() + " " + oid + " (path: " + path + ")");
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(objectType));
    deltaType.setChangeType(ChangeTypeType.MODIFY);
    deltaType.setOid(oid);
    if (path != null) {
        ItemDeltaType itemDelta = new ItemDeltaType();
        itemDelta.setModificationType(modType);
        itemDelta.setPath(createNonDefaultItemPathType(path));
        if (!(value instanceof Collection)) {
            itemDelta.getValue().add(value);
        } else {
            itemDelta.getValue().addAll((Collection) value);
        }
        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) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 43 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getConfiguration.

protected SystemConfigurationType getConfiguration() throws FaultMessage {
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    modelPort.getObject(ModelClientUtil.getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, objectHolder, resultHolder);
    return (SystemConfigurationType) objectHolder.value;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 44 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class AbstractAdLdapTest method test390ModifyUserBarbossaRename.

@Test
public void test390ModifyUserBarbossaRename() throws Exception {
    final String TEST_NAME = "test390ModifyUserBarbossaRename";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, UserType.F_NAME, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_USERNAME));
    objectDelta.addModificationReplaceProperty(UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_FULL_NAME));
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapAccount(USER_CPTBARBOSSA_USERNAME, USER_CPTBARBOSSA_FULL_NAME);
    assertAttribute(entry, "title", "Captain");
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
    PrismObject<ShadowType> shadow = getObject(ShadowType.class, shadowOid);
    display("Shadow after rename (model)", shadow);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result);
    display("Shadow after rename (repo)", repoShadow);
    assertNoLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    assertLdapConnectorInstances(2);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Example 45 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class AbstractAdLdapMultidomainTest method test690ModifyUserSubmanRename.

@Test
public void test690ModifyUserSubmanRename() throws Exception {
    final String TEST_NAME = "test690ModifyUserSubmanRename";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_SUBMAN_OID, UserType.F_NAME, PrismTestUtil.createPolyString(USER_SUBDOG_USERNAME));
    objectDelta.addModificationReplaceProperty(UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_SUBDOG_FULL_NAME));
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertLdapSubAccount(USER_SUBDOG_USERNAME, USER_SUBDOG_FULL_NAME);
    assertAttribute(entry, "title", "Underdog");
    PrismObject<UserType> user = getUser(USER_SUBMAN_OID);
    String shadowOid = getSingleLinkOid(user);
    assertEquals("Shadows have moved", accountSubmanOid, shadowOid);
    PrismObject<ShadowType> shadow = getObject(ShadowType.class, shadowOid);
    display("Shadow after rename (model)", shadow);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result);
    display("Shadow after rename (repo)", repoShadow);
    assertNoLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME);
//        assertLdapConnectorInstances(2);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)297 Test (org.testng.annotations.Test)264 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)253 Task (com.evolveum.midpoint.task.api.Task)252 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)223 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)155 ArrayList (java.util.ArrayList)123 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)100 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)58 Holder (javax.xml.ws.Holder)49 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)46 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)38 QName (javax.xml.namespace.QName)38 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)37 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)33 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32