Search in sources :

Example 61 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class AssignmentEditorPanel method findOrCreateValueConstruction.

private ResourceAttributeDefinitionType findOrCreateValueConstruction(PrismPropertyDefinition attrDef, List<ResourceAttributeDefinitionType> attrConstructions) {
    for (ResourceAttributeDefinitionType construction : attrConstructions) {
        if (attrDef.getName().equals(construction.getRef())) {
            return construction;
        }
    }
    ResourceAttributeDefinitionType construction = new ResourceAttributeDefinitionType();
    construction.setRef(new ItemPathType(new ItemPath(attrDef.getName())));
    return construction;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 62 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class TestSanity method test501NotifyChangeModifyAccount.

@Test
public void test501NotifyChangeModifyAccount() throws Exception {
    final String TEST_NAME = "test501NotifyChangeModifyAccount";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.MODIFY);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    ItemDeltaType mod1 = new ItemDeltaType();
    mod1.setModificationType(ModificationTypeType.REPLACE);
    ItemPathType path = new ItemPathType(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName")));
    mod1.setPath(path);
    RawType value = new RawType(new PrimitiveXNode<String>("newAngelika"), prismContext);
    mod1.getValue().add(value);
    delta.getItemDelta().add(mod1);
    delta.setOid(oid);
    LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(mod1));
    LOGGER.info("delta: {}", DebugUtil.dump(mod1));
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    // WHEN
    TaskType task = modelWeb.notifyChange(changeDescription);
    // THEN
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertSuccess(result);
    PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
    UserType userAfterSync = userAngelikaAfterSync.asObjectable();
    PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 63 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class ModelClientUtil method createItemPathType.

public static ItemPathType createItemPathType(String stringPath) {
    String pathDeclaration = "declare default namespace '" + NS_COMMON + "'; " + stringPath;
    ItemPathType itemPathType = new ItemPathType(pathDeclaration);
    return itemPathType;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType)

Example 64 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class SecurityEnforcerImpl method isApplicableItem.

private <O extends ObjectType> boolean isApplicableItem(Authorization autz, PrismObject<O> object, ObjectDelta<O> delta) throws SchemaException {
    List<ItemPathType> itemPaths = autz.getItem();
    if (itemPaths == null || itemPaths.isEmpty()) {
        // No item constraints. Applicable for all items.
        LOGGER.trace("  items empty");
        return true;
    }
    for (ItemPathType itemPathType : itemPaths) {
        ItemPath itemPath = itemPathType.getItemPath();
        if (delta == null) {
            if (object != null) {
                if (object.containsItem(itemPath, false)) {
                    LOGGER.trace("  applicable object item " + itemPath);
                    return true;
                }
            }
        } else {
            ItemDelta<?, ?> itemDelta = delta.findItemDelta(itemPath);
            if (itemDelta != null && !itemDelta.isEmpty()) {
                LOGGER.trace("  applicable delta item " + itemPath);
                return true;
            }
        }
    }
    LOGGER.trace("  no applicable item");
    return false;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 65 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class SecurityEnforcerImpl method getItems.

private Collection<ItemPath> getItems(Authorization autz) {
    List<ItemPathType> itemPaths = autz.getItem();
    Collection<ItemPath> items = new ArrayList<>(itemPaths.size());
    for (ItemPathType itemPathType : itemPaths) {
        ItemPath itemPath = itemPathType.getItemPath();
        items.add(itemPath);
    }
    return items;
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ArrayList(java.util.ArrayList) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)114 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)58 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)27 Test (org.testng.annotations.Test)27 QName (javax.xml.namespace.QName)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)21 List (java.util.List)18 NotNull (org.jetbrains.annotations.NotNull)18 PrismObject (com.evolveum.midpoint.prism.PrismObject)15 ArrayList (java.util.ArrayList)15 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)13 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)13 Collectors (java.util.stream.Collectors)13 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)12 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)11 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)11 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)11 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)11 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)11