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");
}
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");
}
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());
}
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;
}
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;
}
Aggregations