Search in sources :

Example 1 with DataAccessException

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

the class DesignerDataAccess method updateVariableInstanceThruServer.

public void updateVariableInstanceThruServer(VariableInstanceInfo var, String value, boolean isDocument) throws RemoteException, DataAccessException {
    if (this.dbSchemaVersion < 5000 && isDocument) {
        // temporary work-around by updating database directly
        // need to enhance 4.5 code to handle document variables
        DocumentReference docref = new DocumentReference(var.getStringValue());
        rtinfo.updateDocumentContent(docref.getDocumentId(), value);
    } else {
        DomDocument domdoc = new DomDocument();
        FormatDom fmter = new FormatDom();
        domdoc.getRootNode().setName("_mdw_update_variable");
        MbengNode node = domdoc.newNode("var_value", value, "", ' ');
        domdoc.getRootNode().appendChild(node);
        if (var.getInstanceId() == null) {
            node = domdoc.newNode("var_name", var.getName(), "", ' ');
            domdoc.getRootNode().appendChild(node);
            node = domdoc.newNode("proc_inst_id", var.getStringValue(), "", ' ');
            domdoc.getRootNode().appendChild(node);
            String res = this.engineCall(fmter.format(domdoc));
            if (res.startsWith("OK:")) {
                String[] vs = res.split(":");
                var.setInstanceId(new Long(vs[1]));
                if (vs.length == 3) {
                    DocumentReference docref = new DocumentReference(new Long(vs[2]), null);
                    var.setStringValue(docref.toString());
                }
            } else
                throw new DataAccessException(res);
        } else {
            node = domdoc.newNode("var_inst_id", var.getInstanceId().toString(), "", ' ');
            domdoc.getRootNode().appendChild(node);
            String res = this.engineCall(fmter.format(domdoc));
            if (!"OK".equals(res))
                throw new DataAccessException(res);
        }
    }
    auditLog(Action.Create, Entity.VariableInstance, var.getInstanceId(), var.getName());
}
Also used : FormatDom(com.qwest.mbeng.FormatDom) MbengNode(com.qwest.mbeng.MbengNode) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) DomDocument(com.qwest.mbeng.DomDocument)

Example 2 with DataAccessException

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

the class DesignerDataAccess method sendRestfulMessage.

private String sendRestfulMessage(String mdwWebUrl, String message, Map<String, String> headers) throws DataAccessException {
    try {
        HttpHelper httpHelper = currentServer.getHttpHelper(mdwWebUrl + "/Services/REST");
        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 3 with DataAccessException

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

the class DesignerDataAccess method updateVariableInstanceInDb.

public void updateVariableInstanceInDb(VariableInstanceInfo varInstInfo, String newValue, boolean isDocument) throws DataAccessException {
    // needs a separate db connection for some reason?
    DatabaseAccess db = new DatabaseAccess(currentServer.getDatabaseUrl());
    try {
        RuntimeDataAccess runtimeDao = DataAccess.getRuntimeDataAccess(dbSchemaVersion, dbSupportedSchemaVersion, db, getVariableTypes());
        db.openConnection();
        if (isDocument) {
            DocumentReference docRef = (DocumentReference) varInstInfo.getData();
            runtimeDao.updateDocumentContent(docRef.getDocumentId(), newValue);
        } else {
            varInstInfo.setStringValue(newValue);
            runtimeDao.updateVariableInstance(varInstInfo);
        }
    } catch (SQLException ex) {
        throw new DataAccessException(-1, ex.getMessage(), ex);
    } finally {
        db.closeConnection();
    }
    auditLog(Action.Change, Entity.VariableInstance, varInstInfo.getInstanceId(), varInstInfo.getName());
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) DatabaseAccess(com.centurylink.mdw.dataaccess.DatabaseAccess) SQLException(java.sql.SQLException) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 4 with DataAccessException

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

the class DesignerDataAccess method sendSoapMessage.

private String sendSoapMessage(String mdwWebUrl, String message, Map<String, String> headers) throws DataAccessException {
    try {
        HttpHelper httpHelper = currentServer.getHttpHelper(mdwWebUrl + "/Services/SOAP");
        httpHelper.setHeaders(headers);
        httpHelper.setConnectTimeout(getConnectTimeout());
        httpHelper.setReadTimeout(getReadTimeout());
        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 5 with DataAccessException

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

the class DesignerDataAccess method launchBrowser.

public void launchBrowser(String url) throws DataAccessException, RemoteException {
    String vUrl = url;
    if (vUrl.startsWith("prop:")) {
        String property = vUrl.substring(5);
        vUrl = getStringProperty(property);
    } else if (vUrl.startsWith("/")) {
        if (currentServer.getServerUrl() == null)
            throw new DataAccessException("No server specification to translate relative URL");
        if (vUrl.startsWith("/MDWWeb")) {
            if (currentServer.getMdwWebUrl() != null)
                vUrl = currentServer.getMdwWebUrl() + vUrl.substring(7);
        } else if (vUrl.startsWith("/MDWTaskManagerWeb")) {
            if (currentServer.getTaskManagerUrl() != null)
                vUrl = currentServer.getTaskManagerUrl() + vUrl.substring(18);
        } else {
            String serverurl = currentServer.getServerUrl();
            int i1 = serverurl.indexOf("//");
            int i2 = serverurl.indexOf('/', i1 + 2);
            if (i2 < 0)
                serverurl = HTTP + serverurl.substring(i1);
            else
                serverurl = HTTP + serverurl.substring(i1, i2);
            vUrl = serverurl + vUrl;
        }
    } else if (!vUrl.startsWith("http")) {
        File file = new File(vUrl);
        if (!file.exists())
            throw new DataAccessException("File does not exist: " + vUrl);
    }
    try {
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + vUrl);
    } catch (Exception ex) {
        throw new DataAccessException(0, "cannot launch browser:\n" + ex.getLocalizedMessage(), ex);
    }
}
Also used : File(java.io.File) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) JSONException(org.json.JSONException) SQLException(java.sql.SQLException) MDWException(com.centurylink.mdw.common.exception.MDWException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) PropertyException(com.centurylink.mdw.common.exception.PropertyException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) NamingException(javax.naming.NamingException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CreateException(javax.ejb.CreateException)

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