use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class RestfulServer method invokeService.
public MDWStatusMessageDocument invokeService(String request) throws DataAccessException, RemoteException {
String response = null;
try {
// append to Services context root since sometimes only Services/* are excluded from CT auth
HttpHelper httpHelper = getHttpHelper(getMdwWebUrl() + "/Services/REST");
httpHelper.setConnectTimeout(getConnectTimeout());
httpHelper.setReadTimeout(getReadTimeout());
response = httpHelper.post(request);
MDWStatusMessageDocument statusMessageDoc;
if (response.startsWith("{")) {
StatusMessage statusMessage = new StatusMessage(new JSONObject(response));
statusMessageDoc = statusMessage.getStatusDocument();
} else {
statusMessageDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
}
MDWStatusMessage statusMessage = statusMessageDoc.getMDWStatusMessage();
if (statusMessage.getStatusCode() == -3) {
// event handler not registered
throw new RemoteException("No event handler is registered for instance-level actions on: " + getMdwWebUrl());
} else if (statusMessage.getStatusCode() != 0) {
throw new RemoteException("Error response from server: " + statusMessage.getStatusMessage());
}
return statusMessageDoc;
} catch (RemoteException ex) {
// don't fall through to IOException catch block
throw ex;
} catch (SocketTimeoutException ex) {
throw new DataAccessOfflineException("Timeout after " + getReadTimeout() + " ms", ex);
} catch (IOException ex) {
throw new DataAccessOfflineException("Unable to connect to " + getMdwWebUrl(), ex);
} catch (JSONException ex) {
throw new DataAccessException("Unparsable JSON response:\n" + response);
} catch (XmlException ex) {
throw new DataAccessException("Unparsable XML response:\n" + response);
}
}
use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class CacheRefresh method doRefresh.
public void doRefresh(boolean silent, final boolean includeDynamicJava) {
try {
if (silent) {
if (workflowProject.isUpdateServerCache()) {
// run as background job
new Job("MDW Cache Refresh: " + restfulServer.getMdwWebUrl()) {
protected IStatus run(IProgressMonitor monitor) {
try {
CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
timer.stopAndLog();
} catch (Exception ex) {
if (MdwPlugin.getSettings().isLogConnectErrors())
PluginMessages.log(ex);
}
return Status.OK_STATUS;
}
}.schedule();
}
} else {
String progressMsg = "Refreshing Caches and Properties for '" + workflowProject.getLabel() + "'";
String errorMsg = "Refresh Cache";
DesignerRunner designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {
public void perform() throws ValidationException, DataAccessException, RemoteException {
try {
CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
timer.stopAndLog();
} catch (Exception ex) {
PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
}
}
};
designerRunner.run();
if (refreshStatusMessage == null) {
PluginMessages.uiError(workflowProject.getName() + " Refresh Caches and Properties failed. Make sure baseline event handlers are registered.", REFRESH_CACHES, workflowProject);
} else if (refreshStatusMessage.getMDWStatusMessage().getStatusCode() != 0) {
String message = refreshStatusMessage.getMDWStatusMessage().getStatusMessage();
PluginMessages.uiMessage(workflowProject.getName() + " Refresh Caches and Properties:\n" + message, "Refresh Caches", workflowProject, PluginMessages.INFO_MESSAGE);
}
}
} catch (Exception ex) {
if (!silent)
PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
}
}
use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method engineCall.
public String engineCall(String serverUrl, String request, Map<String, String> headers) throws RemoteException, DataAccessException {
String response;
if (serverUrl == null)
throw new DataAccessException("No server specified");
if (serverUrl.startsWith("iiop:")) {
response = sendEjbMessage(serverUrl, request);
} else if (serverUrl.startsWith(HTTP) || serverUrl.startsWith("https:")) {
if (request.startsWith("<env:Envelope"))
response = sendSoapMessage(serverUrl, request, headers);
else
response = sendRestfulMessage(serverUrl, request, headers);
} else if (serverUrl.startsWith("rmi:")) {
response = sendRmiMessage(serverUrl, request);
} else
throw new DataAccessException("Illegal server url: " + serverUrl);
return response;
}
use of com.centurylink.mdw.common.exception.DataAccessException 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.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method getTaskInstances.
private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
List<TaskInstanceVO> taskInstances = new ArrayList<>();
for (TaskInstanceVO taskInstance : allTaskInstances) {
String secondaryOwner = taskInstance.getSecondaryOwnerType();
if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
String formDataString = null;
if (OwnerType.DOCUMENT.equals(secondaryOwner))
formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
FormDataDocument formDataDoc = new FormDataDocument();
try {
formDataDoc.load(formDataString);
for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
taskInstances.add(taskInstance);
}
} catch (MbengException ex) {
throw new DataAccessException(-1, ex.getMessage(), ex);
}
} else {
// task instance secondary owner is work transition instance
Long workTransInstId = taskInstance.getSecondaryOwnerId();
for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
Long transitionId = transitionInstance.getTransitionID();
WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
if (workTrans == null && process.getSubProcesses() != null) {
for (ProcessVO subproc : process.getSubProcesses()) {
workTrans = subproc.getWorkTransition(transitionId);
if (workTrans != null)
break;
}
}
if (workTrans != null && workTrans.getToWorkId().equals(activityId))
taskInstances.add(taskInstance);
}
}
}
}
return taskInstances;
}
Aggregations