Search in sources :

Example 56 with NameItemPathSegment

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

the class TestValidityRecomputeTask method test129JackAssignmentJudgeValidToSetValid.

@Test
public void test129JackAssignmentJudgeValidToSetValid() throws Exception {
    final String TEST_NAME = "test129JackAssignmentJudgeValidToSetValid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assertNoDummyAccount(null, USER_JACK_USERNAME);
    AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID);
    XMLGregorianCalendar validTo = clock.currentTimeXMLGregorianCalendar();
    // one hour ahead
    validTo.add(XmlTypeConverter.createDuration(60 * 60 * 1000));
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_TO)), task, result, validTo);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("User after", user);
    assertDummyAccount(null, USER_JACK_USERNAME);
    assert11xUserOk(user);
    // CLEANUP
    unassignAllRoles(USER_JACK_OID);
    assertNoDummyAccount(null, USER_JACK_USERNAME);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 57 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment 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();
}
Also used : ItemPathSegment(com.evolveum.midpoint.prism.path.ItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment)

Example 58 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment 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;
}
Also used : ItemPathSegment(com.evolveum.midpoint.prism.path.ItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment)

Example 59 with NameItemPathSegment

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

the class AbstractSearchExpressionEvaluator method evaluatePopulateExpression.

private <IV extends PrismValue, ID extends ItemDefinition, C extends Containerable> ItemDelta<IV, ID> evaluatePopulateExpression(PopulateItemType populateItem, ExpressionVariables variables, ExpressionEvaluationContext params, PrismContainerDefinition<C> objectDefinition, String contextDescription, boolean evaluateMinus, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    ExpressionType expressionType = populateItem.getExpression();
    if (expressionType == null) {
        LOGGER.warn("No expression in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
        return null;
    }
    VariableBindingDefinitionType targetType = populateItem.getTarget();
    if (targetType == null) {
        LOGGER.warn("No target in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
        return null;
    }
    ItemPathType itemPathType = targetType.getPath();
    if (itemPathType == null) {
        throw new SchemaException("No path in target definition in " + contextDescription);
    }
    ItemPath targetPath = itemPathType.getItemPath();
    ID propOutputDefinition = ExpressionUtil.resolveDefinitionPath(targetPath, variables, objectDefinition, "target definition in " + contextDescription);
    if (propOutputDefinition == null) {
        throw new SchemaException("No target item that would conform to the path " + targetPath + " in " + contextDescription);
    }
    String expressionDesc = "expression in assignment expression in " + contextDescription;
    ExpressionFactory expressionFactory = params.getExpressionFactory();
    Expression<IV, ID> expression = expressionFactory.makeExpression(expressionType, propOutputDefinition, expressionDesc, task, result);
    ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, expressionDesc, task, result);
    context.setExpressionFactory(expressionFactory);
    context.setStringPolicyResolver(params.getStringPolicyResolver());
    context.setDefaultTargetContext(params.getDefaultTargetContext());
    context.setSkipEvaluationMinus(true);
    context.setSkipEvaluationPlus(false);
    PrismValueDeltaSetTriple<IV> outputTriple = expression.evaluate(context);
    LOGGER.trace("output triple: {}", outputTriple.debugDump());
    Collection<IV> pvalues = outputTriple.getNonNegativeValues();
    // Maybe not really clean but it works. TODO: refactor later
    NameItemPathSegment first = (NameItemPathSegment) targetPath.first();
    if (first.isVariable()) {
        targetPath = targetPath.rest();
    }
    ItemDelta<IV, ID> itemDelta = propOutputDefinition.createEmptyDelta(targetPath);
    itemDelta.addValuesToAdd(PrismValue.cloneCollection(pvalues));
    LOGGER.trace("Item delta:\n{}", itemDelta.debugDump());
    return itemDelta;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 60 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment 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);
}
Also used : ItemPathSegment(com.evolveum.midpoint.prism.path.ItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment)

Aggregations

NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)69 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)61 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)46 Test (org.testng.annotations.Test)35 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 QName (javax.xml.namespace.QName)20 Task (com.evolveum.midpoint.task.api.Task)19 ItemPathSegment (com.evolveum.midpoint.prism.path.ItemPathSegment)15 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)14 TestTriggerTask (com.evolveum.midpoint.model.intest.TestTriggerTask)11 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)10 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 UserType (com.evolveum.midpoint.prism.foo.UserType)7 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)7 AssignmentType (com.evolveum.midpoint.prism.foo.AssignmentType)6 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)6 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4