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