use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method retryActivity.
public void retryActivity(Long activityId, Long activityInstId) throws DataAccessException, XmlException, IOException {
if (currentServer.isSchemaVersion61()) {
((RestfulServer) currentServer).retryActivityInstance(activityInstId, ActivityResultCodeConstant.RESULT_RETRY);
} else {
String request = currentServer.buildRetryActivityInstanceRequest(activityId, activityInstId, false);
String response = this.engineCall(request);
try {
String result = currentServer.getErrorMessageFromResponse(response);
if (result == null || result.length() > 0)
throw new RemoteException(result);
auditLog(Action.Retry, Entity.ActivityInstance, activityInstId, null);
} catch (XmlException e) {
throw new DataAccessException("Response is not an MDWStatusMessage");
}
}
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class ActivityInstanceDialog method createButtonsForButtonBar.
protected void createButtonsForButtonBar(Composite parent) {
if (mode.equals(Mode.VIEW)) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
return;
}
if (mode.equals(Mode.RETRY)) {
retryButton = createButton(parent, -1, "Retry", false);
retryButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
statusMessage = activity.getProject().getDesignerProxy().retryActivityInstance(activity, activityInstanceVO);
}
});
if (statusMessage == null || statusMessage.trim().length() == 0)
MessageDialog.openInformation(getShell(), "Retry Activity", "Activity instance: " + activityInstanceVO.getId() + " retried");
else if (statusMessage.startsWith("{")) {
try {
JSONObject json = new JSONObject(statusMessage);
StatusMessage status = null;
if (json.has("status"))
status = new StatusMessage(json);
if (status.getCode() == 0)
MessageDialog.openInformation(getShell(), "Retry Activity", "Activity instance: " + activityInstanceVO.getId() + " retried");
else
MessageDialog.openError(getShell(), "Retry Activity", status.getMessage());
} catch (JSONException e1) {
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
} catch (XmlException e1) {
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
}
} else
MessageDialog.openError(getShell(), "Retry Activity", statusMessage);
close();
}
});
if (!activity.getProcess().isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
retryButton.setEnabled(false);
}
if (mode.equals(Mode.SKIP)) {
skipButton = createButton(parent, -1, "Proceed", false);
skipButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
statusMessage = activity.getProject().getDesignerProxy().skipActivityInstance(activity, activityInstanceVO, completionCode);
}
});
if (statusMessage == null || statusMessage.trim().length() == 0)
MessageDialog.openInformation(getShell(), "Skip Activity", "Activity instance: " + activityInstanceVO.getId() + " skipped with completion code: " + completionCode + ".");
if (statusMessage.startsWith("{")) {
try {
JSONObject json = new JSONObject(statusMessage);
StatusMessage status = null;
if (json.has("status"))
status = new StatusMessage(json);
if (status.getCode() == 0)
MessageDialog.openInformation(getShell(), "Skip Activity", "Activity instance: " + activityInstanceVO.getId() + " skipped with completion code: " + completionCode + ".");
else
MessageDialog.openError(getShell(), "Skip Activity", status.getMessage());
} catch (JSONException e1) {
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
} catch (XmlException e1) {
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
}
} else
MessageDialog.openError(getShell(), "Skip Activity", statusMessage);
close();
}
});
if (!activity.getProcess().isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
skipButton.setEnabled(false);
}
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class WorkflowProjectManager method discoverWorkflowApps.
public List<WorkflowApplication> discoverWorkflowApps() throws DiscoveryException {
String urlBase = MdwPlugin.getSettings().getProjectDiscoveryUrl();
if (!urlBase.endsWith("/"))
urlBase += "/";
String ctxRoot = urlBase.endsWith("Discovery/") ? "" : "MDWWeb/";
if (urlBase.indexOf("lxdnd696") >= 0)
// old discovery server
ctxRoot = "MDWExampleWeb/";
String path = urlBase.endsWith("Discovery/") ? "ConfigManagerProjects.xml" : "Services/GetConfigFile?name=ConfigManagerProjects.xml";
String cfgMgrUrl = urlBase + ctxRoot + path;
try {
URL url = new URL(cfgMgrUrl);
HttpHelper httpHelper = new HttpHelper(url);
httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
String xml = httpHelper.get();
ConfigManagerProjectsDocument doc = ConfigManagerProjectsDocument.Factory.parse(xml, Compatibility.namespaceOptions());
return doc.getConfigManagerProjects().getWorkflowAppList();
} catch (XmlException ex) {
PluginMessages.log(ex);
throw new DiscoveryException("Unable to obtain/parse Config Manager info from " + cfgMgrUrl);
} catch (Exception ex) {
throw new DiscoveryException(ex.getMessage(), ex);
}
}
use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.
the class ImportPackagePage method populateTopFolder.
public Folder populateTopFolder(String discoveryUrl, String groupId, boolean latestVersionsOnly, IProgressMonitor progressMonitor) throws Exception {
Folder folder = null;
getImportPackageWizard().getImportPackageSelectPage().clear();
if (discoveryUrl != null || groupId != null) {
if (discoveryUrl != null) {
if (getProject().checkRequiredVersion(6, 0, 13))
folder = new Discoverer(new URL(discoveryUrl), getProject().getHttpHelper(discoveryUrl)).getAssetTopFolder(latestVersionsOnly, progressMonitor);
else
folder = new Discoverer(new URL(discoveryUrl)).getAssetTopFolder(latestVersionsOnly, progressMonitor);
}
if (groupId != null)
folder = new Discoverer(groupId).getAssetTopFolder(latestVersionsOnly, progressMonitor);
if (getProject().isRemote() && getProject().isGitVcs()) {
List<Folder> emptyFolders = removeGitVersionedPackages(folder);
List<Folder> emptyParents = new ArrayList<>();
for (Folder emptyFolder : emptyFolders) {
if (emptyFolder.getParent() instanceof Folder) {
Folder parent = emptyFolder.getParent();
parent.getChildren().remove(emptyFolder);
// go one more level up
if (parent.getChildren().isEmpty() && !emptyParents.contains(parent))
emptyParents.add(parent);
}
}
for (Folder emptyParent : emptyParents) {
if (emptyParent.getParent() instanceof Folder)
(emptyParent.getParent()).getChildren().remove(emptyParent);
}
}
} else {
String filepath = filePathText.getText().trim();
String contents = FileHelper.getFileContents(filepath);
folder = new Folder(filepath);
boolean hasOldImpls = false;
if (contents.trim().startsWith("{")) {
ImporterExporterJson importer = new ImporterExporterJson();
List<PackageVO> packages = importer.importPackages(contents);
for (PackageVO pkg : packages) {
if (getProject().isRemote() && getProject().isGitVcs()) {
for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
if (existingVcs.getName().equals(pkg.getName()))
getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + pkg.getName());
}
}
File aFile = new File(folder, pkg.getName() + " v" + pkg.getVersionString());
ImporterExporterJson jsonExporter = new ImporterExporterJson();
List<PackageVO> pkgs = new ArrayList<>();
pkgs.add(pkg);
JSONObject pkgJson = new JSONObject(jsonExporter.exportPackages(pkgs));
pkgJson.put("name", pkg.getName());
aFile.setContent(pkgJson.toString(2));
folder.addChild(aFile);
}
preselected = folder;
} else {
try {
// try and parse as multiple packages
PackageDocument pkgDoc = PackageDocument.Factory.parse(contents);
QName docElement = new QName("http://mdw.centurylink.com/bpm", "processDefinition");
for (MDWProcessDefinition pkgDef : pkgDoc.getPackage().getProcessDefinitionList()) {
if (getProject().isRemote() && getProject().isGitVcs()) {
for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
if (existingVcs.getName().equals(pkgDef.getPackageName()))
getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + pkgDef.getPackageName());
}
}
if (!hasOldImpls && getProject().isFilePersist() && !getProject().isRemote())
hasOldImpls = checkForOldImplementors(pkgDef);
File aFile = new File(folder, pkgDef.getPackageName() + " v" + pkgDef.getPackageVersion());
aFile.setContent(pkgDef.xmlText(new XmlOptions().setSaveOuter().setSaveSyntheticDocumentElement(docElement)));
folder.addChild(aFile);
}
preselected = folder;
} catch (XmlException ex) {
// unparseable -- assume single package
if (getProject().isRemote() && getProject().isGitVcs()) {
MDWProcessDefinition procDef = ProcessDefinitionDocument.Factory.parse(contents, Compatibility.namespaceOptions()).getProcessDefinition();
for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
if (existingVcs.getName().equals(procDef.getPackageName()))
getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + procDef.getPackageName());
}
}
if (getProject().isFilePersist() && !getProject().isRemote())
hasOldImpls = checkForOldImplementors(ProcessDefinitionDocument.Factory.parse(contents, Compatibility.namespaceOptions()).getProcessDefinition());
File file = new File(folder, filepath);
file.setContent(contents);
folder.addChild(file);
preselected = file;
}
}
getImportPackageWizard().setHasOldImplementors(hasOldImpls);
}
return folder;
}
use of org.apache.xmlbeans.XmlException in project knime-core by knime.
the class PMMLPortObject method loadFrom.
/**
* Initializes the pmml port object based on the xml input stream.
* @param spec the referring spec of this object
* @param is the pmml input stream
* @throws IOException if the file cannot be found
* @throws XmlException if something goes wrong during reading
*/
public void loadFrom(final PMMLPortObjectSpec spec, final InputStream is) throws IOException, XmlException {
// disallow close in the factory -- we had indeterministic behavior
// where close was called more than once (which should be OK) but as
// the argument input stream is a NonClosableZipInput, which delegates
// close to closeEntry(), we have to make sure that close is only
// called once.
// TODO: The document is read twice here. Could we "probe" into the file to check the version?
XmlObject xmlDoc = null;
Thread current = Thread.currentThread();
ClassLoader oldLoader = current.getContextClassLoader();
current.setContextClassLoader(PMMLDocument.class.getClassLoader());
try (NonClosableInputStream nonClosableIn = new NonClosableInputStream(is)) {
xmlDoc = XmlObject.Factory.parse(nonClosableIn);
} finally {
current.setContextClassLoader(oldLoader);
// call only once (see above)
is.close();
}
if (xmlDoc instanceof PMMLDocument) {
m_pmmlDoc = (PMMLDocument) xmlDoc;
} else {
/* Try to recover when reading a PMML 3.x/4.0 document that
* was produced by KNIME by just replacing the PMML version and
* namespace. */
if (PMMLUtils.isOldKNIMEPMML(xmlDoc) || PMMLUtils.is4_1PMML(xmlDoc)) {
try {
String updatedPMML = PMMLUtils.getUpdatedVersionAndNamespace(xmlDoc);
/* Parse the modified document and assign it to a
* PMMLDocument.*/
m_pmmlDoc = PMMLDocument.Factory.parse(updatedPMML);
} catch (Exception e) {
throw new RuntimeException("Parsing of PMML v 3.x/4.0 document failed.", e);
}
LOGGER.info("KNIME produced PMML 3.x/4.0 converted to PMML 4.1.");
} else {
throw new RuntimeException("Parsing of PMML v 3.x/4.0 document failed.");
}
}
m_spec = spec;
}
Aggregations