use of com.centurylink.mdw.common.exception.TranslationException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getVariableInfo.
/**
* Must be called from the UI thread.
*/
public VariableTypeVO getVariableInfo(final VariableInstanceInfo varInstInfo) {
String varType = varInstInfo.getType();
VariableTranslator varTrans = getVariableTranslator(varType);
final VariableTypeVO varTypeVO = new VariableTypeVO(0L, varType, varTrans == null ? null : varTrans.getClass().getName());
if (varInstInfo.getStringValue() != null && varTypeVO.isJavaObjectType()) {
BusyIndicator.showWhile(MdwPlugin.getShell().getDisplay(), new Runnable() {
public void run() {
DocumentReference docRef = new DocumentReference(varInstInfo.getStringValue());
try {
Object obj = new JavaObjectTranslator().realToObject(getDocument(docRef).getContent());
varTypeVO.setVariableType(obj.getClass().getName());
varTypeVO.setUpdateable(obj instanceof SelfSerializable);
} catch (TranslationException ex) {
if (MdwPlugin.getSettings().isLogConnectErrors())
PluginMessages.log(ex);
try {
if (!project.checkRequiredVersion(6, 1, 1)) {
String path = "DocumentValue?format=xml&id=" + docRef.getDocumentId() + "&type=" + varTypeVO.getVariableType();
String resp = getRestfulServer().invokeResourceService(path);
Resource res = Resource.Factory.parse(resp, Compatibility.namespaceOptions());
for (Parameter param : res.getParameterList()) {
if ("className".equals(param.getName()))
varTypeVO.setVariableType(param.getStringValue());
else if ("isUpdateable".equals(param.getName()))
varTypeVO.setUpdateable(Boolean.parseBoolean(param.getStringValue()));
}
}
} catch (Exception ex2) {
throw new RuntimeException(ex2.getMessage(), ex2);
}
}
}
});
}
return varTypeVO;
}
use of com.centurylink.mdw.common.exception.TranslationException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getVariableValue.
/**
* Must be called from the UI thread.
*/
public String getVariableValue(final Shell shell, final VariableInstanceInfo varInstInfo, final boolean tryServer) {
final StringBuilder valueHolder = new StringBuilder();
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
String value = varInstInfo.getStringValue();
if (value != null) {
boolean isDoc = isDocumentVariable(varInstInfo.getType(), value);
if (isDoc) {
DocumentReference docRef = new DocumentReference(value);
DocumentVO docVo = getDocument(docRef);
if (docVo != null) {
value = docVo.getContent();
boolean isJavaObj = Object.class.getName().equals(varInstInfo.getType());
if (isJavaObj) {
try {
value = new JavaObjectTranslator().realToObject(value).toString();
} catch (TranslationException ex) {
if (MdwPlugin.getSettings().isLogConnectErrors())
PluginMessages.log(ex);
if (tryServer) {
try {
String path = "DocumentValues/" + docRef.getDocumentId();
if (!project.checkRequiredVersion(6, 1, 1))
path = "DocumentValue?id=" + docRef.getDocumentId() + "&type=" + varInstInfo.getType() + "&format=text";
value = getRestfulServer().invokeResourceService(path);
} catch (Exception ex2) {
throw new RuntimeException(ex2.getMessage(), ex2);
}
} else {
value = "<Double-click to retrieve>";
}
}
}
}
}
valueHolder.append(value);
}
}
});
return valueHolder.toString();
}
Aggregations