Search in sources :

Example 71 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType in project midpoint by Evolveum.

the class DependencyProcessor method determineProjectionWaveDeprovision.

private <F extends ObjectType> LensProjectionContext determineProjectionWaveDeprovision(LensContext<F> context, LensProjectionContext projectionContext, ResourceObjectTypeDependencyType inDependency, List<ResourceObjectTypeDependencyType> depPath) throws PolicyViolationException {
    if (depPath == null) {
        depPath = new ArrayList<ResourceObjectTypeDependencyType>();
    }
    int determinedWave = 0;
    int determinedOrder = 0;
    // This needs to go in the reverse. We need to figure out who depends on us.
    for (DependencyAndSource ds : findReverseDependecies(context, projectionContext)) {
        LensProjectionContext dependencySourceContext = ds.sourceProjectionContext;
        ResourceObjectTypeDependencyType outDependency = ds.dependency;
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("DEP(rev): {}", outDependency);
        }
        if (inDependency != null && isHigerOrder(outDependency, inDependency)) {
            // otherwise we can end up in endless loop even for legal dependencies.
            continue;
        }
        checkForCircular(depPath, outDependency);
        depPath.add(outDependency);
        ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(outDependency, projectionContext.getResource().getOid(), projectionContext.getKind());
        dependencySourceContext = determineProjectionWave(context, dependencySourceContext, outDependency, depPath);
        if (dependencySourceContext.getWave() + 1 > determinedWave) {
            determinedWave = dependencySourceContext.getWave() + 1;
            if (outDependency.getOrder() == null) {
                determinedOrder = 0;
            } else {
                determinedOrder = outDependency.getOrder();
            }
        }
        depPath.remove(outDependency);
    }
    LensProjectionContext resultAccountContext = projectionContext;
    if (projectionContext.getWave() >= 0 && projectionContext.getWave() != determinedWave) {
        // therefore there is a circular dependency. Therefore we need to create another context to split it.
        if (!projectionContext.isDelete()) {
            resultAccountContext = createAnotherContext(context, projectionContext, determinedOrder);
        }
    }
    //			LOGGER.trace("Wave for {}: {}", resultAccountContext.getResourceAccountType(), wave);
    resultAccountContext.setWave(determinedWave);
    return resultAccountContext;
}
Also used : ResourceObjectTypeDependencyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDependencyType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 72 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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 73 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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 74 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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 75 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)321 Test (org.testng.annotations.Test)267 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)252 Task (com.evolveum.midpoint.task.api.Task)251 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)230 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)170 ArrayList (java.util.ArrayList)136 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)103 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)65 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)61 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)56 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)53 Holder (javax.xml.ws.Holder)51 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)50 QName (javax.xml.namespace.QName)46 PrismObject (com.evolveum.midpoint.prism.PrismObject)42 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)36 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)36 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)34