Search in sources :

Example 6 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method remoteRetrieveProcess.

public ProcessVO remoteRetrieveProcess(String name, int version) throws DataAccessException {
    try {
        String path = "Processes?name=" + name;
        if (version != 0)
            path += "&version=" + RuleSetVO.formatVersion(version);
        String pkgXml = ((RestfulServer) currentServer).invokeResourceService(path);
        ProcessImporter importer = DataAccess.getProcessImporter(getDatabaseSchemaVersion());
        PackageVO pkg = importer.importPackage(pkgXml);
        ProcessVO process = pkg.getProcesses().get(0);
        process.setPackageName(pkg.getName());
        process.setPackageVersion(pkg.getVersionString());
        if (isVcsPersist())
            process.setId(currentServer.getVersionControl().getId(getLogicalFile(process)));
        return process;
    } catch (IOException ex) {
        throw new DataAccessException("Error retrieving process: " + name + " v" + RuleSetVO.formatVersion(version), ex);
    }
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) IOException(java.io.IOException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 7 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException 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");
        }
    }
}
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 8 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method createRemoteAccess.

private RemoteAccess createRemoteAccess(String logicalServerName) throws DataAccessException, RemoteException {
    // and hence requires the remote server to be running
    for (Server s : serverList) {
        if (logicalServerName.equals(s.getApplicationName())) {
            String curenv = currentServer.getEnvironment();
            String senv = s.getEnvironment();
            if (curenv == null)
                curenv = "";
            if (senv == null)
                senv = "";
            if (curenv.equals(senv)) {
                String remoteDbInfo = s.getDatabaseUrl();
                if (remoteDbInfo == null)
                    remoteDbInfo = getDatabaseCredentialFromServer(s.getServerUrl());
                return new RemoteAccess(logicalServerName, remoteDbInfo);
            }
        }
    }
    if (currentServer.getServerUrl() != null) {
        String remoteServerUrl = this.getStringProperty(PropertyNames.MDW_REMOTE_SERVER + "." + logicalServerName);
        if (remoteServerUrl == null)
            throw new DataAccessException("Cannot find translation for logical server name " + logicalServerName);
        String remoteDbInfo = this.getDatabaseCredentialFromServer(remoteServerUrl);
        return new RemoteAccess(logicalServerName, remoteDbInfo);
    }
    throw new DataAccessException("Cannot find translation for logical server name " + logicalServerName);
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) RemoteAccess(com.centurylink.mdw.dataaccess.RemoteAccess) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 9 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method executeUnitTest.

public String executeUnitTest(String message, Map<String, String> headers) throws DataAccessException {
    try {
        HttpHelper httpHelper = currentServer.getHttpHelper(currentServer.getMdwWebUrl() + "/Services/com/centurylink/mdw/testing/AutomatedTests/unit");
        httpHelper.setConnectTimeout(getConnectTimeout());
        httpHelper.setReadTimeout(getReadTimeout());
        httpHelper.setHeaders(headers);
        String res = httpHelper.post(message);
        return res == null ? null : res.trim();
    } catch (IOException ex) {
        throw new DataAccessException(0, IOEXCEPTION, ex);
    }
}
Also used : IOException(java.io.IOException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 10 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getDocumentContent.

public String getDocumentContent(DocumentReference docref, String type) throws RemoteException, DataAccessException {
    if (type.equals(Object.class.getName())) {
        if (currentServer.getServerUrl() != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("<_mdw_document_content>");
            sb.append("<document_id>").append(docref.getDocumentId().toString()).append("</document_id>");
            sb.append("<type>").append(type).append("</type>");
            sb.append("</_mdw_document_content>");
            String result = this.engineCall(sb.toString());
            if (result.startsWith(ERROR))
                throw new DataAccessException(result);
            return result;
        } else {
            return rtinfo.getDocument(docref.getDocumentId()).getContent();
        }
    } else {
        if (docref.getServer() != null) {
            RemoteAccess rao = remoteAccess.get(docref.getServer());
            if (rao == null) {
                rao = createRemoteAccess(docref.getServer());
                remoteAccess.put(docref.getServer(), rao);
            }
            return rao.getRuntimeDataAccess().getDocument(docref.getDocumentId()).getContent();
        } else {
            return rtinfo.getDocument(docref.getDocumentId()).getContent();
        }
    }
}
Also used : RemoteAccess(com.centurylink.mdw.dataaccess.RemoteAccess) PortableRemoteObject(javax.rmi.PortableRemoteObject) JSONObject(org.json.JSONObject) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)61 IOException (java.io.IOException)32 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)25 JSONException (org.json.JSONException)21 XmlException (org.apache.xmlbeans.XmlException)19 RemoteException (java.rmi.RemoteException)18 JSONObject (org.json.JSONObject)12 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)10 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)10 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)8 FileNotFoundException (java.io.FileNotFoundException)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)6 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 Graph (com.centurylink.mdw.designer.display.Graph)4 SubGraph (com.centurylink.mdw.designer.display.SubGraph)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)4 File (java.io.File)4 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)3