Search in sources :

Example 86 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class MidpointFunctionsImpl method takePasswordsFromItemDelta.

private void takePasswordsFromItemDelta(List<ProtectedStringType> passwords, ItemDelta itemDelta) {
    if (itemDelta.isDelete()) {
        return;
    }
    if (itemDelta.getPath().equivalent(new ItemPath(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE))) {
        LOGGER.trace("Found password value add/modify delta");
        Collection<PrismPropertyValue<ProtectedStringType>> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace();
        for (PrismPropertyValue<ProtectedStringType> value : values) {
            passwords.add(value.getValue());
        }
    } else if (itemDelta.getPath().equivalent(new ItemPath(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD))) {
        LOGGER.trace("Found password add/modify delta");
        Collection<PrismContainerValue<PasswordType>> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace();
        for (PrismContainerValue<PasswordType> value : values) {
            if (value.asContainerable().getValue() != null) {
                passwords.add(value.asContainerable().getValue());
            }
        }
    } else if (itemDelta.getPath().equivalent(new ItemPath(ShadowType.F_CREDENTIALS))) {
        LOGGER.trace("Found credentials add/modify delta");
        Collection<PrismContainerValue<CredentialsType>> values = itemDelta.isAdd() ? itemDelta.getValuesToAdd() : itemDelta.getValuesToReplace();
        for (PrismContainerValue<CredentialsType> value : values) {
            if (value.asContainerable().getPassword() != null && value.asContainerable().getPassword().getValue() != null) {
                passwords.add(value.asContainerable().getPassword().getValue());
            }
        }
    }
}
Also used : ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 87 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class PrismContainer method findPartial.

@Override
public <IV extends PrismValue, ID extends ItemDefinition> PartiallyResolvedItem<IV, ID> findPartial(ItemPath path) {
    if (path == null || path.isEmpty()) {
        return new PartiallyResolvedItem<IV, ID>((Item<IV, ID>) this, null);
    }
    IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path);
    PrismContainerValue<C> cval = findValue(idSegment);
    if (cval == null) {
        return null;
    }
    // descent to the correct value
    ItemPath rest = ItemPath.pathRestStartingWithName(path);
    return cval.findPartial(rest);
}
Also used : IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 88 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class PrismContainer method find.

@Override
public Object find(ItemPath path) {
    if (path == null || path.isEmpty()) {
        return this;
    }
    IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path);
    PrismContainerValue<C> cval = findValue(idSegment);
    if (cval == null) {
        return null;
    }
    // descent to the correct value
    ItemPath rest = ItemPath.pathRestStartingWithName(path);
    return cval.find(rest);
}
Also used : IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 89 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class PrismReferenceDefinitionImpl method findItemDefinition.

@Override
public <T extends ItemDefinition> T findItemDefinition(@NotNull ItemPath path, @NotNull Class<T> clazz) {
    if (path.isEmpty() || !(path.first() instanceof ObjectReferencePathSegment)) {
        return super.findItemDefinition(path, clazz);
    } else {
        ItemPath rest = path.rest();
        PrismObjectDefinition referencedObjectDefinition = getSchemaRegistry().determineReferencedObjectDefinition(targetTypeName, rest);
        return (T) referencedObjectDefinition.findItemDefinition(rest, clazz);
    }
}
Also used : ObjectReferencePathSegment(com.evolveum.midpoint.prism.path.ObjectReferencePathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 90 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class PrismReferenceValue method checkConsistenceInternal.

@Override
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) {
    if (!scope.isThorough()) {
        return;
    }
    ItemPath myPath = getPath();
    if (StringUtils.isBlank(oid) && object == null && filter == null) {
        boolean mayBeEmpty = false;
        if (getParent() != null && getParent().getDefinition() != null) {
            ItemDefinition itemDefinition = getParent().getDefinition();
            if (itemDefinition instanceof PrismReferenceDefinition) {
                PrismReferenceDefinition prismReferenceDefinition = (PrismReferenceDefinition) itemDefinition;
                mayBeEmpty = prismReferenceDefinition.isComposite();
            }
        }
        if (!mayBeEmpty) {
            throw new IllegalStateException("Neither OID, object nor filter specified in reference value " + this + " (" + myPath + " in " + rootItem + ")");
        }
    }
    if (object != null) {
        try {
            object.checkConsistence();
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(e.getMessage() + " in reference " + myPath + " in " + rootItem, e);
        } catch (IllegalStateException e) {
            throw new IllegalStateException(e.getMessage() + " in reference " + myPath + " in " + rootItem, e);
        }
    }
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30