Search in sources :

Example 1 with RemoteAccess

use of com.centurylink.mdw.dataaccess.RemoteAccess 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 2 with RemoteAccess

use of com.centurylink.mdw.dataaccess.RemoteAccess 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)

Example 3 with RemoteAccess

use of com.centurylink.mdw.dataaccess.RemoteAccess in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getProcessDefinition.

public ProcessVO getProcessDefinition(String procname, int version) throws RemoteException, DataAccessException {
    if (procname.indexOf(RemoteAccess.REMOTE_NAME_DELIMITER) > -1) {
        int k = procname.indexOf(RemoteAccess.REMOTE_NAME_DELIMITER);
        String properProcname = procname.substring(0, k);
        String logicalServerName = procname.substring(k + 1);
        RemoteAccess rao = remoteAccess.get(logicalServerName);
        if (rao == null) {
            rao = createRemoteAccess(logicalServerName);
            remoteAccess.put(logicalServerName, rao);
        }
        ProcessLoader procLoader = rao.getLoader();
        ProcessVO procdef = procLoader.getProcessBase(properProcname, version);
        procdef.setRemoteServer(logicalServerName);
        return procdef;
    } else {
        return loader.getProcessBase(procname, version);
    }
}
Also used : RemoteAccess(com.centurylink.mdw.dataaccess.RemoteAccess) ProcessLoader(com.centurylink.mdw.dataaccess.ProcessLoader) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Aggregations

RemoteAccess (com.centurylink.mdw.dataaccess.RemoteAccess)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 ProcessLoader (com.centurylink.mdw.dataaccess.ProcessLoader)1 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)1 Server (com.centurylink.mdw.designer.utils.Server)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 PortableRemoteObject (javax.rmi.PortableRemoteObject)1 JSONObject (org.json.JSONObject)1