Search in sources :

Example 26 with MapXNode

use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.

the class ImportTest method assertDummyResource.

private void assertDummyResource(PrismObject<ResourceType> resource, boolean fromRepo) {
    PrismContainer<Containerable> configurationPropertiesContainer = assertResource(resource, "Dummy Resource", RESOURCE_DUMMY_NAMESPACE, dummyConnector.getOid(), fromRepo);
    PrismProperty<ProtectedStringType> guardedProperty = configurationPropertiesContainer.findProperty(new QName(CONNECTOR_DUMMY_NAMESPACE, "uselessGuardedString"));
    // The resource was pulled from the repository. Therefore it does not have the right schema here. We should proceed with caution
    // and inspect the DOM elements there
    assertNotNull("No uselessGuardedString property in configuration properties", guardedProperty);
    PrismPropertyValue<ProtectedStringType> guardedPVal = guardedProperty.getValue();
    if (fromRepo) {
        Object passwordRawElement = guardedPVal.getRawElement();
        if (!(passwordRawElement instanceof MapXNode)) {
            AssertJUnit.fail("Expected password value of type " + MapXNode.class + " but got " + passwordRawElement.getClass());
        }
        MapXNode passwordXNode = (MapXNode) passwordRawElement;
        assertTrue("uselessGuardedString was not encrypted (clearValue)", passwordXNode.get(new QName("clearValue")) == null);
        assertTrue("uselessGuardedString was not encrypted (no encryptedData)", passwordXNode.get(new QName("encryptedData")) != null);
    } else {
        ProtectedStringType psType = guardedPVal.getValue();
        assertNull("uselessGuardedString was not encrypted (clearValue)", psType.getClearValue());
        assertNotNull("uselessGuardedString was not encrypted (no EncryptedData)", psType.getEncryptedDataType());
    }
}
Also used : QName(javax.xml.namespace.QName) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 27 with MapXNode

use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.

the class QueryJaxbConvertor method createQueryType.

public static QueryType createQueryType(ObjectQuery query, PrismContext prismContext) throws SchemaException {
    ObjectFilter filter = query.getFilter();
    QueryType queryType = new QueryType();
    if (filter != null) {
        SearchFilterType filterType = new SearchFilterType();
        MapXNode filterXNode = QueryConvertor.serializeFilter(filter, prismContext);
        filterType.setFilterClauseXNode(filterXNode);
        queryType.setFilter(filterType);
    }
    queryType.setPaging(PagingConvertor.createPagingType(query.getPaging()));
    return queryType;
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 28 with MapXNode

use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.

the class SearchFilterType method setFilterClauseXNode.

public void setFilterClauseXNode(RootXNode filterClauseNode) {
    if (filterClauseNode == null) {
        this.filterClauseXNode = null;
    } else {
        this.filterClauseXNode = new MapXNode();
        this.filterClauseXNode.put(filterClauseNode.getRootElementName(), filterClauseNode.getSubnode());
    }
}
Also used : MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode)

Example 29 with MapXNode

use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.

the class SearchFilterType method serializeToXNode.

public MapXNode serializeToXNode() throws SchemaException {
    MapXNode xmap = getFilterClauseXNode();
    if (description == null) {
        return xmap;
    } else {
        // we have to serialize the map in correct order (see MID-1847): description first, filter clause next
        MapXNode newXMap = new MapXNode();
        newXMap.put(SearchFilterType.F_DESCRIPTION, new PrimitiveXNode<>(description));
        if (xmap != null && !xmap.isEmpty()) {
            newXMap.put(xmap.getSingleSubEntry("search filter"));
        }
        return newXMap;
    }
}
Also used : MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode)

Example 30 with MapXNode

use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.

the class TestFundamentals method testRawTypeClone.

@Test
public void testRawTypeClone() throws Exception {
    System.out.println("\n\n===[ testRawTypeClone ]===\n");
    // GIVEN
    QName typeQName = new QName("abcdef");
    MapXNode mapXNode = new MapXNode();
    mapXNode.setTypeQName(typeQName);
    RawType rawType = new RawType(mapXNode, PrismTestUtil.getPrismContext());
    // WHEN
    RawType rawTypeClone = rawType.clone();
    // THEN
    assertEquals("Wrong or missing type QName", typeQName, rawTypeClone.getXnode().getTypeQName());
}
Also used : QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) Test(org.testng.annotations.Test)

Aggregations

MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)42 QName (javax.xml.namespace.QName)24 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)21 XNode (com.evolveum.midpoint.prism.xnode.XNode)18 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)15 ListXNode (com.evolveum.midpoint.prism.xnode.ListXNode)13 Test (org.testng.annotations.Test)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)9 SchemaXNode (com.evolveum.midpoint.prism.xnode.SchemaXNode)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)7 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)7 Element (org.w3c.dom.Element)6 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)4 Protector (com.evolveum.midpoint.prism.crypto.Protector)3 EncryptedDataType (com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType)3 NotNull (org.jetbrains.annotations.NotNull)3 TestProtector (com.evolveum.midpoint.prism.crypto.TestProtector)2