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());
}
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);
}
}
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());
}
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);
}
}
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);
}
}
Aggregations