Search in sources :

Example 86 with XmlException

use of org.apache.xmlbeans.XmlException 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");
        }
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 87 with XmlException

use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.

the class RuntimeDataAccessRest method deleteProcessInstances.

public int deleteProcessInstances(List<Long> processInstanceIds) throws DataAccessException {
    try {
        List<ProcessInstanceVO> instances = new ArrayList<ProcessInstanceVO>();
        for (Long id : processInstanceIds) instances.add(new ProcessInstanceVO(id));
        ProcessList processList = new ProcessList(ProcessList.PROCESS_INSTANCES, instances);
        if (getServer().getSchemaVersion() >= 6000) {
            try {
                getServer().delete("Processes", processList.getJson().toString(2));
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Unable to connect to " + getServer().getServiceUrl(), ex);
            }
        } else {
            ActionRequestMessage actionRequest = new ActionRequestMessage();
            actionRequest.setAction("DeleteProcessInstances");
            actionRequest.addParameter("appName", "MDW Designer");
            JSONObject msgJson = actionRequest.getJson();
            msgJson.put(processList.getJsonName(), processList.getJson());
            invokeActionService(msgJson.toString(2));
        }
        return processList.getCount();
    } catch (XmlException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    } catch (JSONException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) ActionRequestMessage(com.centurylink.mdw.common.service.types.ActionRequestMessage) JSONException(org.json.JSONException) IOException(java.io.IOException) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 88 with XmlException

use of org.apache.xmlbeans.XmlException in project mdw-designer by CenturyLinkCloud.

the class NewTaskTemplateWizard method performFinish.

@Override
public boolean performFinish() {
    TaskTemplate taskTemplate = (TaskTemplate) getWorkflowAsset();
    try {
        TaskTemplateDocument doc;
        if (isImportFile()) {
            // load from selected file
            doc = TaskTemplateDocument.Factory.parse(new File(getImportFilePath()));
            com.centurylink.mdw.task.TaskTemplate template = doc.getTaskTemplate();
            // selection)
            if (template.getLogicalId() == null)
                throw new XmlException("Task template missing logicalId");
            else if (template.getCategory() == null)
                throw new XmlException("Task template missing category");
            else if (template.getName() == null || template.getName().isEmpty())
                throw new XmlException("Task template missing name");
        } else {
            doc = TaskTemplateDocument.Factory.newInstance();
            com.centurylink.mdw.task.TaskTemplate template = doc.addNewTaskTemplate();
            String taskName = taskTemplate.getName().substring(0, taskTemplate.getName().length() - 5);
            template.setLogicalId(taskName.replace(' ', '_'));
            template.setCategory("GEN");
            template.setName(taskName);
            if ("AUTOFORM".equals(taskTemplate.getLanguage())) {
                Attribute form = template.addNewAttribute();
                form.setName("FormName");
                form.setStringValue("Autoform");
            }
        }
        XmlOptions xmlOptions = new XmlOptions().setSaveAggressiveNamespaces();
        xmlOptions.setSavePrettyPrint().setSavePrettyPrintIndent(2);
        taskTemplate.setContent(doc.xmlText(xmlOptions));
        String templateName = taskTemplate.getName();
        taskTemplate.setTaskVO(new TaskVO(doc.getTaskTemplate()));
        taskTemplate.setName(templateName);
        taskTemplate.getTaskVO().setPackageName(taskTemplate.getPackage().getName());
        DesignerProxy designerProxy = taskTemplate.getProject().getDesignerProxy();
        designerProxy.createNewTaskTemplate(taskTemplate);
        if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
            taskTemplate.openFile(new NullProgressMonitor());
            taskTemplate.addElementChangeListener(taskTemplate.getProject());
            taskTemplate.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, taskTemplate);
            taskTemplate.setVersion(1);
            taskTemplate.fireElementChangeEvent(ChangeType.VERSION_CHANGE, taskTemplate);
            DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), taskTemplate);
            return true;
        } else {
            return false;
        }
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Create " + taskTemplate.getTitle(), taskTemplate.getProject());
        return false;
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TaskTemplateDocument(com.centurylink.mdw.task.TaskTemplateDocument) Attribute(com.centurylink.mdw.task.Attribute) XmlOptions(org.apache.xmlbeans.XmlOptions) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) XmlException(org.apache.xmlbeans.XmlException) XmlException(org.apache.xmlbeans.XmlException) File(java.io.File) TaskVO(com.centurylink.mdw.model.value.task.TaskVO)

