use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class BamEventComposer method setElement.
public void setElement(WorkflowElement element) {
this.element = element;
WorkflowAsset bamPageletAsset = getElement().getPackage().getAsset(WorkflowProject.BAM_PAGELET);
if (bamPageletAsset == null) {
// try baseline package
WorkflowPackage baselinePackage = element.getProject().getPackage(PackageVO.BASELINE_PACKAGE_NAME);
if (baselinePackage != null)
bamPageletAsset = baselinePackage.getAsset(WorkflowProject.BAM_PAGELET);
}
bamPagelet = null;
try {
if (bamPageletAsset == null) {
bamPagelet = PAGELETDocument.Factory.parse(BamEventComposer.DEFAULT_BAM_PAGELET).getPAGELET();
} else {
if (!bamPageletAsset.isLoaded())
bamPageletAsset.load();
bamPagelet = PAGELETDocument.Factory.parse(bamPageletAsset.getContent()).getPAGELET();
}
} catch (XmlException ex) {
PluginMessages.uiError(ex, "BAM Pagelet", element.getProject());
}
createBamDataTable();
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method launchProcess.
public MDWStatusMessage launchProcess(WorkflowProcess processVersion, String masterRequestId, String owner, Long ownerId, List<VariableValue> variableValues, Long activityId) throws DataAccessException, XmlException, JSONException, IOException {
Map<VariableVO, String> variables = new HashMap<>();
for (VariableValue variableValue : variableValues) {
variables.put(variableValue.getVariableVO(), variableValue.getValue());
}
MDWStatusMessageDocument statusMessageDoc = restfulServer.launchProcess(processVersion.getId(), masterRequestId, owner, ownerId, variables, activityId, project.isOldNamespaces());
if (statusMessageDoc.getMDWStatusMessage().getStatusCode() != 0)
throw new RemoteException("Error launching process: " + statusMessageDoc.getMDWStatusMessage().getStatusMessage());
// audit log in separate dao since launch is multi-threaded
UserActionVO userAction = new UserActionVO(project.getUser().getUsername(), Action.Run, processVersion.getActionEntity(), processVersion.getId(), processVersion.getLabel());
userAction.setSource("Eclipse/RCP Designer");
try {
new DesignerDataAccess(dataAccess.getDesignerDataAccess()).auditLog(userAction);
} catch (Exception ex) {
throw new DataAccessException(-1, ex.getMessage(), ex);
}
return statusMessageDoc.getMDWStatusMessage();
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method renameProcess.
public void renameProcess(final WorkflowProcess processVersion, final String newName) {
if (dataAccess.processNameExists(processVersion.getPackage().getPackageVO(), newName)) {
Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
MessageDialog.openError(shell, RENAME_ERROR, "Process name already exists: '" + newName + "'");
return;
}
String version = "v" + processVersion.getVersionString();
String progressMsg = "Renaming to '" + newName + "' " + version;
String errorMsg = "Rename Process";
designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {
public void perform() throws ValidationException, DataAccessException, RemoteException, XmlException {
try {
if (dataAccess.getDesignerDataAccess().hasProcessInstances(processVersion.getId()))
throw new DataAccessException("Process " + processVersion.getLabel() + " has instances and cannot be renamed.\nPlease save as a new version.");
} catch (DataAccessOfflineException ex) {
final StringBuilder confirm = new StringBuilder();
MdwPlugin.getDisplay().syncExec(new Runnable() {
public void run() {
String msg = "Cannot connect to server to check for instances. Are you sure you want to rename?";
confirm.append(MessageDialog.openConfirm(MdwPlugin.getShell(), "Rename Process", msg));
}
});
if (!Boolean.valueOf(confirm.toString()))
return;
}
dataAccess.removeProcess(processVersion.getProcessVO());
if (processVersion.isInRuleSet() && !project.isFilePersist()) {
ProcessVO procVO = dataAccess.getDesignerDataAccess().getProcessDefinition(processVersion.getName(), processVersion.getVersion());
procVO = dataAccess.getDesignerDataAccess().getProcess(procVO.getProcessId(), procVO);
procVO.setName(newName);
procVO.setVersion(1);
new ProcessWorker().convert_to_designer(procVO);
dataAccess.getDesignerDataAccess().updateProcess(procVO, 0, false);
processVersion.setProcessVO(procVO);
} else {
processVersion.setName(newName);
processVersion.getProcessVO().setVersion(1);
processVersion.getProcessVO().setId(dataAccess.getDesignerDataAccess().renameProcess(processVersion.getId(), newName, 1));
}
dataAccess.getDesignerDataModel().addProcess(processVersion.getProcessVO());
}
};
designerRunner.run();
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class CustomTaskManager method updateApplicationXml.
private void updateApplicationXml(WorkflowProject project, String webUri, String contextRoot, IProgressMonitor monitor) throws XmlException, CoreException, IOException {
monitor.subTask("Update application deployment descriptor");
String namespace = "http://java.sun.com/xml/ns/j2ee";
QName id = new QName("id");
String errorMsg = "Update failed for EAR content META-INF/application.xml.";
XmlCursor xmlCursor = null;
try {
IFile appXmlFile = project.getEarContentFolder().getFile("META-INF/application.xml");
XmlObject xmlBean = XmlObject.Factory.parse(appXmlFile.getContents());
xmlCursor = xmlBean.newCursor();
// document
xmlCursor.toChild(0);
if (!xmlCursor.toChild(namespace, "module")) {
namespace = "http://java.sun.com/xml/ns/javaee";
xmlCursor.toChild(namespace, "module");
}
boolean found = true;
while (found && !"MDWTaskManagerWeb".equals(xmlCursor.getAttributeText(id))) found = xmlCursor.toNextSibling(namespace, "module");
if (!found)
throw new XmlException(errorMsg + "\nNo 'module' element found with id='MDWTaskManagerWeb'");
if (!xmlCursor.toChild(namespace, "web"))
throw new XmlException(errorMsg + "\nMissing 'web' subelement under module 'MDWTaskManagerWeb'");
if (!xmlCursor.toChild(namespace, "web-uri"))
throw new XmlException(errorMsg + "\nMissing 'web-uri' subelement under module 'MDWTaskManagerWeb'");
xmlCursor.setTextValue(webUri);
xmlCursor.toParent();
if (!xmlCursor.toChild(namespace, "context-root"))
throw new XmlException(errorMsg + "\nMissing 'context-root' subelement under module 'MDWTaskManagerWeb'");
xmlCursor.setTextValue(contextRoot);
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setUseDefaultNamespace();
PluginUtil.writeFile(appXmlFile, xmlBean.xmlText(xmlOptions), monitor);
} finally {
if (xmlCursor != null)
xmlCursor.dispose();
}
}
use of org.apache.xmlbeans.XmlException 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);
}
}
Aggregations