Search in sources :

Example 6 with SchemaHandlingType

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

the class ConsistencyTest method test124AddAccountDirectAlreadyExists.

//MID-1595, MID-1577
@Test
public void test124AddAccountDirectAlreadyExists() throws Exception {
    final String TEST_NAME = "test124AddAccountDirectAlreadyExists";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);
    Task task = taskManager.createTaskInstance();
    SchemaHandlingType oldSchemaHandling = resourceTypeOpenDjrepo.getSchemaHandling();
    SynchronizationType oldSynchronization = resourceTypeOpenDjrepo.getSynchronization();
    try {
        // we will reapply this schema handling after this test finish
        ItemDefinition syncDef = resourceTypeOpenDjrepo.asPrismObject().getDefinition().findItemDefinition(ResourceType.F_SYNCHRONIZATION);
        assertNotNull("null definition for sync delta", syncDef);
        ObjectDeltaType omt = unmarshallValueFromFile(REQUEST_RESOURCE_MODIFY_SYNCHRONIZATION, ObjectDeltaType.class);
        ObjectDelta objectDelta = DeltaConvertor.createObjectDelta(omt, prismContext);
        repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, objectDelta.getModifications(), parentResult);
        requestToExecuteChanges(REQUEST_RESOURCE_MODIFY_RESOURCE_SCHEMA, RESOURCE_OPENDJ_OID, ResourceType.class, task, null, parentResult);
        PrismObject<ResourceType> res = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, parentResult);
        // LOGGER.trace("resource schema handling after modify: {}",
        // prismContext.silentMarshalObject(res.asObjectable(), LOGGER));
        repoAddObjectFromFile(USER_ABOMBA_FILENAME, parentResult);
        requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, parentResult);
        String abombaOid = assertUserOneAccountRef(USER_ABOMBA_OID);
        ShadowType abombaShadow = repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult).asObjectable();
        assertShadowName(abombaShadow, "uid=abomba,OU=people,DC=example,DC=com");
        repoAddObjectFromFile(USER_ABOM_FILENAME, parentResult);
        requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOM_OID, UserType.class, task, null, parentResult);
        String abomOid = assertUserOneAccountRef(USER_ABOM_OID);
        ShadowType abomShadow = repositoryService.getObject(ShadowType.class, abomOid, null, parentResult).asObjectable();
        assertShadowName(abomShadow, "uid=abomba1,OU=people,DC=example,DC=com");
        ReferenceDelta abombaDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, new PrismReferenceValue(abombaOid));
        ObjectDelta d = ObjectDelta.createModifyDelta(USER_ABOMBA_OID, abombaDeleteAccDelta, UserType.class, prismContext);
        modelService.executeChanges(MiscSchemaUtil.createCollection(d), null, task, parentResult);
        assertUserNoAccountRef(USER_ABOMBA_OID, parentResult);
        repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult);
        ReferenceDelta abomDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, abomShadow.asPrismObject());
        ObjectDelta d2 = ObjectDelta.createModifyDelta(USER_ABOM_OID, abomDeleteAccDelta, UserType.class, prismContext);
        modelService.executeChanges(MiscSchemaUtil.createCollection(d2), null, task, parentResult);
        assertUserNoAccountRef(USER_ABOM_OID, parentResult);
        try {
            repositoryService.getObject(ShadowType.class, abomOid, null, parentResult);
            fail("Expected that shadow abom does not exist, but it is");
        } catch (ObjectNotFoundException ex) {
        // this is expected
        } catch (Exception ex) {
            fail("Expected object not found exception but got " + ex);
        }
        LOGGER.info("starting second execution request for user abomba");
        OperationResult result = new OperationResult("Add account already exist result.");
        requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, result);
        String abombaOid2 = assertUserOneAccountRef(USER_ABOMBA_OID);
        ShadowType abombaShadow2 = repositoryService.getObject(ShadowType.class, abombaOid2, null, result).asObjectable();
        assertShadowName(abombaShadow2, "uid=abomba,OU=people,DC=example,DC=com");
        result.computeStatus();
        LOGGER.info("Displaying execute changes result");
        display(result);
        // return the previous changes of resource back
        Collection<? extends ItemDelta> schemaHandlingDelta = ContainerDelta.createModificationReplaceContainerCollection(ResourceType.F_SCHEMA_HANDLING, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSchemaHandling.asPrismContainerValue().clone());
        PropertyDelta syncDelta = PropertyDelta.createModificationReplaceProperty(ResourceType.F_SYNCHRONIZATION, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSynchronization);
        ((Collection) schemaHandlingDelta).add(syncDelta);
        repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, schemaHandlingDelta, parentResult);
    } catch (Exception ex) {
        LOGGER.info("error: " + ex.getMessage(), ex);
        throw ex;
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) JAXBException(javax.xml.bind.JAXBException) TaskManagerException(com.evolveum.midpoint.task.api.TaskManagerException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) SynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 7 with SchemaHandlingType

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

the class TestSanityLegacy method checkOpenDjSchemaHandling.

private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
    SchemaHandlingType schemaHandling = resource.getSchemaHandling();
    for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
        if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
            assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
        if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
            assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
    }
}
Also used : SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)

Aggregations

SchemaHandlingType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType)6 ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 CommonException (com.evolveum.midpoint.util.exception.CommonException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 IOException (java.io.IOException)2 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)1 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)1 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1