@Override public GetOperationOptionsBuilder item(ItemPath path) { currentPaths = singleton(prismContext.toUniformPath(path)); return this; }
public Attribute findAttributePathOverride(ManagedType type, ItemPath pathOverride) { Map<UniformItemPath, Attribute> overrides = attributeNamePathOverrides.get(type); if (overrides == null) { return null; } return overrides.get(prismContext.toUniformPath(pathOverride)); } }
private UniformItemPath pathForItem(Object item) { if (item instanceof QName) { return prismContext.path((QName) item); } else if (item instanceof UniformItemPath) { return ((UniformItemPath) item); } else if (item instanceof ItemPath) { return prismContext.toUniformPath((ItemPath) item); } else { throw new IllegalArgumentException("item has to be QName or ItemPath but is " + item); } }
private static ObjectSelector selectorTypeToSelector(OptionObjectSelectorType selectorType, PrismContext prismContext) { if (selectorType == null) { return null; } return new ObjectSelector(prismContext.toUniformPath(selectorType.getPath())); }
protected ItemDeltaImpl(ItemPath itemPath, QName elementName, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.parentPath = prismContext.toUniformPath(itemPath); checkNoSpecialSymbols(parentPath); this.prismContext = prismContext; this.elementName = ItemName.fromQName(elementName); this.definition = itemDefinition; }
public static <T> PropertyDelta<T> createModificationDeleteProperty(ItemPath propertyPath, PrismPropertyDefinition propertyDefinition, T... propertyValues) { PrismContext prismContext = propertyDefinition.getPrismContext(); PropertyDelta<T> propertyDelta = new PropertyDeltaImpl<T>(prismContext.toUniformPath(propertyPath), propertyDefinition, prismContext); // hoping the prismContext is there Collection<PrismPropertyValue<T>> pValues = new ArrayList<>(propertyValues.length); for (T val: propertyValues) { pValues.add(new PrismPropertyValueImpl<>(val)); } propertyDelta.addValuesToDelete(pValues); return propertyDelta; }
@Override protected void extendOptions(Collection<SelectorOptions<GetOperationOptions>> options, boolean searchOnResource) { super.extendOptions(options, searchOnResource); // We do not need to worry about associations of associations here // (nested associations). Avoiding that will make the query faster. options.add(SelectorOptions.create(getPrismContext().toUniformPath(ShadowType.F_ASSOCIATION), GetOperationOptions.createDontRetrieve())); }
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())); } }
@Override public S_ConditionEntry item(ItemPath itemPath, ItemDefinition itemDefinition) { if (itemDefinition != null) { return R_AtomicFilter.create(getPrismContext().toUniformPath(itemPath), itemDefinition, this); } else { return item(itemPath); } }
@Override public S_ConditionEntry item(ItemPath itemPath) { ItemDefinition itemDefinition = resolveItemPath(getPrismContext().toUniformPath(itemPath), ItemDefinition.class); return item(itemPath, itemDefinition); }
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 ItemPath getPath(MapXNodeImpl clauseXMap, QName key) throws SchemaException { XNodeImpl xnode = clauseXMap.get(key); if (xnode == null) { return null; } if (!(xnode instanceof PrimitiveXNodeImpl<?>)) { throw new SchemaException("Expected that field "+key+" will be primitive, but it is "+xnode.getDesc()); } ItemPathType itemPathType = clauseXMap.getParsedPrimitiveValue(key, ItemPathType.COMPLEX_TYPE); return itemPathType != null ? prismContext.toUniformPath(itemPathType) : null; }
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 <T extends ObjectType> List<ObjectDelta<T>> extractDeltasToApprove(ObjectDelta<T> focusDelta, WfProcessSpecificationType processSpecification) throws SchemaException { List<ObjectDelta<T>> rv = new ArrayList<>(); if (focusDelta.isDelete() || processSpecification == null || processSpecification.getDeltaFrom().isEmpty()) { return takeWholeDelta(focusDelta, rv); } for (DeltaSourceSpecificationType sourceSpec : processSpecification.getDeltaFrom()) { if (sourceSpec == null || sourceSpec.getItem().isEmpty() && sourceSpec.getItemValue() == null) { return takeWholeDelta(focusDelta, rv); } else if (!sourceSpec.getItem().isEmpty()) { ObjectDelta.FactorOutResultSingle<T> out = focusDelta.factorOut(ItemPathType.toItemPathList(sourceSpec.getItem()), false); addIgnoreNull(rv, out.offspring); } else { assert sourceSpec.getItemValue() != null; ObjectDelta.FactorOutResultMulti<T> out = focusDelta.factorOutValues(prismContext.toUniformPath(sourceSpec.getItemValue()), false); rv.addAll(out.offsprings); } } return rv; }
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); }
throw new IllegalStateException("Item definition with null ref in " + contextDesc); ItemPathCollectionsUtil.putToMap(definitions, prismContext.toUniformPath(def.getRef()), def); // TODO check for incompatible overrides
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()); } }
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()); } }
@Test public void test111GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test111GetRoleResolveEntitlement"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolve(), prismContext.toUniformPath(UserType.F_LINK), prismContext.toUniformPath(ItemPath.create(UserType.F_LINK, ShadowType.F_RESOURCE)) ); // WHEN PrismObject<RoleType> role = modelService.getObject(RoleType.class, ROLE_PIRATE_OID, options, task, result); RoleType roleType = role.asObjectable(); assertLinks(role, 1); PrismReferenceValue linkRef = getSingleLinkRef(role); assertEquals("OID mismatch in linkRefValue", groupOid, linkRef.getOid()); assertNotNull("Missing account object in linkRefValue", linkRef.getObject()); ShadowType shadow = roleType.getLink().get(0); assertDummyGroupShadowModel(shadow.asPrismObject(), groupOid, GROUP_PIRATE_DUMMY_NAME); assertNotNull("Resource in account was not resolved", shadow.getResource()); result.computeStatus(); TestUtil.assertSuccess("getObject result", result); }
getOpts.setNoFetch(true); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(prismContext.toUniformPath(UserType.F_LINK), getOpts);