private boolean isObjectExtensionDelta(ItemPath path) { return path.startsWithName(ObjectType.F_EXTENSION); }
private boolean isShadowAttributesDelta(ItemPath path) { return path.startsWithName(ShadowType.F_ATTRIBUTES); }
private static <O extends ObjectType> boolean isItemLoadable(PrismObject<O> object, ItemPath path) { if (!(object.asObjectable() instanceof ShadowType)) { return false; } return path.startsWithName(ShadowType.F_ATTRIBUTES) || path.startsWithName(ShadowType.F_ASSOCIATION); }
public static boolean matchesAttribute(ItemPath path, QName attributeName) { return path.startsWithName(ShadowType.F_ATTRIBUTES) && path.rest().startsWithName(attributeName); }
@NotNull private ItemPath skipFirstId(@NotNull ItemPath path) { if (path.startsWithName()) { return path; } else if (path.startsWithId()) { return path.rest(); } else { throw new IllegalArgumentException("Unexpected path segment in "+path); } }
@Override public <ID extends ItemDefinition> ID findItemDefinition(@NotNull ItemPath path, @NotNull Class<ID> clazz) { if (path.size() == 1 && path.startsWithName()) { return findLocalItemDefinition(ItemPath.toName(path.first()), clazz, false); } throw new UnsupportedOperationException("TODO implement if needed"); }
<I extends Item<?,?>> void removeItem(ItemPath itemPath, Class<I> itemType) { checkMutability(); if (items == null) { return; } if (!itemPath.startsWithName()) { throw new IllegalArgumentException("Attempt to remove item using a non-name path "+itemPath+" in "+this); } QName subName = itemPath.firstToName(); ItemPath rest = itemPath.rest(); Iterator<Item<?,?>> itemsIterator = items.iterator(); while(itemsIterator.hasNext()) { Item<?,?> item = itemsIterator.next(); if (subName.equals(item.getElementName())) { if (!rest.isEmpty() && item instanceof PrismContainer) { ((PrismContainer) item).removeItem(rest, itemType); return; } else { if (itemType.isAssignableFrom(item.getClass())) { itemsIterator.remove(); } else { throw new IllegalArgumentException("Attempt to remove item "+subName+" from "+this+ " of type "+itemType+" while the existing item is of incompatible type "+item.getClass()); } } } } }
private ObjectQuery narrowQueryForBucket(ObjectQuery query, Task localCoordinatorTask, WorkBucketType workBucket, ObjectClassComplexTypeDefinition objectclassDef, OperationResult opResult) throws SchemaException, ObjectNotFoundException { return taskManager.narrowQueryForWorkBucket(query, ShadowType.class, itemPath -> { if (itemPath.startsWithName(ShadowType.F_ATTRIBUTES)) { return objectclassDef.findAttributeDefinition(itemPath.rest().asSingleName()); } else { return null; } }, localCoordinatorTask, workBucket, opResult); }
@Override public void modifyExtension(ItemDelta itemDelta) throws SchemaException { if (ItemPath.isEmpty(itemDelta.getPath()) || !itemDelta.getPath().startsWithName(TaskType.F_EXTENSION)) { throw new IllegalArgumentException( "modifyExtension must modify the Task extension element; however, the path is " + itemDelta.getPath()); } processModificationBatched(modifyExtensionAndPrepareDelta(itemDelta)); }
public <T> void normalizeDelta(ItemDelta<PrismPropertyValue<T>,PrismPropertyDefinition<T>> delta, RefinedObjectClassDefinition objectClassDefinition) throws SchemaException { if (!delta.getPath().startsWithName(ShadowType.F_ATTRIBUTES)) { return; } RefinedAttributeDefinition rAttrDef = objectClassDefinition.findAttributeDefinition(delta.getElementName()); if (rAttrDef == null){ throw new SchemaException("Failed to normalize attribute: " + delta.getElementName()+ ". Definition for this attribute doesn't exist."); } normalizeDelta(delta, rAttrDef); }
public static ResourceAttribute<?> fixAttributePath(ResourceAttribute<?> attribute) throws SchemaException { if (attribute == null) { return null; } if (attribute.getPath().startsWithName(ShadowType.F_ATTRIBUTES)) { return attribute; } ResourceAttribute<?> fixedAttribute = attribute.clone(); ResourceAttributeContainer container = ObjectFactory.createResourceAttributeContainer(ShadowType.F_ATTRIBUTES, null, attribute.getPrismContext()); container.createNewValue().add(fixedAttribute); return fixedAttribute; }
private void preparePassword() { if (valueItemPath == null) { return; } if (!valueItemPath.startsWithName(UserType.F_CREDENTIALS)) { return; } Object secondPathSegment = valueItemPath.getSegment(1); if (!ItemPath.isName(secondPathSegment)) { return; } credentialQName = ItemPath.toName(secondPathSegment); if (!QNameUtil.match(CredentialsType.F_PASSWORD, credentialQName)) { return; } if (securityPolicy == null) { return; } credentialPolicy = SecurityUtil.getEffectivePasswordCredentialsPolicy(securityPolicy); }
public boolean containsItem(ItemPath path, boolean acceptEmptyItem) throws SchemaException { if (!path.startsWithName()) { throw new IllegalArgumentException("Attempt to lookup item using a non-name path "+path+" in "+this); } QName subName = path.firstToName(); ItemPath rest = path.rest(); Item item = findItemByQName(subName); if (item != null) { if (rest.isEmpty()) { return (acceptEmptyItem || !item.isEmpty()); } else { // Go deeper if (item instanceof PrismContainer) { return ((PrismContainer<?>)item).containsItem(rest, acceptEmptyItem); } else { return (acceptEmptyItem || !item.isEmpty()); } } } return false; }
@Override protected Function<ItemPath, ItemDefinition<?>> getIdentifierDefinitionProvider(Task localCoordinatorTask, OperationResult opResult) { TaskRunResult dummyRunResult = new TaskRunResult(); ResourceType resource = resolveObjectRef(ResourceType.class, dummyRunResult, localCoordinatorTask, opResult); if (resource == null) { return null; } ObjectClassComplexTypeDefinition objectClass = determineObjectClassDefinition(resource, null, dummyRunResult, localCoordinatorTask, opResult); if (objectClass == null) { return null; } return itemPath -> { if (itemPath.startsWithName(ShadowType.F_ATTRIBUTES)) { return objectClass.findAttributeDefinition(itemPath.rest().asSingleName()); } else { return null; } }; }
private void checkItemRef(ResourceValidationContext ctx, ItemPath path, ResourceObjectTypeDefinitionType objectType, ResourceItemDefinitionType itemDef, String noRefKey) { ItemPath refPath = itemDef.getRef() != null ? itemDef.getRef().getItemPath() : null; if (ItemPath.isEmpty(refPath)) { ctx.validationResult.add(Issue.Severity.ERROR, CAT_SCHEMA_HANDLING, noRefKey, getString(CLASS_DOT + noRefKey, getName(objectType)), ctx.resourceRef, path.append(ItemRefinedDefinitionType.F_REF)); } else if (refPath.size() > 1 || !refPath.startsWithName()) { ctx.validationResult.add(Issue.Severity.ERROR, CAT_SCHEMA_HANDLING, C_WRONG_ITEM_NAME, getString(CLASS_DOT + C_WRONG_ITEM_NAME, getName(objectType), refPath.toString()), ctx.resourceRef, path.append(ItemRefinedDefinitionType.F_REF)); } else if (StringUtils.isBlank(refPath.asSingleName().getNamespaceURI())) { ctx.validationResult.add(Issue.Severity.WARNING, CAT_SCHEMA_HANDLING, C_NO_ITEM_NAMESPACE, getString(CLASS_DOT + C_NO_ITEM_NAMESPACE, getName(objectType), refPath.toString()), ctx.resourceRef, path.append(ItemRefinedDefinitionType.F_REF)); } }
protected ObjectDelta<ShadowType> createModifyAccountShadowReplaceDelta(String accountOid, PrismObject<ResourceType> resource, ItemPath itemPath, Object... newRealValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { if (itemPath.startsWithName(ShadowType.F_ATTRIBUTES)) { PropertyDelta<?> attributeDelta = createAttributeReplaceDelta(resource, ItemPath.toName(itemPath.last()), newRealValue); ObjectDelta<ShadowType> accountDelta = prismContext.deltaFactory().object() .createModifyDelta(accountOid, attributeDelta, ShadowType.class); return accountDelta; } else { ObjectDelta<ShadowType> accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty( ShadowType.class, accountOid, itemPath, newRealValue); return accountDelta; } }
@NotNull private DataItem resolveSourceItem(@NotNull DataModel model, @NotNull ResourceDataItem currentItem, @NotNull MappingType mapping, @NotNull ItemPath path, @Nullable QName defaultVariable) { if (!path.startsWithName()) { LOGGER.warn("Probably incorrect path ({}) - does not start with a name - skipping", path); return createAdHocDataItem(model, path);
@NotNull private DataItem resolveTargetItem(@NotNull DataModel model, @NotNull ResourceDataItem currentItem, @NotNull MappingType mapping, @NotNull ItemPath path, @Nullable QName defaultVariable) { if (!path.startsWithName()) { LOGGER.warn("Probably incorrect path ({}) - does not start with a name - skipping", path); return createAdHocDataItem(model, path);
@Override public RAssignment map(AssignmentType input, MapperContext context) { RAssignment ass = new RAssignment(); ItemDelta delta = context.getDelta(); ItemPath path = delta.getPath().namedSegmentsOnly(); if (path.startsWithName(FocusType.F_ASSIGNMENT)) { ass.setAssignmentOwner(RAssignmentOwner.FOCUS); } else { ass.setAssignmentOwner(RAssignmentOwner.ABSTRACT_ROLE); } RObject owner = (RObject) context.getOwner(); try { RAssignment.fromJaxb(input, ass, owner, context.getRepositoryContext()); } catch (DtoTranslationException ex) { throw new SystemException("Couldn't translate assignment to entity", ex); } return ass; } }
rest = rest.rest(); } else if (QNameUtil.match(AssignmentType.F_CONSTRUCTION, firstName) && rest.startsWithName(ConstructionType.F_RESOURCE_REF)) {