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());
}
}
}
}
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);
}
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);
}
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);
}
}
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);
}
}
}
Aggregations