private static PrismObject<? extends ObjectType> getObject(ObjectReferenceType reference, ModelService modelService, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String oid = reference.getOid(); QName typeName = reference.getType() != null ? reference.getType() : ObjectType.COMPLEX_TYPE; Class<? extends ObjectType> typeClass = ObjectTypes.getObjectTypeClass(typeName); return modelService.getObject(typeClass, oid, createNoFetchCollection(), task, result); } }
/** * No fetch operation should NOT try to read the schema. * MID-3509 */ @Test public void test374ListResourcesNoFetch() throws Exception { final String TEST_NAME = "test374ListResourcesNoFetch"; rememberCounter(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); rememberCounter(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT); testListResources(TEST_NAME, NUMBER_OF_RESOURCES + 1, GetOperationOptions.createNoFetchCollection()); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); }
private void selectMatchingShadows(List<String> candidateShadowsOidList, PrismContainer<ShadowAssociationType> output, String resourceOid, ShadowKindType kind, String intent, QName assocName, ExpressionEvaluationContext params) throws SchemaException { S_AtomicFilterExit filter = prismContext.queryFor(ShadowType.class) .id(candidateShadowsOidList.toArray(new String[0])) .and().item(ShadowType.F_RESOURCE_REF).ref(resourceOid) .and().item(ShadowType.F_KIND).eq(kind); if (intent != null) { filter = filter.and().item(ShadowType.F_INTENT).eq(intent); } ObjectQuery query = filter.build(); ResultHandler<ShadowType> handler = (object, parentResult) -> { PrismContainerValue<ShadowAssociationType> newValue = output.createNewValue(); ShadowAssociationType shadowAssociationType = newValue.asContainerable(); shadowAssociationType.setName(assocName); toAssociation(object, shadowAssociationType); return true; }; try { objectResolver.searchIterative(ShadowType.class, query, createNoFetchCollection(), handler, params.getTask(), params.getResult()); } catch (CommonException e) { throw new SystemException("Couldn't search for relevant shadows: " + e.getMessage(), e); } }
/** * No fetch operation should NOT try to read the schema. * MID-3509 */ @Test public void test372GetUnaccessibleResourceNoFetch() throws Exception { final String TEST_NAME = "test372GetUnaccessibleResourceNoFetch"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); rememberCounter(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); rememberCounter(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT); // WHEN PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_UNACCESSIBLE_OID, GetOperationOptions.createNoFetchCollection(), task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); display("Resource after", resource); assertNotNull("No resource", resource); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); }
ResourceType resource; try { resource = getObject(ResourceType.class, resourceOid, GetOperationOptions.createNoFetchCollection()); } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
+ "." + TEST_NAME); Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.createNoFetchCollection();