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);
}
}
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");
}
}
}
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);
}
}
Aggregations