Search in sources :

Example 1 with EvaluateAuditScriptType

use of com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateAuditScriptType 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)

Aggregations

SerializationContext (com.evolveum.midpoint.prism.SerializationContext)1 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)1 XNode (com.evolveum.midpoint.prism.xnode.XNode)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)1 AuditEventRecordListType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordListType)1 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)1 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)1 EvaluateAuditScriptResponseType (com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateAuditScriptResponseType)1 EvaluateAuditScriptType (com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateAuditScriptType)1 EvaluateScriptResponseType (com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateScriptResponseType)1 EvaluateScriptType (com.evolveum.midpoint.xml.ns._public.report.report_3.EvaluateScriptType)1 ProcessReportResponseType (com.evolveum.midpoint.xml.ns._public.report.report_3.ProcessReportResponseType)1 ProcessReportType (com.evolveum.midpoint.xml.ns._public.report.report_3.ProcessReportType)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Holder (javax.xml.ws.Holder)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1