]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentServerUtils.java
Improvements to resolving primitive properties in document server
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / DocumentServerUtils.java
index 4821bbd1ca0e4c48a1cbe71210d1e53acb2c20be..5e1f5cc30e798aff45343b8f8c5f4483b6d8a9cc 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -324,8 +325,24 @@ public class DocumentServerUtils {
                        for(Variable attrib : statics) {
                                String name = attrib.getName(graph);
                                try {
-                                   Object value = DocumentServerUtils.getValue(graph, attrib);
-                                   object.addJSONField(name, value);
+                                       if (name.equals(NodeRequest.PROPERTY_VALUE_EXCEPTIONS)) {
+                                       @SuppressWarnings("unchecked")
+                                               Map<String, Exception> exceptions = (Map<String, Exception>)DocumentServerUtils.getValue(graph, attrib);
+                                       
+                                       List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+                                           if(errorList == null)
+                                               errorList = new ArrayList<String>();
+                                           
+                                   for (Map.Entry<String, Exception> entry : exceptions.entrySet()) {
+                                       String errorMessage = NodeRequestUtils.formatErrorMessage(entry.getKey(), entry.getValue());
+                                       errorList.add(errorMessage);
+                                   }
+                                       object.addJSONField(NodeRequest.ERRORS, errorList);
+                                       
+                                   } else {
+                                               Object value = DocumentServerUtils.getValue(graph, attrib);
+                                           object.addJSONField(name, value);
+                                   }
                                } catch (Throwable t) {
                                    List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
                                    if(errorList == null)