Search in sources :

Example 6 with ObjectListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.

the class TestSanityLegacy method test480ListResources.

@Test
public void test480ListResources() throws Exception {
    final String TEST_NAME = "test480ListResources";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResultType result = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result);
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.searchObjects(ObjectTypes.RESOURCE.getTypeQName(), null, options, objectListHolder, resultHolder);
    // THEN
    display("Resources", objectListHolder.value);
    assertEquals("Unexpected number of resources", 3, objectListHolder.value.getObject().size());
    for (ObjectType object : objectListHolder.value.getObject()) {
        // Marshalling may fail even though the Java object is OK so test for it
        String xml = prismContext.serializeObjectToString(object.asPrismObject(), PrismContext.LANG_XML);
    }
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 7 with ObjectListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.

the class TestWSSanity method test015SearchLdapConnector.

// TODO: fetch&parse schema http://..?WSDL
@Test
public void test015SearchLdapConnector() throws Exception {
    final String TEST_NAME = "test015SearchLdapConnector";
    displayTestTitle(TEST_NAME);
    QueryType query = new QueryType();
    query.setFilter(ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:connectorType</path>" + "<value>" + CONNECTOR_LDAP_TYPE + "</value>" + "</equal>"));
    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();
    // WHEN
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ConnectorType.class), query, null, objectListHolder, resultHolder);
    // THEN
    assertSuccess(resultHolder);
    ObjectListType objectList = objectListHolder.value;
    assertEquals("Unexpected number of LDAP connectors", 1, objectList.getObject().size());
    ConnectorType ldapConnector = (ConnectorType) objectList.getObject().get(0);
    assertNotNull("Null LDAP connector", ldapConnector);
    connectorLdapOid = ldapConnector.getOid();
    assertNotNull("Null LDAP connector OID", connectorLdapOid);
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 8 with ObjectListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.

the class ReportWebService method createObjectListType.

private ObjectListType createObjectListType(Collection resultList) {
    if (resultList == null) {
        return new ObjectListType();
    }
    ObjectListType results = new ObjectListType();
    int skipped = 0;
    for (Object object : resultList) {
        if (object instanceof PrismObject) {
            results.getObject().add(((PrismObject<ObjectType>) object).asObjectable());
        } else if (object instanceof ObjectType) {
            results.getObject().add((ObjectType) object);
        } else {
            skipped++;
        }
    }
    if (skipped > 0) {
        LOGGER.warn("{} non-PrismObject data objects not returned, as these are not supported by ReportWebService yet", skipped);
    }
    return results;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)

Example 9 with ObjectListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.

the class ReportWebServiceRaw method invokeAllowingFaults.

public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
    Node rootNode = request.getNode();
    Element rootElement;
    if (rootNode instanceof Document) {
        rootElement = ((Document) rootNode).getDocumentElement();
    } else if (rootNode instanceof Element) {
        rootElement = (Element) rootNode;
    } else {
        //	            throw ws.createIllegalArgumentFault("Unexpected DOM node type: " + rootNode);
        throw new FaultMessage("Unexpected DOM node type: " + rootNode);
    }
    Object requestObject;
    try {
        requestObject = prismContext.parserFor(rootElement).parseRealValue();
    } catch (SchemaException e) {
        throw new FaultMessage("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
    //	            throw ws.createIllegalArgumentFault("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
    }
    Node response;
    Holder<OperationResultType> operationResultTypeHolder = new Holder<>();
    SerializationContext ctx = new SerializationContext(SerializationOptions.createSerializeReferenceNames());
    try {
        if (requestObject instanceof EvaluateScriptType) {
            EvaluateScriptType s = (EvaluateScriptType) requestObject;
            ObjectListType olt = reportService.evaluateScript(s.getScript(), s.getParameters());
            EvaluateScriptResponseType sr = new EvaluateScriptResponseType();
            sr.setObjectList(olt);
            response = prismContext.domSerializer().context(ctx).serializeAnyData(sr, ReportPort.EVALUATE_SCRIPT_RESPONSE);
        } else if (requestObject instanceof EvaluateAuditScriptType) {
            EvaluateAuditScriptType s = (EvaluateAuditScriptType) requestObject;
            AuditEventRecordListType olt = reportService.evaluateAuditScript(s.getScript(), s.getParameters());
            EvaluateAuditScriptResponseType sr = new EvaluateAuditScriptResponseType();
            sr.setObjectList(olt);
            response = prismContext.domSerializer().context(ctx).serializeAnyData(sr, ReportPort.EVALUATE_AUDIT_SCRIPT_RESPONSE);
        } else if (requestObject instanceof ProcessReportType) {
            ProcessReportType p = (ProcessReportType) requestObject;
            ObjectListType olt = reportService.processReport(p.getQuery(), p.getParameters(), p.getOptions());
            ProcessReportResponseType pr = new ProcessReportResponseType();
            pr.setObjectList(olt);
            response = prismContext.domSerializer().context(ctx).serializeAnyData(pr, ReportPort.PROCESS_REPORT_RESPONSE);
        } else {
            throw new FaultMessage("Unsupported request type: " + requestObject);
        }
    } catch (SchemaException e) {
        throwFault(e, operationResultTypeHolder.value);
        // not reached
        return null;
    }
    return new DOMSource(response);
}
Also used : SerializationContext(com.evolveum.midpoint.prism.SerializationContext) ProcessReportType(com.evolveum.midpoint.xml.ns._public.report.report_3.ProcessReportType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) DOMSource(javax.xml.transform.dom.DOMSource) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) Holder(javax.xml.ws.Holder) EvaluateScriptType(com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateScriptType) EvaluateAuditScriptType(com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateAuditScriptType) Document(org.w3c.dom.Document) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) EvaluateAuditScriptResponseType(com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateAuditScriptResponseType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) AuditEventRecordListType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordListType) EvaluateScriptResponseType(com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateScriptResponseType) ProcessReportResponseType(com.evolveum.midpoint.xml.ns._public.report.report_3.ProcessReportResponseType)

Example 10 with ObjectListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method searchRoleByName.

protected RoleType searchRoleByName(String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (RoleType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Aggregations

ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)27 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)26 Holder (javax.xml.ws.Holder)24 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)18 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)14 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)12 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 Collection (java.util.Collection)9 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)6 Test (org.testng.annotations.Test)6 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)5 QName (javax.xml.namespace.QName)5 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)4 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3