Search in sources :

Example 1 with DocumentVO

use of com.centurylink.mdw.model.value.variable.DocumentVO 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();
}
Also used : JavaObjectTranslator(com.centurylink.mdw.common.translator.impl.JavaObjectTranslator) DocumentVO(com.centurylink.mdw.model.value.variable.DocumentVO) TranslationException(com.centurylink.mdw.common.exception.TranslationException) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference) 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)

Example 2 with DocumentVO

use of com.centurylink.mdw.model.value.variable.DocumentVO in project mdw-designer by CenturyLinkCloud.

the class RuntimeDataAccessRest method getDocument.

public DocumentVO getDocument(Long documentId) throws DataAccessException {
    try {
        String pathWithArgs = "DocumentValues/" + documentId;
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "DocumentValue?format=json&id=" + documentId;
        String response = getServer().invokeResourceServiceRaw(pathWithArgs);
        DocumentVO docVO = new DocumentVO();
        docVO.setContent(response);
        docVO.setDocumentId(documentId);
        return docVO;
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DocumentVO(com.centurylink.mdw.model.value.variable.DocumentVO) IOException(java.io.IOException) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

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