Search in sources :

Example 11 with RestfulServer

use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.

the class GroovyTestCaseRun method startProcess.

void startProcess(TestCaseProcess process) throws TestException {
    if (verbose)
        log.println("starting process " + process.getLabel() + "...");
    this.testCaseProcess = process;
    try {
        if (!getTestCase().isLegacy()) {
            // delete the (convention-based) result file if exists
            String resFileName = getTestCase().getName() + RuleSetVO.getFileExtension(RuleSetVO.YAML);
            File resFile = new File(getTestCase().getResultDirectory() + "/" + resFileName);
            if (resFile.isFile())
                resFile.delete();
        }
        ProcessVO vo = process.getProcessVo();
        Map<String, String> params = process.getParams();
        String server = getNextServer();
        String response;
        if (server == null) {
            response = dao.launchProcess(vo, getMasterRequestId(), null, params, false, oldNamespaces);
        } else {
            Server restServer = dao.getCurrentServer();
            if (restServer.isSchemaVersion61()) {
                Map<VariableVO, String> variables = new HashMap<>();
                for (Map.Entry<String, String> entry : params.entrySet()) {
                    VariableVO varVO = vo.getVariable(entry.getKey());
                    if (varVO != null)
                        variables.put(varVO, entry.getValue());
                }
                response = ((RestfulServer) restServer).launchProcess(vo.getProcessId(), masterRequestId, vo.getOwnerType(), vo.getOwnerId(), variables);
            } else {
                String request = restServer.buildLaunchProcessRequest(vo, getMasterRequestId(), null, params, false, oldNamespaces);
                response = dao.engineCall(dao.getPeerServerUrl(server), request);
            }
        }
        validateEngineCallResponse(response);
    } catch (Exception ex) {
        throw new TestException("Failed to start " + process.getLabel(), ex);
    }
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) AssetFile(com.centurylink.mdw.dataaccess.file.AssetFile) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) JSONException(org.json.JSONException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException)

Example 12 with RestfulServer

use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method skipActivity.

public void skipActivity(Long activityId, Long activityInstId, String compCode) throws DataAccessException, XmlException, IOException {
    if (currentServer.isSchemaVersion61()) {
        ((RestfulServer) currentServer).skipActivityInstance(activityInstId, ActivityResultCodeConstant.RESULT_PROCEED, compCode);
    } else {
        String request = currentServer.buildSkipActivityInstanceRequest(activityId, activityInstId, compCode, false);
        String response = this.engineCall(request);
        try {
            String result = currentServer.getErrorMessageFromResponse(response);
            if (result == null || result.length() > 0)
                throw new RemoteException(result);
            auditLog(Action.Proceed, Entity.ActivityInstance, activityInstId, compCode);
        } catch (XmlException e) {
            throw new DataAccessException("Response is not an MDWStatusMessage");
        }
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 13 with RestfulServer

use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.

the class TestCaseRun method performStart.

public void performStart(TestFileLine line) throws TestException {
    logCommand(line);
    ProcessVO vo = getProcess(line, line.getWord(1));
    Map<String, String> params = new HashMap<>();
    try {
        for (int i = 2; i < line.getWordCount(); i++) {
            int k = line.getWord(i).indexOf('=');
            params.put(line.getWord(i).substring(0, k), getParameterValue(line.getWord(i).substring(k + 1)));
        }
        String server = getNextServer();
        if (server == null)
            dao.launchProcess(vo, masterRequestId, null, params, false, oldNamespaces);
        else {
            Server restServer = dao.getCurrentServer();
            if (restServer.isSchemaVersion61()) {
                Map<VariableVO, String> variables = new HashMap<>();
                for (Map.Entry<String, String> entry : params.entrySet()) {
                    VariableVO varVO = vo.getVariable(entry.getKey());
                    if (varVO != null)
                        variables.put(varVO, entry.getValue());
                }
                response = ((RestfulServer) restServer).launchProcess(vo.getProcessId(), masterRequestId, vo.getOwnerType(), vo.getOwnerId(), variables);
            } else {
                String request = dao.getCurrentServer().buildLaunchProcessRequest(vo, masterRequestId, null, params, false, oldNamespaces);
                dao.engineCall(dao.getPeerServerUrl(server), request);
            }
        }
    } catch (Exception e) {
        throw new TestException(line, "failed to launch process", e);
    }
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) 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)

Aggregations

RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)13 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)10 IOException (java.io.IOException)8 RemoteException (java.rmi.RemoteException)7 XmlException (org.apache.xmlbeans.XmlException)7 JSONException (org.json.JSONException)6 VersionControl (com.centurylink.mdw.dataaccess.VersionControl)5 VersionControlGit (com.centurylink.mdw.dataaccess.file.VersionControlGit)4 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)4 File (java.io.File)4 DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)3 Server (com.centurylink.mdw.designer.utils.Server)3 HashMap (java.util.HashMap)3 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)2 ProcessImporter (com.centurylink.mdw.dataaccess.ProcessImporter)2 AppSummary (com.centurylink.mdw.designer.model.AppSummary)2 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)2 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)2 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)2 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)2