/** * Specifies whether to return specific items. It is used for optimizations. * Some requests only needs a subset of items therefore fetching them all is a waste * of resources. Other requests may need expensive data that are not normally returned by default. * <p> * If no retrieve option is set in the entire options set then it * means that the whole object with a default set of properties has to be * returned. This is equivalent to specifying DEFAULT retrieve root option. * <p> * If there is at least one retrieve option in the set then the following rules apply: * <ul> * <li>Items marked as INCLUDE will be returned.</li> * <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li> * <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li> * <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option) * behave in the same way as superitem. E.g. if a superitem is marked as * INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem). * <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li> * <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed. * This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap * but they will be most likely omitted from the result.</li> * </ul> */ public static GetOperationOptions createRetrieve() { return createRetrieve(RetrieveOption.INCLUDE); }
/** * Specifies whether to return specific items. It is used for optimizations. * Some requests only needs a subset of items therefore fetching them all is a waste * of resources. Other requests may need expensive data that are not normally returned by default. * <p> * If no retrieve option is set in the entire options set then it * means that the whole object with a default set of properties has to be * returned. This is equivalent to specifying DEFAULT retrieve root option. * <p> * If there is at least one retrieve option in the set then the following rules apply: * <ul> * <li>Items marked as INCLUDE will be returned.</li> * <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li> * <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li> * <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option) * behave in the same way as superitem. E.g. if a superitem is marked as * INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem). * <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li> * <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed. * This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap * but they will be most likely omitted from the result.</li> * </ul> */ public static GetOperationOptions createDontRetrieve() { return createRetrieve(RetrieveOption.EXCLUDE); }
private void applyAttributesToGet(LensProjectionContext projCtx, Collection<SelectorOptions<GetOperationOptions>> options) throws SchemaException { if ( !LensUtil.isPasswordReturnedByDefault(projCtx) && LensUtil.needsFullShadowForCredentialProcessing(projCtx)) { options.add(SelectorOptions.create(prismContext.toUniformPath(SchemaConstants.PATH_PASSWORD_VALUE), GetOperationOptions.createRetrieve())); } }
public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(List<String> options, List<String> include, List<String> exclude, DefinitionProcessingOption definitionProcessing, PrismContext prismContext) { if (CollectionUtils.isEmpty(options) && CollectionUtils.isEmpty(include) && CollectionUtils.isEmpty(exclude)) { if (definitionProcessing != null) { return SelectorOptions.createCollection(GetOperationOptions.createDefinitionProcessing(definitionProcessing)); } return null; } Collection<SelectorOptions<GetOperationOptions>> rv = new ArrayList<>(); GetOperationOptions rootOptions = fromRestOptions(options, definitionProcessing); if (rootOptions != null) { rv.add(SelectorOptions.create(rootOptions)); } for (ItemPath includePath : ItemPathCollectionsUtil.pathListFromStrings(include, prismContext)) { rv.add(SelectorOptions.create(prismContext.toUniformPath(includePath), GetOperationOptions.createRetrieve())); } for (ItemPath excludePath : ItemPathCollectionsUtil.pathListFromStrings(exclude, prismContext)) { rv.add(SelectorOptions.create(prismContext.toUniformPath(excludePath), GetOperationOptions.createDontRetrieve())); } // Do NOT set executionPhase here! return rv; }
private PrismObject<LookupTableType> getFullTable(String oid, OperationResult result) throws ObjectNotFoundException, SchemaException { SelectorOptions<GetOperationOptions> retrieve = SelectorOptions.create(prismContext.toUniformPath(F_ROW), GetOperationOptions.createRetrieve(INCLUDE)); return repositoryService.getObject(LookupTableType.class, oid, Arrays.asList(retrieve), result); }
private void checkTable(String tableOid, PrismObject<LookupTableType> expectedObject, OperationResult result) throws SchemaException, ObjectNotFoundException { SelectorOptions<GetOperationOptions> retrieve = SelectorOptions.create(prismContext.toUniformPath(F_ROW), GetOperationOptions.createRetrieve(INCLUDE)); PrismObject<LookupTableType> table = repositoryService.getObject(LookupTableType.class, tableOid, Arrays.asList(retrieve), result); expectedObject.setOid(tableOid); PrismAsserts.assertEquivalent("Table is not as expected", expectedObject, table); }
private void checkObject(String oid, PrismObject<OrgType> expected, boolean loadPhoto, OperationResult result) throws ObjectNotFoundException, SchemaException { Collection<SelectorOptions<GetOperationOptions>> options; if (loadPhoto) { options = Collections.singletonList( SelectorOptions.create(prismContext.toUniformPath(FocusType.F_JPEG_PHOTO), GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE))); } else { options = null; } PrismObject<OrgType> real = repositoryService.getObject(OrgType.class, oid, options, result); ObjectDelta<OrgType> delta = expected.diff(real); System.out.println("Expected object = \n" + expected.debugDump()); System.out.println("Real object in repo = \n" + real.debugDump()); System.out.println("Difference = \n" + delta.debugDump()); if (!delta.isEmpty()) { fail("Objects are not equal.\n*** Expected:\n" + expected.debugDump() + "\n*** Got:\n" + real.debugDump() + "\n*** Delta:\n" + delta.debugDump()); } }
private void checkObject(String oid, PrismObject<UserType> expected, boolean loadPhoto, OperationResult result) throws ObjectNotFoundException, SchemaException { Collection<SelectorOptions<GetOperationOptions>> options; if (loadPhoto) { options = Collections.singletonList( SelectorOptions.create(prismContext.toUniformPath(UserType.F_JPEG_PHOTO), GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE))); } else { options = null; } PrismObject<UserType> real = repositoryService.getObject(UserType.class, oid, options, result); ObjectDelta<UserType> delta = expected.diff(real); System.out.println("Expected object = \n" + expected.debugDump()); System.out.println("Real object in repo = \n" + real.debugDump()); System.out.println("Difference = \n" + delta.debugDump()); if (!delta.isEmpty()) { fail("Objects are not equal.\n*** Expected:\n" + expected.debugDump() + "\n*** Got:\n" + real.debugDump() + "\n*** Delta:\n" + delta.debugDump()); } }
SelectorOptions.createCollection(GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); object = cacheRepositoryService.getObject(focusContext.getObjectTypeClass(), focusOid, options, result);
@Override protected void afterFirstClockworkRun(Task rootTask, List<Task> subtasks, List<WorkItemType> workItems, OperationResult result) throws Exception { ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result); ObjectDelta realDelta0 = taskModelContext.getFocusContext().getPrimaryDelta(); assertTrue("Non-empty primary focus delta: " + realDelta0.debugDump(), realDelta0.isEmpty()); assertNoObject(employee); ExpectedTask expectedTask = new ExpectedTask(null, "Adding role \"" + employee.asObjectable().getName().getOrig() + "\""); ExpectedWorkItem expectedWorkItem = new ExpectedWorkItem(userEmployeeOwnerOid, null, expectedTask); assertWfContextAfterClockworkRun(rootTask, subtasks, workItems, result, null, Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem)); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(prismContext.path(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve()); Task opTask = taskManager.createTaskInstance(); TaskType subtask = modelService.getObject(TaskType.class, subtasks.get(0).getOid(), options, opTask, result).asObjectable(); WfContextType wfc = subtask.getWorkflowContext(); ItemApprovalProcessStateType processState = WfContextUtil.getItemApprovalProcessInfo(wfc); assertEquals("Wrong # of attached policy rules entries", 1, processState.getPolicyRules().getEntry().size()); SchemaAttachedPolicyRuleType attachedRule = processState.getPolicyRules().getEntry().get(0); assertEquals(1, attachedRule.getStageMin().intValue()); assertEquals(1, attachedRule.getStageMax().intValue()); assertEquals("Wrong # of attached triggers", 1, attachedRule.getRule().getTrigger().size()); EvaluatedPolicyRuleTriggerType trigger = attachedRule.getRule().getTrigger().get(0); assertEquals("Wrong constraintKind in trigger", PolicyConstraintKindType.OBJECT_MODIFICATION, trigger.getConstraintKind()); WorkItemType workItem = wfc.getWorkItem().get(0); assertEquals("Wrong # of additional information", 0, workItem.getAdditionalInformation().size()); }
/** * This test is disabled because id-based searching is not available yet (and it's unclear if it would be eventually necessary). */ @Test(enabled = false) public void test140LookupLanguagesGetByIdExisting() throws Exception { final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection( prismContext.path(LookupTableType.F_ROW, 1L), GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); PrismObject<LookupTableType> lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); // THEN displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); }
SelectorOptions.createCollection(prismContext.path(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve()); Task opTask = taskManager.createTaskInstance(); TaskType subtask = modelService.getObject(TaskType.class, subtasks.get(0).getOid(), options, opTask, result).asObjectable();
SelectorOptions.createCollection(prismContext.path(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve());
protected void assertWfContextAfterRootTaskFinishes(Task rootTask, List<Task> subtasks, OperationResult result, String... processNames) throws Exception { final Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(prismContext.path(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve()); Task opTask = taskManager.createTaskInstance(); TaskType rootTaskType = modelService.getObject(TaskType.class, rootTask.getOid(), options, opTask, result).asObjectable(); assertTrue("unexpected process instance id in root task", rootTaskType.getWorkflowContext() == null || rootTaskType.getWorkflowContext().getProcessInstanceId() == null); assertEquals("Wrong # of wf subtasks w.r.t processNames (" + Arrays.asList(processNames) + ")", processNames.length, subtasks.size()); int i = 0; for (Task subtask : subtasks) { TaskType subtaskType = modelService.getObject(TaskType.class, subtask.getOid(), options, opTask, result).asObjectable(); display("Subtask #"+(i+1)+": ", subtaskType); assertNull("Unexpected fetch result in wf subtask: " + subtask, subtaskType.getFetchResult()); WfContextType wfc = subtaskType.getWorkflowContext(); assertNotNull("Missing workflow context in wf subtask: " + subtask, wfc); assertNotNull("No process ID in wf subtask: " + subtask, wfc.getProcessInstanceId()); assertEquals("Wrong process ID name in subtask: " + subtask, processNames[i++], wfc.getProcessInstanceName()); assertNotNull("Missing process start time in subtask: " + subtask, wfc.getStartTimestamp()); assertNotNull("Missing process end time in subtask: " + subtask, wfc.getEndTimestamp()); assertEquals("Wrong outcome", SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE, wfc.getOutcome()); } }
protected void assertWfContextAfterClockworkRun(Task rootTask, List<Task> subtasks, OperationResult result, String... processNames) throws Exception { SelectorOptions.createCollection(prismContext.path(F_WORKFLOW_CONTEXT, F_WORK_ITEM), createRetrieve());