Example 89 with XmlException

use of org.apache.xmlbeans.XmlException in project carbon-business-process by wso2.

the class BPELServerConfiguration method loadBPELServerConfigurationFile.

private void loadBPELServerConfigurationFile() {
    String carbonConfigDirPath = CarbonUtils.getCarbonConfigDirPath();
    String bpsConfigPath = carbonConfigDirPath + File.separator + BPELConstants.BPEL_CONFIGURATION_FILE_NAME;
    File bpsConfigFile = new File(bpsConfigPath);
    if (!bpsConfigFile.exists()) {
        log.warn("Cannot find BPEL configuration file: " + bpsConfigPath + " Default values are used.");
        return;
    }
    try {
        this.bpsConfigDocument = WSO2BPSDocument.Factory.parse(bpsConfigFile);
        populateFields();
    } catch (XmlException e) {
        String errMsg = "BPS configuration parsing exception. " + BPELConstants.BPEL_CONFIGURATION_FILE_NAME + " can be found at " + bpsConfigPath;
        log.error(errMsg);
        throw new RuntimeException(errMsg, e);
    } catch (IOException e) {
        String errMsg = "Error reading bps configuration file." + BPELConstants.BPEL_CONFIGURATION_FILE_NAME + " can be found at " + bpsConfigPath;
        log.error(errMsg);
        throw new RuntimeException(errMsg, e);
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) IOException(java.io.IOException) File(java.io.File)

Example 90 with XmlException

use of org.apache.xmlbeans.XmlException in project sw360portal by sw360.

the class DocxGenerator method generateOutputFile.

@Override
public byte[] generateOutputFile(Collection<LicenseInfoParsingResult> projectLicenseInfoResults, String projectName, String projectVersion, String licenseInfoHeaderText) throws SW360Exception {
    ByteArrayOutputStream docxOutputStream = new ByteArrayOutputStream();
    Optional<byte[]> docxTemplateFile = CommonUtils.loadResource(DocxGenerator.class, DOCX_TEMPLATE_FILE);
    if (docxTemplateFile.isPresent()) {
        try {
            XWPFDocument xwpfDocument = new XWPFDocument(new ByteArrayInputStream(docxTemplateFile.get()));
            switch(getOutputVariant()) {
                case DISCLOSURE:
                    fillDocument(xwpfDocument, projectLicenseInfoResults, projectName, projectVersion, licenseInfoHeaderText, false);
                    break;
                case REPORT:
                    fillDocument(xwpfDocument, projectLicenseInfoResults, projectName, projectVersion, licenseInfoHeaderText, true);
                    break;
                default:
                    throw new IllegalArgumentException("Unknown generator variant type: " + getOutputVariant());
            }
            xwpfDocument.write(docxOutputStream);
            docxOutputStream.close();
        } catch (XmlException e) {
            throw new SW360Exception("Got XmlException while generating docx document: " + e.getMessage());
        } catch (IOException e) {
            throw new SW360Exception("Got IOException when generating docx document: " + e.getMessage());
        } catch (TException e) {
            throw new SW360Exception("Error reading sw360 licenses: " + e.getMessage());
        }
        return docxOutputStream.toByteArray();
    } else {
        throw new SW360Exception("Could not load the template for xwpf document: " + DOCX_TEMPLATE_FILE);
    }
}
Also used : TException(org.apache.thrift.TException) ByteArrayInputStream(java.io.ByteArrayInputStream) XmlException(org.apache.xmlbeans.XmlException) XWPFDocument(org.apache.poi.xwpf.usermodel.XWPFDocument) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

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