Search in sources :

Example 81 with XmlException

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();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) XmlException(org.apache.xmlbeans.XmlException) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 82 with XmlException

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();
}
Also used : UserActionVO(com.centurylink.mdw.model.value.user.UserActionVO) HashMap(java.util.HashMap) VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) RemoteException(java.rmi.RemoteException) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 83 with XmlException

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();
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) Shell(org.eclipse.swt.widgets.Shell) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) XmlException(org.apache.xmlbeans.XmlException) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 84 with XmlException

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();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) QName(javax.xml.namespace.QName) XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) XmlObject(org.apache.xmlbeans.XmlObject) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 85 with XmlException

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);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONException(org.json.JSONException) IOException(java.io.IOException) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage) SocketTimeoutException(java.net.SocketTimeoutException) JSONObject(org.json.JSONObject) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) XmlException(org.apache.xmlbeans.XmlException) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) RemoteException(java.rmi.RemoteException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

XmlException (org.apache.xmlbeans.XmlException)112 XmlObject (org.apache.xmlbeans.XmlObject)45 IOException (java.io.IOException)35 DecodingException (org.n52.svalbard.decode.exception.DecodingException)19 EncodingException (org.n52.svalbard.encode.exception.EncodingException)17 POIXMLException (org.apache.poi.POIXMLException)15 InputStream (java.io.InputStream)11 ArrayList (java.util.ArrayList)10 XmlCursor (org.apache.xmlbeans.XmlCursor)10 XmlOptions (org.apache.xmlbeans.XmlOptions)10 OpenXML4JException (org.apache.poi.openxml4j.exceptions.OpenXML4JException)8 POIXMLDocumentPart (org.apache.poi.POIXMLDocumentPart)7 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)7 Geometry (org.locationtech.jts.geom.Geometry)6 Document (org.w3c.dom.Document)6 Node (org.w3c.dom.Node)6 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 File (java.io.File)5