use of com.evolveum.midpoint.schema.GetOperationOptions in project midpoint by Evolveum.
the class ProvisioningServiceImpl method searchObjects.
@Override
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".searchObjects");
result.addParam("objectType", type);
result.addParam("query", query);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
final SearchResultList<PrismObject<T>> objListType = new SearchResultList<>(new ArrayList<PrismObject<T>>());
SearchResultMetadata metadata;
try {
if (!ShadowType.class.isAssignableFrom(type)) {
SearchResultList<PrismObject<T>> objects = searchRepoObjects(type, query, options, task, result);
result.computeStatus();
result.recordSuccessIfUnknown();
result.cleanupResult();
// validateObjects(objects);
return objects;
}
final ResultHandler<T> handler = (object, parentResult1) -> objListType.add(object);
metadata = searchObjectsIterative(type, query, options, handler, task, result);
} catch (ConfigurationException | SecurityViolationException | CommunicationException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Could not search objects: " + e.getMessage(), e);
throw e;
}
result.computeStatus();
result.cleanupResult();
// validateObjects(objListType);
objListType.setMetadata(metadata);
return objListType;
}
use of com.evolveum.midpoint.schema.GetOperationOptions in project midpoint by Evolveum.
the class OperationsHelper method createGetOptions.
public Collection<SelectorOptions<GetOperationOptions>> createGetOptions(SelectorQualifiedGetOptionsType optionsBean, boolean noFetch) {
LOGGER.trace("optionsBean = {}, noFetch = {}", optionsBean, noFetch);
Collection<SelectorOptions<GetOperationOptions>> rv = MiscSchemaUtil.optionsTypeToOptions(optionsBean);
if (noFetch) {
if (rv == null) {
return SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
}
GetOperationOptions root = SelectorOptions.findRootOptions(rv);
if (root != null) {
root.setNoFetch(true);
} else {
rv.add(SelectorOptions.create(GetOperationOptions.createNoFetch()));
}
}
return rv;
}
use of com.evolveum.midpoint.schema.GetOperationOptions in project midpoint by Evolveum.
the class TestResources method test107SearchResourcesIterativeNoFetchReadOnly.
/**
* MID-3424
*/
@Test
public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception {
final String TEST_NAME = "test107SearchResourcesIterativeNoFetchReadOnly";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
// precondition
assertSteadyResources();
rememberPrismObjectCloneCount();
final List<PrismObject<ResourceType>> resources = new ArrayList<PrismObject<ResourceType>>();
ResultHandler<ResourceType> handler = (resource, parentResult) -> {
assertResource(resource, false);
resources.add(resource);
return true;
};
GetOperationOptions option = GetOperationOptions.createNoFetch();
option.setReadOnly(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(option);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("searchObjects result", result);
assertFalse("Empty search return", resources.isEmpty());
assertEquals("Unexpected number of resources found", 2, resources.size());
assertPrismObjectCloneIncrement(2);
assertResourceSchemaFetchIncrement(0);
assertResourceSchemaParseCountIncrement(0);
assertConnectorCapabilitiesFetchIncrement(0);
assertConnectorInitializationCountIncrement(0);
assertConnectorSchemaParseIncrement(0);
assertSteadyResources();
}
use of com.evolveum.midpoint.schema.GetOperationOptions in project midpoint by Evolveum.
the class TestResources method test105SearchResourcesIterativeNoFetch.
/**
* MID-3424
*/
@Test
public void test105SearchResourcesIterativeNoFetch() throws Exception {
final String TEST_NAME = "test105SearchResourcesIterativeNoFetch";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
// precondition
assertSteadyResources();
rememberPrismObjectCloneCount();
final List<PrismObject<ResourceType>> resources = new ArrayList<PrismObject<ResourceType>>();
ResultHandler<ResourceType> handler = (resource, parentResult) -> {
assertResource(resource, false);
resources.add(resource);
return true;
};
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("searchObjects result", result);
assertFalse("Empty search return", resources.isEmpty());
assertEquals("Unexpected number of resources found", 2, resources.size());
assertPrismObjectCloneIncrement(2);
assertResourceSchemaFetchIncrement(0);
assertResourceSchemaParseCountIncrement(0);
assertConnectorCapabilitiesFetchIncrement(0);
assertConnectorInitializationCountIncrement(0);
assertConnectorSchemaParseIncrement(0);
assertSteadyResources();
}
use of com.evolveum.midpoint.schema.GetOperationOptions in project midpoint by Evolveum.
the class TestResources method test102SearchResourcesNoFetchReadOnly.
/**
* MID-3424
*/
@Test
public void test102SearchResourcesNoFetchReadOnly() throws Exception {
final String TEST_NAME = "test102SearchResourcesNoFetchReadOnly";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
// precondition
assertSteadyResources();
rememberPrismObjectCloneCount();
GetOperationOptions option = GetOperationOptions.createNoFetch();
option.setReadOnly(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(option);
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ResourceType>> resources = modelService.searchObjects(ResourceType.class, null, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertNotNull("null search return", resources);
assertFalse("Empty search return", resources.isEmpty());
assertEquals("Unexpected number of resources found", 2, resources.size());
result.computeStatus();
TestUtil.assertSuccess("searchObjects result", result);
assertPrismObjectCloneIncrement(0);
for (PrismObject<ResourceType> resource : resources) {
assertResource(resource, false);
}
assertResourceSchemaFetchIncrement(0);
assertResourceSchemaParseCountIncrement(0);
assertConnectorCapabilitiesFetchIncrement(0);
assertConnectorInitializationCountIncrement(0);
assertConnectorSchemaParseIncrement(0);
assertSteadyResources();
}
Aggregations