/** * No not fetch any information from external sources, e.g. do not fetch account data from resource, * do not fetch resource schema, etc. * Such operation returns only the data stored in midPoint repository. */ public static Collection<SelectorOptions<GetOperationOptions>> createNoFetchCollection() { return SelectorOptions.createCollection(createNoFetch()); }
protected PrismObject<ShadowType> getShadowModelNoFetch(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return getShadowModel(accountOid, GetOperationOptions.createNoFetch(), true); }
public Collection<SelectorOptions<GetOperationOptions>> createGetOptions(SelectorQualifiedGetOptionsType optionsBean, boolean noFetch) { LOGGER.trace("optionsBean = {}, noFetch = {}", optionsBean, noFetch); Collection<SelectorOptions<GetOperationOptions>> rv = MiscSchemaUtil.optionsTypeToOptions(optionsBean, prismContext); 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; }
private ShadowType getProjection(ObjectReferenceType linkRef, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); return objectResolver.getObject(ShadowType.class, linkRef.getOid(), options, task, result); }
@Test public void test176SearchUidExactNoFetch() throws Exception { final String TEST_NAME = "test176SearchUidExactNoFetch"; displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); }
@Test public void test176SearchUidCaseNoFetch() throws Exception { final String TEST_NAME = "test176SearchUidCaseNoFetch"; TestUtil.displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, "wIlL", GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); }
protected <F extends FocusType> PrismReferenceValue getLinkRef(PrismObject<F> focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { F focusType = focus.asObjectable(); for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { String linkTargetOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); PrismObject<ShadowType> account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) { // This is noFetch. Therefore there is no fetchResult return linkRefType.asReferenceValue(); } } AssertJUnit.fail("Account for resource "+resourceOid+" not found in "+focus); return null; // Never reached. But compiler complains about missing return }
@Test public void test194SearchIcfNameRepoizedNoFetch() throws Exception { final String TEST_NAME = "test194SearchIcfNameRepoizedNoFetch"; displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, getWillRepoIcfName(), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); }
@Test public void test196SearchIcfNameExactNoFetch() throws Exception { final String TEST_NAME = "test196SearchIcfNameExactNoFetch"; displayTestTitle(TEST_NAME); testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); }
@Test public void test197SearchIcfNameAndUidExactNoFetch() throws Exception { final String TEST_NAME = "test197SearchIcfNameAndUidExactNoFetch"; displayTestTitle(TEST_NAME); testSeachIterativeAlternativeAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); }
private <F extends ObjectType, T extends ObjectType> PrismObject<T> deleteProvisioningObject( Class<T> objectTypeClass, String oid, LensContext<F> context, LensElementContext<T> objectContext, ProvisioningOperationOptions options, ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, ObjectAlreadyExistsException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { PrismObject<T> shadowToModify = null; OperationProvisioningScriptsType scripts = null; try { GetOperationOptions rootOpts = GetOperationOptions.createNoFetch(); rootOpts.setPointInTimeType(PointInTimeType.FUTURE); shadowToModify = provisioning.getObject(objectTypeClass, oid, SelectorOptions.createCollection(rootOpts), task, result); } catch (ObjectNotFoundException ex) { // this is almost OK, mute the error and try to delete account (it // will fail if something is wrong) result.muteLastSubresultError(); } if (ShadowType.class.isAssignableFrom(objectTypeClass)) { scripts = prepareScripts(shadowToModify, context, objectContext, ProvisioningOperationTypeType.DELETE, resource, task, result); } ModelImplUtils.setRequestee(task, context); PrismObject<T> objectAfterModification = provisioning.deleteObject(objectTypeClass, oid, options, scripts, task, result); ModelImplUtils.clearRequestee(task); return objectAfterModification; }
public ShadowType resolveTargetUnchecked(ShadowAssociationType association, OperationResult result) throws SchemaException, ObjectNotFoundException { if (association == null) { return null; } ObjectReferenceType shadowRef = association.getShadowRef(); if (shadowRef == null || shadowRef.getOid() == null) { throw new IllegalStateException("None or null-OID shadowRef in " + association); } PrismObject<ShadowType> shadow = shadowRef.asReferenceValue().getObject(); if (shadow == null) { Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection( GetOperationOptions.createNoFetch()); shadow = repositoryService.getObject(ShadowType.class, shadowRef.getOid(), options, result); shadowRef.asReferenceValue().setObject(shadow); } return shadow.asObjectable(); }
private PrismObject<? extends ObjectType> getObject(String oid, Class<? extends ObjectType> objectTypeClass, VisualizationContext context, Task task, OperationResult result) { PrismObject<? extends ObjectType> object = context.getCurrentObject(oid); if (object != null) { return object; } try { if (objectTypeClass == null) { LOGGER.warn("No object class for {}, using ObjectType", oid); objectTypeClass = ObjectType.class; } object = modelService.getObject(objectTypeClass, oid, createCollection(createNoFetch()), task, result); context.putObject(object); return object; } catch (ObjectNotFoundException e) { // Not a big problem: object does not exist (was already deleted or was not yet created). LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Object {} does not exist", e, oid); result.recordHandledError(e); return null; } catch (RuntimeException|SchemaException|ConfigurationException|CommunicationException|SecurityViolationException|ExpressionEvaluationException e) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't resolve object {}", e, oid); result.recordWarning("Couldn't resolve object " + oid + ": " + e.getMessage(), e); return null; } }
protected <F extends FocusType> String getLinkRefOid(PrismObject<F> focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { F focusType = focus.asObjectable(); for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { String linkTargetOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); PrismObject<ShadowType> account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); ShadowType shadowType = account.asObjectable(); if (kind != null && !kind.equals(shadowType.getKind())) { continue; } if (!MiscUtil.equals(intent, shadowType.getIntent())) { continue; } if (resourceOid.equals(shadowType.getResourceRef().getOid())) { // This is noFetch. Therefore there is no fetchResult return linkTargetOid; } } AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); return null; // Never reached. But compiler complains about missing return }
private PrismObject<ShadowType> getShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("getShadowNoFetch"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); return shadow; }
/** * Search with query that queries both the repository and the resource. * NoFetch. This should go OK. * MID-2822 */ @Test public void test196SearchOnAndOffResourceNoFetch() throws Exception { final String TEST_NAME = "test196SearchOnAndOffResourceNoFetch"; displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); ObjectQuery query = createOnOffQuery(); ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() { @Override public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) { AssertJUnit.fail("Handler called: "+object); return false; } }; // WHEN provisioningService.searchObjectsIterative(ShadowType.class, query, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), handler, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); }
protected ShadowAsserter<Void> assertShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertShadowProvisioning"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter<Void> asserter = ShadowAsserter.forShadow(shadow, "noFetch"); asserter .display(); return asserter; }
@Test public void test101GetAccountMurrayNoFetch() throws Exception { final String TEST_NAME = "test101GetAccountMurrayNoFetch"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_CSVFILE_OID, options, task, result); display("getObject account", account); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess("getObject result", result); // TODO: better asserts assertNotNull("Null resource", account); }
@Test public void test102GetAccountNoFetch() throws Exception { TestUtil.displayTestTitle(this, "test102GetAccountNoFetch"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test102GetAccountNoFetch"); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, accountJackOid, options , task, result); display("Account", account); display("Account def", account.getDefinition()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismContainer<Containerable> accountContainer = account.findContainer(ShadowType.F_ATTRIBUTES); display("Account attributes def", accountContainer.getDefinition()); display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition()); assertDummyAccountShadowRepo(account, accountJackOid, "jack"); assertSuccess("getObject result", result); assertSteadyResources(); }
@Test public void test102GetGroupNoFetch() throws Exception { final String TEST_NAME = "test102GetGroupNoFetch"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN PrismObject<ShadowType> shadow = modelService.getObject(ShadowType.class, groupOid, options , task, result); display("Account", shadow); display("Account def", shadow.getDefinition()); PrismContainer<Containerable> accountContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); display("Account attributes def", accountContainer.getDefinition()); display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition()); assertDummyGroupShadowRepo(shadow, groupOid, GROUP_PIRATE_DUMMY_NAME); result.computeStatus(); TestUtil.assertSuccess("getObject result", result); }