use of com.evolveum.midpoint.prism.path.ItemPathSegment in project midpoint by Evolveum.
the class TestPath method assertNormalizedPath.
private void assertNormalizedPath(ItemPath normalized, Object... expected) {
assertEquals("wrong path length", normalized.size(), expected.length);
for (int i = 0; i < normalized.size(); i += 2) {
ItemPathSegment nameSegment = normalized.getSegments().get(i);
assert nameSegment instanceof NameItemPathSegment : "Expected name segment but it was " + nameSegment.getClass();
QName name = ((NameItemPathSegment) nameSegment).getName();
assert name != null : "name is null";
assert name.getNamespaceURI().equals(NS) : "wrong namespace: " + name.getNamespaceURI();
assert name.getLocalPart().equals(expected[i]) : "wrong local name, expected " + expected[i] + ", was " + name.getLocalPart();
if (i + 1 < expected.length) {
ItemPathSegment idSegment = normalized.getSegments().get(i + 1);
assert idSegment instanceof IdItemPathSegment : "Expected is segment but it was " + nameSegment.getClass();
Long id = ((IdItemPathSegment) idSegment).getId();
assertId(id, (Long) expected[i + 1]);
}
}
}
use of com.evolveum.midpoint.prism.path.ItemPathSegment in project midpoint by Evolveum.
the class GeneralNotifier method formatPath.
private String formatPath(ItemDelta itemDelta) {
if (itemDelta.getDefinition() != null && itemDelta.getDefinition().getDisplayName() != null) {
return itemDelta.getDefinition().getDisplayName();
}
StringBuilder sb = new StringBuilder();
for (ItemPathSegment itemPathSegment : itemDelta.getPath().getSegments()) {
if (itemPathSegment instanceof NameItemPathSegment) {
NameItemPathSegment nameItemPathSegment = (NameItemPathSegment) itemPathSegment;
if (sb.length() > 0) {
sb.append("/");
}
sb.append(nameItemPathSegment.getName().getLocalPart());
}
}
return sb.toString();
}
use of com.evolveum.midpoint.prism.path.ItemPathSegment in project midpoint by Evolveum.
the class SelectorOptions method isPathInSelected.
private static boolean isPathInSelected(ItemPath path, ItemPath selected) {
if (selected == null || path == null) {
return false;
}
if (path.isEmpty()) {
if (selected.isEmpty()) {
return true;
}
} else {
List<ItemPathSegment> pSegments = path.getSegments();
List<ItemPathSegment> sSegments = selected.getSegments();
for (int i = 0; i < pSegments.size(); i++) {
if (sSegments.size() <= i) {
return true;
}
NameItemPathSegment pSegment = (NameItemPathSegment) pSegments.get(i);
NameItemPathSegment sSegment = (NameItemPathSegment) sSegments.get(i);
if (!pSegment.equivalent(sSegment)) {
return false;
}
}
return true;
}
return false;
}
use of com.evolveum.midpoint.prism.path.ItemPathSegment in project midpoint by Evolveum.
the class ObjectValuePolicyEvaluator method preparePassword.
private void preparePassword() {
if (!QNameUtil.match(UserType.F_CREDENTIALS, valueItemPath.getFirstName())) {
return;
}
ItemPathSegment secondPathSegment = valueItemPath.getSegments().get(1);
if (!(secondPathSegment instanceof NameItemPathSegment)) {
return;
}
credentialQName = ((NameItemPathSegment) secondPathSegment).getName();
if (!QNameUtil.match(CredentialsType.F_PASSWORD, credentialQName)) {
return;
}
credentialPolicy = SecurityUtil.getEffectivePasswordCredentialsPolicy(securityPolicy);
}
use of com.evolveum.midpoint.prism.path.ItemPathSegment in project midpoint by Evolveum.
the class ModelController method resolve.
// TODO clean this mess
private <O extends ObjectType> void resolve(Containerable containerable, ItemPath path, SelectorOptions<GetOperationOptions> option, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException {
if (path == null || path.isEmpty()) {
return;
}
ItemPathSegment first = path.first();
ItemPath rest = path.rest();
PrismContainerValue<?> containerValue = containerable.asPrismContainerValue();
if (first instanceof NameItemPathSegment) {
QName refName = ItemPath.getName(first);
PrismReference reference = containerValue.findReferenceByCompositeObjectElementName(refName);
if (reference == null) {
// alternatively look up by reference name (e.g. linkRef)
reference = containerValue.findReference(refName);
}
if (reference != null) {
for (PrismReferenceValue refVal : reference.getValues()) {
PrismObject<O> refObject = refVal.getObject();
if (refObject == null) {
refObject = objectResolver.resolve(refVal, containerable.toString(), option.getOptions(), task, result);
refObject = refObject.cloneIfImmutable();
schemaTransformer.applySchemasAndSecurity(refObject, option.getOptions(), null, task, result);
refVal.setObject(refObject);
}
if (!rest.isEmpty()) {
resolve(refObject.asObjectable(), rest, option, task, result);
}
}
return;
}
}
if (rest.isEmpty()) {
return;
}
if (first instanceof ParentPathSegment) {
PrismContainerValue<?> parent = containerValue.getParentContainerValue();
if (parent != null) {
resolve(parent.asContainerable(), rest, option, task, result);
}
} else {
QName nextName = ItemPath.getName(first);
PrismContainer<?> nextContainer = containerValue.findContainer(nextName);
if (nextContainer != null) {
for (PrismContainerValue<?> pcv : nextContainer.getValues()) {
resolve(pcv.asContainerable(), rest, option, task, result);
}
}
}
}
Aggregations