Search in sources :

Example 1 with ActionRequest

use of com.centurylink.mdw.service.ActionRequestDocument.ActionRequest 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 ActionRequest

use of com.centurylink.mdw.service.ActionRequestDocument.ActionRequest 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 ActionRequest

use of com.centurylink.mdw.service.ActionRequestDocument.ActionRequest 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 4 with ActionRequest

use of com.centurylink.mdw.service.ActionRequestDocument.ActionRequest 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)

Example 5 with ActionRequest

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

the class RestfulServer method refreshCache.

public MDWStatusMessageDocument refreshCache(String type, String cacheName, boolean global, boolean oldFormat, boolean includeDynamicJava) throws DataAccessException, XmlException, IOException {
    if (isSchemaVersion61())
        return refreshCache("WorkflowCache", cacheName, global, includeDynamicJava);
    else {
        ActionRequestDocument actionRequestDoc = ActionRequestDocument.Factory.newInstance();
        ActionRequest actionRequest = actionRequestDoc.addNewActionRequest();
        Action action = actionRequest.addNewAction();
        action.setName("RefreshCache");
        if (type != null) {
            Parameter typeParam = action.addNewParameter();
            typeParam.setName("RefreshType");
            typeParam.setStringValue(type);
        }
        if (cacheName != null) {
            Parameter cacheNameParam = action.addNewParameter();
            cacheNameParam.setName("CacheName");
            cacheNameParam.setStringValue(cacheName);
        }
        if (global) {
            Parameter parameter = action.addNewParameter();
            parameter.setName("GlobalRefresh");
            parameter.setStringValue("true");
        }
        if (!includeDynamicJava) {
            Parameter parameter = action.addNewParameter();
            parameter.setName("ExcludedFormats");
            parameter.setStringValue(RuleSetVO.JAVA);
        }
        String request;
        if (oldFormat)
            request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
        else
            request = actionRequestDoc.xmlText(getXmlOptions());
        return invokeService(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)

Aggregations

ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)8 ActionRequest (com.centurylink.mdw.service.ActionRequestDocument.ActionRequest)8 Parameter (com.centurylink.mdw.service.Parameter)6 Action (com.centurylink.mdw.service.Action)5 IOException (java.io.IOException)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 File (java.io.File)1 InetAddress (java.net.InetAddress)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 PartInitException (org.eclipse.ui.PartInitException)1