Search in sources :

Example 1 with Resource

use of com.centurylink.mdw.service.Resource 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;
}
Also used : JavaObjectTranslator(com.centurylink.mdw.common.translator.impl.JavaObjectTranslator) Resource(com.centurylink.mdw.service.Resource) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator) TranslationException(com.centurylink.mdw.common.exception.TranslationException) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) SelfSerializable(com.centurylink.mdw.common.translator.SelfSerializable) Parameter(com.centurylink.mdw.service.Parameter) JSONObject(org.json.JSONObject) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Aggregations

AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 SelfSerializable (com.centurylink.mdw.common.translator.SelfSerializable)1 VariableTranslator (com.centurylink.mdw.common.translator.VariableTranslator)1 JavaObjectTranslator (com.centurylink.mdw.common.translator.impl.JavaObjectTranslator)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)1 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)1 Parameter (com.centurylink.mdw.service.Parameter)1 Resource (com.centurylink.mdw.service.Resource)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ZipException (java.util.zip.ZipException)1 XmlException (org.apache.xmlbeans.XmlException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1