Search in sources :

Example 1 with ActionRequestDocument

use of com.centurylink.mdw.service.ActionRequestDocument in project mdw-designer by CenturyLinkCloud.

the class TestCaseRun method performNotify.

public void performNotify(String eventName, String message, String procName, String actLogicalId) throws TestException {
    try {
        TestDataFilter filter = new TestDataFilter(message, log, true);
        Map<String, String> map = new HashMap<String, String>();
        map.put(TestDataFilter.MasterRequestId, this.masterRequestId);
        map.put(TestDataFilter.RunNumber, Integer.toString(runNumber));
        // FIXME: placeholders for non-legacy
        if (testcase.isLegacy()) {
            File mapfile = new File(testcase.getCaseDirectory().getPath() + "/" + TestCase.PLACEHOLDER_MAP_FILENAME);
            TestDataFilter.loadPlaceHolderMap(mapfile, map, runNumber);
            message = filter.applyFilters(map, null);
        }
        ActionRequestDocument msgdoc = ActionRequestDocument.Factory.newInstance();
        ActionRequest actionRequest = msgdoc.addNewActionRequest();
        com.centurylink.mdw.service.Action act = actionRequest.addNewAction();
        act.setName("RegressionTest");
        addActionParameter(act, "SubAction", "NotifyProcess");
        addActionParameter(act, "EventName", eventName);
        addActionParameter(act, "Message", message);
        addActionParameter(act, "MasterRequestId", masterRequestId);
        if (procName != null)
            addActionParameter(act, "ProcessName", procName);
        if (actLogicalId != null)
            addActionParameter(act, "ActivityLogicalId", actLogicalId);
        String request;
        if (oldNamespaces)
            request = DesignerCompatibility.getInstance().getOldActionRequest(msgdoc);
        else
            request = msgdoc.xmlText();
        String server = getNextServer();
        if (server == null)
            response = dao.sendMessage("DefaultProtocol", request, getDefaultMessageHeaders());
        else
            response = dao.engineCall(dao.getPeerServerUrl(server), request);
        log.println("Response: " + response);
    } catch (Exception e) {
        throw new TestException(e.getMessage(), e);
    }
}
Also used : HashMap(java.util.HashMap) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) File(java.io.File) JSONException(org.json.JSONException) ParseException(java.text.ParseException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 2 with ActionRequestDocument

use of com.centurylink.mdw.service.ActionRequestDocument in project mdw-designer by CenturyLinkCloud.

the class TestCaseRun method performTask.

public JSONObject performTask(String taskName, String action, Map<String, String> variables) throws TestException {
    try {
        ActionRequestDocument msgdoc = ActionRequestDocument.Factory.newInstance();
        ActionRequest actionRequest = msgdoc.addNewActionRequest();
        com.centurylink.mdw.service.Action act = actionRequest.addNewAction();
        act.setName("RegressionTest");
        addActionParameter(act, "SubAction", "TaskAction");
        addActionParameter(act, "TaskName", taskName);
        addActionParameter(act, "MasterRequestId", masterRequestId);
        addActionParameter(act, "User", dao.getCuid());
        if (action.startsWith("Action/")) {
            addActionParameter(act, "FormAction", action.substring("Action/".length()));
        } else {
            addActionParameter(act, "DirectAction", action);
        }
        for (String dataname : variables.keySet()) {
            addActionParameter(act, "formdata." + dataname, variables.get(dataname));
        }
        String request;
        if (oldNamespaces)
            request = DesignerCompatibility.getInstance().getOldActionRequest(msgdoc);
        else
            request = msgdoc.xmlText();
        String server = getNextServer();
        String response;
        if (server == null)
            response = dao.engineCall(request);
        else
            response = dao.engineCall(dao.getPeerServerUrl(server), request);
        return validateEngineCallResponse(response);
    } catch (Exception e) {
        throw new TestException(e.getMessage(), e);
    }
}
Also used : ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) JSONException(org.json.JSONException) ParseException(java.text.ParseException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 3 with ActionRequestDocument

use of com.centurylink.mdw.service.ActionRequestDocument in project mdw-designer by CenturyLinkCloud.

the class RestfulServer method launchSynchronousProcess.

public String launchSynchronousProcess(Long processId, String masterRequestId, String owner, Long ownerId, Map<VariableVO, String> variables, String responseVarName, boolean oldFormat) throws XmlException, JSONException, IOException {
    if (isSchemaVersion61()) {
        return launchProcess(processId, masterRequestId, owner, ownerId, variables);
    } else {
        ActionRequestDocument actionRequestDoc = getLaunchProcessBaseDoc(processId, masterRequestId, owner, ownerId);
        Parameter syncParam = actionRequestDoc.getActionRequest().getAction().addNewParameter();
        syncParam.setName("mdw.Synchronous");
        syncParam.setStringValue("true");
        Parameter responseVarParam = actionRequestDoc.getActionRequest().getAction().addNewParameter();
        responseVarParam.setName("mdw.ResponseVariableName");
        responseVarParam.setStringValue(responseVarName);
        for (VariableVO variableVO : variables.keySet()) {
            Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
            parameter.setName(variableVO.getVariableName());
            parameter.setType(variableVO.getVariableType());
            String stringValue = variables.get(variableVO);
            parameter.setStringValue(stringValue);
        }
        try {
            HttpHelper httpHelper = getHttpHelper(getMdwWebUrl() + "/Services/REST");
            httpHelper.setConnectTimeout(getConnectTimeout());
            httpHelper.setReadTimeout(getReadTimeout());
            String request;
            if (oldFormat)
                request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
            else
                request = actionRequestDoc.xmlText(getXmlOptions());
            return httpHelper.post(request);
        } catch (SocketTimeoutException ex) {
            throw new RemoteException("Timeout after " + getReadTimeout() + " ms", ex);
        } catch (IOException ex) {
            throw new RemoteException("Unable to connect to " + getMdwWebUrl(), ex);
        }
    }
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) Parameter(com.centurylink.mdw.service.Parameter) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 4 with ActionRequestDocument

use of com.centurylink.mdw.service.ActionRequestDocument in project mdw-designer by CenturyLinkCloud.

the class Server method buildActionOnActivityInstanceRequest.

private String buildActionOnActivityInstanceRequest(Long activityId, Long activityInstanceId, String actionType, String completionCode, boolean oldFormat) throws XmlException {
    ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
    ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
    Action action = actionRequest.addNewAction();
    action.setName("PerformInstanceLevelAction");
    Parameter parameter = action.addNewParameter();
    parameter.setName("mdw.WorkType");
    parameter.setStringValue(WorkType.ACTIVITY.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.Action");
    parameter.setStringValue(actionType);
    parameter = action.addNewParameter();
    parameter.setName("mdw.DefinitionId");
    parameter.setStringValue(activityId.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.InstanceId");
    parameter.setStringValue(activityInstanceId.toString());
    if (completionCode != null) {
        parameter = action.addNewParameter();
        parameter.setName("mdw.CompletionCode");
        parameter.setStringValue(completionCode);
    }
    String request;
    if (oldFormat)
        request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
    else
        request = actionRequestDoc.xmlText(getXmlOptions());
    return request;
}
Also used : Action(com.centurylink.mdw.service.Action) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) Parameter(com.centurylink.mdw.service.Parameter) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 5 with ActionRequestDocument

use of com.centurylink.mdw.service.ActionRequestDocument in project mdw-designer by CenturyLinkCloud.

the class Server method getLaunchProcessBaseDoc.

protected ActionRequestDocument getLaunchProcessBaseDoc(Long processId, String masterRequestId, String owner, Long ownerId) {
    ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
    ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
    Action action = actionRequest.addNewAction();
    action.setName("PerformInstanceLevelAction");
    Parameter parameter = action.addNewParameter();
    parameter.setName("mdw.WorkType");
    parameter.setStringValue(WorkType.PROCESS.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.Action");
    parameter.setStringValue("Launch");
    parameter = action.addNewParameter();
    parameter.setName("mdw.DefinitionId");
    parameter.setStringValue(processId.toString());
    parameter = action.addNewParameter();
    parameter.setName("mdw.MasterRequestId");
    parameter.setStringValue(masterRequestId);
    parameter = action.addNewParameter();
    parameter.setName("mdw.Owner");
    parameter.setStringValue(owner);
    parameter = action.addNewParameter();
    parameter.setName("mdw.OwnerId");
    if (ownerId == null)
        ownerId = new Date().getTime();
    parameter.setStringValue(ownerId.toString());
    return actionRequestDoc;
}
Also used : Action(com.centurylink.mdw.service.Action) ActionRequest(com.centurylink.mdw.service.ActionRequestDocument.ActionRequest) Parameter(com.centurylink.mdw.service.Parameter) Date(java.util.Date) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Aggregations

ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)11 Parameter (com.centurylink.mdw.service.Parameter)9 ActionRequest (com.centurylink.mdw.service.ActionRequestDocument.ActionRequest)8 Action (com.centurylink.mdw.service.Action)6 IOException (java.io.IOException)4 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)2 MbengException (com.qwest.mbeng.MbengException)2 ParseException (java.text.ParseException)2 XmlException (org.apache.xmlbeans.XmlException)2 JSONException (org.json.JSONException)2 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)1 StatusMessage (com.centurylink.mdw.common.service.types.StatusMessage)1 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)1 File (java.io.File)1 InetAddress (java.net.InetAddress)1 SocketTimeoutException (java.net.SocketTimeoutException)1 RemoteException (java.rmi.RemoteException)1 Date (java.util.Date)1