Search in sources :

Example 11 with ObjectSynchronizationType

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

the class TestCorrelationConfiramtionEvaluator method test005CorrelationMatchCaseInsensitive.

@Test
public void test005CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test005CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		ObjectQuery query = ObjectQuery.createObjectQuery(EqualsFilter.createEqual(null, userType.getDefinition().findItemDefinition(UserType.F_EMPLOYEE_NUMBER), "stringIgnoreCase", "ps1234"));
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setEmployeeNumber("JaCk");
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 12 with ObjectSynchronizationType

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

the class TestCorrelationConfiramtionEvaluator method test004CorrelationMatchCaseInsensitive.

@Test
public void test004CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test004CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 13 with ObjectSynchronizationType

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

the class AbstractSynchronizationStoryTest method assumeUserTemplate.

private void assumeUserTemplate(String templateOid, ResourceType resource, String syncConfigName, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
    SynchronizationType resourceSync = resource.getSynchronization();
    resourceSync.getObjectSynchronization().get(0).setObjectTemplateRef(ObjectTypeUtil.createObjectRef(templateOid, ObjectTypes.OBJECT_TEMPLATE));
    Collection<? extends ItemDelta> refDelta = PropertyDelta.createModificationReplacePropertyCollection(ResourceType.F_SYNCHRONIZATION, resource.asPrismObject().getDefinition(), resourceSync);
    repositoryService.modifyObject(ResourceType.class, resource.getOid(), refDelta, result);
    ResourceType res = repositoryService.getObject(ResourceType.class, resource.getOid(), null, result).asObjectable();
    assertNotNull(res);
    assertNotNull("Synchronization is not specified", res.getSynchronization());
    ObjectSynchronizationType ost = determineSynchronization(res, UserType.class, syncConfigName);
    assertNotNull("object sync type is not specified", ost);
    assertNotNull("user template not specified", ost.getObjectTemplateRef());
    assertEquals("Wrong user template in resource", templateOid, ost.getObjectTemplateRef().getOid());
}
Also used : ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) SynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationType)

Example 14 with ObjectSynchronizationType

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

the class ResourceDetailsTabPanel method createResourceConfigList.

private List<ResourceConfigurationDto> createResourceConfigList(ResourceType resource) {
    OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, parentPage.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resource.getOid()).build(), result, parentPage);
    List<ResourceConfigurationDto> configs = new ArrayList<>();
    if (resource.getSchemaHandling() == null) {
        return configs;
    }
    List<ResourceObjectTypeDefinitionType> objectTypes = resource.getSchemaHandling().getObjectType();
    if (objectTypes == null) {
        return configs;
    }
    try {
        for (ResourceObjectTypeDefinitionType objectType : objectTypes) {
            ObjectSynchronizationType obejctSynchronization = null;
            if (resource.getSynchronization() != null && resource.getSynchronization().getObjectSynchronization() != null) {
                obejctSynchronization = getSynchronizationFor(objectType, resource.getSynchronization().getObjectSynchronization(), resource.asPrismObject());
            }
            List<TaskType> syncTask = new ArrayList<>();
            if (obejctSynchronization != null) {
                syncTask = getTaskFor(tasks, obejctSynchronization, resource.asPrismObject());
            }
            ResourceConfigurationDto resourceConfig = new ResourceConfigurationDto(objectType, obejctSynchronization != null, syncTask);
            configs.add(resourceConfig);
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Could not determine resource configuration", ex);
    }
    return configs;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto)

Example 15 with ObjectSynchronizationType

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

the class SynchronizationServiceImpl method determineSituation.

/**
	 * XXX: in situation when one account belongs to two different idm users
	 * (repository returns only first user, method
	 * {@link com.evolveum.midpoint.model.api.ModelService#findShadowOwner(String, Task, OperationResult)}
	 * (String, com.evolveum.midpoint.schema.result.OperationResult)} ). It
	 * should be changed because otherwise we can't find
	 * {@link SynchronizationSituationType#DISPUTED} situation
	 */
private <F extends FocusType> SynchronizationSituation determineSituation(Class<F> focusType, ResourceObjectShadowChangeDescription change, ObjectSynchronizationType synchronizationPolicy, SystemConfigurationType configurationType, Task task, OperationResult result) {
    OperationResult subResult = result.createSubresult(CHECK_SITUATION);
    LOGGER.trace("Determining situation for resource object shadow.");
    SynchronizationSituation situation = null;
    try {
        String shadowOid = getOidFromChange(change);
        Validate.notEmpty(shadowOid, "Couldn't get resource object shadow oid from change.");
        PrismObject<F> owner = repositoryService.searchShadowOwner(shadowOid, SelectorOptions.createCollection(GetOperationOptions.createAllowNotFound()), subResult);
        if (owner != null) {
            F ownerType = owner.asObjectable();
            LOGGER.trace("Shadow OID {} does have owner: {}", shadowOid, ownerType.getName());
            SynchronizationSituationType state = null;
            switch(getModificationType(change)) {
                case ADD:
                case MODIFY:
                    // if user is found it means account/group is linked to
                    // resource
                    state = SynchronizationSituationType.LINKED;
                    break;
                case DELETE:
                    state = SynchronizationSituationType.DELETED;
            }
            situation = new SynchronizationSituation<>(ownerType, null, state);
        } else {
            LOGGER.trace("Resource object shadow doesn't have owner.");
            situation = determineSituationWithCorrelation(focusType, change, synchronizationPolicy, owner, configurationType, task, result);
        }
    } catch (Exception ex) {
        LOGGER.error("Error occurred during resource object shadow owner lookup.");
        throw new SystemException("Error occurred during resource object shadow owner lookup, reason: " + ex.getMessage(), ex);
    } finally {
        subResult.computeStatus();
    }
    return situation;
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) 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) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException)

Aggregations

SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 ObjectSynchronizationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType)9 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)5 SystemException (com.evolveum.midpoint.util.exception.SystemException)5 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)5 SynchronizationSituationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType)5 QName (javax.xml.namespace.QName)5 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)4 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ConditionalSearchFilterType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3