incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1204385 - in /incubator/isis/trunk/framework/viewer/json: json-applib/ json-applib/src/main/java/org/apache/isis/viewer/json/applib/ json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ json-applib/src/main/java/org/...
Date Mon, 21 Nov 2011 07:51:41 GMT
Author: danhaywood
Date: Mon Nov 21 07:51:40 2011
New Revision: 1204385

URL: http://svn.apache.org/viewvc?rev=1204385&view=rev
Log:
ISIS-109: more on json viewer (~v0.52 of RO spec)

Added:
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/AbstractDomainObjectRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java
Modified:
    incubator/isis/trunk/framework/viewer/json/json-applib/pom.xml
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RepresentationType.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RestfulMediaType.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectResource.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ListRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/pom.xml?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/pom.xml (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/pom.xml Mon Nov 21 07:51:40 2011
@@ -58,13 +58,6 @@
 		</dependency>
 		
         <dependency>
-	        <groupId>net.sf.json-lib</groupId>
-	        <artifactId>json-lib</artifactId>
-	        <type>jar</type>
-	        <classifier>jdk15</classifier>
-	        <scope>compile</scope>
-	    </dependency>
-        <dependency>
             <groupId>org.jdom</groupId>
             <artifactId>jdom</artifactId>
         </dependency>

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -18,11 +18,7 @@
  */
 package org.apache.isis.viewer.json.applib;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringReader;
 import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -33,28 +29,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import net.sf.json.JSON;
-import net.sf.json.JSONNull;
-import net.sf.json.JSONSerializer;
-import net.sf.json.xml.XMLSerializer;
-
 import org.apache.isis.viewer.json.applib.blocks.LinkRepresentation;
-import org.apache.isis.viewer.json.applib.util.JsonMapper;
 import org.apache.isis.viewer.json.applib.util.JsonNodeUtils;
 import org.apache.isis.viewer.json.applib.util.UrlEncodingUtils;
 import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.node.ArrayNode;
 import org.codehaus.jackson.node.JsonNodeFactory;
 import org.codehaus.jackson.node.NullNode;
 import org.codehaus.jackson.node.ObjectNode;
 import org.codehaus.jackson.node.POJONode;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.XMLOutputter;
-import org.jdom.xpath.XPath;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RepresentationType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RepresentationType.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RepresentationType.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RepresentationType.java
Mon Nov 21 07:51:40 2011
@@ -28,6 +28,7 @@ import org.apache.isis.viewer.json.appli
 import org.apache.isis.viewer.json.applib.domainobjects.ObjectCollectionRepresentation;
 import org.apache.isis.viewer.json.applib.domainobjects.ObjectPropertyRepresentation;
 import org.apache.isis.viewer.json.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.json.applib.domainobjects.TransientDomainObjectRepresentation;
 import org.apache.isis.viewer.json.applib.domaintypes.TypeActionResultRepresentation;
 import org.apache.isis.viewer.json.applib.domaintypes.DomainTypeRepresentation;
 import org.apache.isis.viewer.json.applib.domaintypes.TypeListRepresentation;
@@ -47,6 +48,7 @@ public enum RepresentationType {
     LIST(RestfulMediaType.APPLICATION_JSON_LIST, ListRepresentation.class),
     SCALAR_VALUE(RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, ScalarValueRepresentation.class),
     DOMAIN_OBJECT(RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, DomainObjectRepresentation.class),
+    TRANSIENT_DOMAIN_OBJECT(RestfulMediaType.APPLICATION_JSON_TRANSIENT_DOMAIN_OBJECT, TransientDomainObjectRepresentation.class),
     OBJECT_PROPERTY(RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, ObjectPropertyRepresentation.class),
     OBJECT_COLLECTION(RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, ObjectCollectionRepresentation.class),
     OBJECT_ACTION(RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, ObjectActionRepresentation.class),

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RestfulMediaType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RestfulMediaType.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RestfulMediaType.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/RestfulMediaType.java
Mon Nov 21 07:51:40 2011
@@ -31,23 +31,24 @@ public final class RestfulMediaType {
 
     private static final String BASE = MediaType.APPLICATION_JSON + ";profile=urn:org.restfulobjects/";
     
-    public final static String APPLICATION_JSON_HOME_PAGE = BASE + "homepage"+ "";
-    public final static String APPLICATION_JSON_USER = BASE + "user"+ "";
-    public final static String APPLICATION_JSON_CAPABILITIES = BASE + "capabilities"+ "";
-    public final static String APPLICATION_JSON_LIST = BASE + "list"+ "";
-    public final static String APPLICATION_JSON_SCALAR_VALUE = BASE + "scalarvalue"+ "";
-    public final static String APPLICATION_JSON_DOMAIN_OBJECT = BASE + "domainobject"+ "";
-    public final static String APPLICATION_JSON_OBJECT_PROPERTY = BASE + "objectproperty"+
"";
-    public final static String APPLICATION_JSON_OBJECT_COLLECTION = BASE + "objectcollection"+
"";
-    public final static String APPLICATION_JSON_OBJECT_ACTION = BASE + "objectaction"+ "";
-    public final static String APPLICATION_JSON_ACTION_RESULT = BASE + "actionresult"+ "";
-    public final static String APPLICATION_JSON_TYPE_LIST = BASE + "typelist"+ "";
-    public final static String APPLICATION_JSON_DOMAIN_TYPE = BASE + "domaintype"+ "";
-    public final static String APPLICATION_JSON_TYPE_ACTION_RESULT = BASE + "typeactionresult"+
"";
-    public final static String APPLICATION_JSON_PROPERTY_DESCRIPTION = BASE + "propertydescription"+
"";
-    public final static String APPLICATION_JSON_COLLECTION_DESCRIPTION = BASE + "collectiondescription"+
"";
-    public final static String APPLICATION_JSON_ACTION_DESCRIPTION = BASE + "actiondescription"+
"";
-    public final static String APPLICATION_JSON_ACTION_PARAMETER_DESCRIPTION = BASE + "actionparameterdescription"+
""; 
-    public final static String APPLICATION_JSON_ERROR = BASE + "error"+ "";
+    public final static String APPLICATION_JSON_HOME_PAGE = BASE + "homepage";
+    public final static String APPLICATION_JSON_USER = BASE + "user";
+    public final static String APPLICATION_JSON_CAPABILITIES = BASE + "capabilities";
+    public final static String APPLICATION_JSON_LIST = BASE + "list";
+    public final static String APPLICATION_JSON_SCALAR_VALUE = BASE + "scalarvalue";
+    public final static String APPLICATION_JSON_DOMAIN_OBJECT = BASE + "domainobject";
+    public final static String APPLICATION_JSON_TRANSIENT_DOMAIN_OBJECT = BASE + "transient";
+    public final static String APPLICATION_JSON_OBJECT_PROPERTY = BASE + "objectproperty";
+    public final static String APPLICATION_JSON_OBJECT_COLLECTION = BASE + "objectcollection";
+    public final static String APPLICATION_JSON_OBJECT_ACTION = BASE + "objectaction";
+    public final static String APPLICATION_JSON_ACTION_RESULT = BASE + "actionresult";
+    public final static String APPLICATION_JSON_TYPE_LIST = BASE + "typelist";
+    public final static String APPLICATION_JSON_DOMAIN_TYPE = BASE + "domaintype";
+    public final static String APPLICATION_JSON_TYPE_ACTION_RESULT = BASE + "typeactionresult";
+    public final static String APPLICATION_JSON_PROPERTY_DESCRIPTION = BASE + "propertydescription";
+    public final static String APPLICATION_JSON_COLLECTION_DESCRIPTION = BASE + "collectiondescription";
+    public final static String APPLICATION_JSON_ACTION_DESCRIPTION = BASE + "actiondescription";
+    public final static String APPLICATION_JSON_ACTION_PARAMETER_DESCRIPTION = BASE + "actionparameterdescription";

+    public final static String APPLICATION_JSON_ERROR = BASE + "error";
 
 }

Added: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/AbstractDomainObjectRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/AbstractDomainObjectRepresentation.java?rev=1204385&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/AbstractDomainObjectRepresentation.java
(added)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/AbstractDomainObjectRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.viewer.json.applib.domainobjects;
+
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+
+public abstract class AbstractDomainObjectRepresentation extends DomainRepresentation {
+
+    public AbstractDomainObjectRepresentation(JsonNode jsonNode) {
+        super(jsonNode);
+    }
+
+    public String getTitle() {
+        return getString("title");
+    }
+    
+    public JsonRepresentation getMembers() {
+        return getRepresentation("members").ensureArray();
+    }
+
+    public JsonRepresentation getProperty(final String id) {
+        return getRepresentation("members[memberType=property id=%s]", id);
+    }
+
+    public JsonRepresentation getProperties() {
+        return getRepresentation("members[memberType=property]").ensureArray();
+    }
+
+    public JsonRepresentation getCollection(final String id) {
+        return getRepresentation("members[memberType=collection id=%s]", id);
+    }
+
+    public JsonRepresentation getCollections() {
+        return getRepresentation("members[memberType=collection]").ensureArray();
+    }
+
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectRepresentation.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -22,45 +22,23 @@ import org.apache.isis.viewer.json.appli
 import org.codehaus.jackson.JsonNode;
 
 
-public class DomainObjectRepresentation extends DomainRepresentation {
+public class DomainObjectRepresentation extends AbstractDomainObjectRepresentation {
 
     public DomainObjectRepresentation(JsonNode jsonNode) {
         super(jsonNode);
     }
 
-    public String getOid() {
-        return getString("oid");
-    }
-
-    public String getTitle() {
-        return getString("title");
-    }
-    
-    public JsonRepresentation getMembers() {
-        return getArray("members");
-    }
-
-    public JsonRepresentation getProperty(final String id) {
-        return getRepresentation("members[memberType=property id=%s]", id);
-    }
-
-    public JsonRepresentation getProperties() {
-        return getRepresentation("members[memberType=property]").ensureArray();
-    }
 
-    public JsonRepresentation getCollection(final String id) {
-        return getRepresentation("members[memberType=collection id=%s]", id);
+    public String getOid() {
+        return getString("oid");
     }
-
-    public JsonRepresentation getCollections() {
-        return getRepresentation("members[memberType=collection]");
+    
+    public JsonRepresentation getActions() {
+        return getRepresentation("members[memberType=action]");
     }
 
-    public JsonRepresentation getActions() {
-        return getRepresentation("members[memberType=action]");
-    }
-
     public JsonRepresentation getAction(final String id) {
         return getRepresentation("members[memberType=action id=%s]", id);
     }
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectResource.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectResource.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainObjectResource.java
Mon Nov 21 07:51:40 2011
@@ -157,7 +157,7 @@ public interface DomainObjectResource {
 
     @GET
     @Path("/{oid}/actions/{actionId}/invoke")
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeActionQueryOnly(
         @PathParam("oid") final String oidStr, 
@@ -167,7 +167,7 @@ public interface DomainObjectResource {
     @PUT
     @Path("/{oid}/actions/{actionId}/invoke")
     @Consumes({ MediaType.WILDCARD })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeActionIdempotent(
         @PathParam("oid") final String oidStr, 
@@ -177,7 +177,7 @@ public interface DomainObjectResource {
     @POST
     @Path("/{oid}/actions/{actionId}/invoke")
     @Consumes({ MediaType.WILDCARD })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeAction(
         @PathParam("oid") final String oidStr, 

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainRepresentation.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -37,7 +37,7 @@ public abstract class DomainRepresentati
     }
 
     public JsonRepresentation getLinks() {
-        return getArray("links");
+        return getArray("links").ensureArray();
     }
 
     public LinkRepresentation getLinkWithRel(Rel rel) {

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
Mon Nov 21 07:51:40 2011
@@ -84,7 +84,7 @@ public interface DomainServiceResource {
 
     @GET
     @Path("/{serviceId}/actions/{actionId}/invoke")
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeActionQueryOnly(
         @PathParam("serviceId") final String serviceId, 
@@ -94,7 +94,7 @@ public interface DomainServiceResource {
     @PUT
     @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeActionIdempotent(
         @PathParam("serviceId") final String serviceId, 
@@ -104,7 +104,7 @@ public interface DomainServiceResource {
     @POST
     @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
     public Response invokeAction(
         @PathParam("serviceId") final String serviceId, 

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ListRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ListRepresentation.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ListRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/ListRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -29,7 +29,7 @@ public class ListRepresentation extends 
     }
 
     public JsonRepresentation getValues() {
-        return getArray("values");
+        return getArray("values").ensureArray();
     }
 
 }

Added: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java?rev=1204385&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java
(added)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/TransientDomainObjectRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.viewer.json.applib.domainobjects;
+
+import org.apache.isis.viewer.json.applib.blocks.LinkRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+
+public class TransientDomainObjectRepresentation extends AbstractDomainObjectRepresentation
{
+
+    public TransientDomainObjectRepresentation(JsonNode jsonNode) {
+        super(jsonNode);
+    }
+    
+    public LinkRepresentation getPersistLink() {
+        return getLink("links[rel=persist]");
+    }
+    
+}

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/user/UserRepresentation.java
Mon Nov 21 07:51:40 2011
@@ -42,7 +42,7 @@ public class UserRepresentation extends 
     }
 
     public JsonRepresentation getRoles() {
-        return getRepresentation("roles");
+        return getRepresentation("roles").ensureArray();
     }
 
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
Mon Nov 21 07:51:40 2011
@@ -17,6 +17,7 @@
 package org.apache.isis.viewer.json.viewer.resources.domainobjects;
 
 import java.io.InputStream;
+import java.util.Map;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -406,7 +407,7 @@ public class DomainObjectResourceServers
 
     @GET
     @Path("/{oid}/actions/{actionId}/invoke")
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     public Response invokeActionQueryOnly(
             @PathParam("oid") final String oidStr,
             @PathParam("actionId") final String actionId,
@@ -415,14 +416,20 @@ public class DomainObjectResourceServers
 
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
         final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(),
objectAdapter);
-
-        return helper.invokeActionQueryOnly(actionId, arguments);
+        
+        @SuppressWarnings("unchecked")
+        final Map<String,String[]> parameterMap = getResourceContext().getHttpServletRequest().getParameterMap();
+        if(parameterMap.containsKey("args")) {
+            return helper.invokeActionQueryOnly(actionId, arguments);
+        } else {
+            return helper.invokeActionQueryOnly(actionId, parameterMap);
+        }
     }
 
     @PUT
     @Path("/{oid}/actions/{actionId}/invoke")
     @Consumes({ MediaType.WILDCARD })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     public Response invokeActionIdempotent(
             @PathParam("oid") final String oidStr,
             @PathParam("actionId") final String actionId,
@@ -439,7 +446,7 @@ public class DomainObjectResourceServers
     @POST
     @Path("/{oid}/actions/{actionId}/invoke")
     @Consumes({ MediaType.WILDCARD })
-    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT,
RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR
})
+    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT,
RestfulMediaType.APPLICATION_JSON_ERROR })
     public Response invokeAction(
             @PathParam("oid") final String oidStr,
             @PathParam("actionId") final String actionId,

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
Mon Nov 21 07:51:40 2011
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import javax.ws.rs.core.Response;
@@ -260,6 +261,22 @@ public final class DomainResourceHelper 
         return invokeActionUsingAdapters(action, arguments);
     }
 
+    public Response invokeActionQueryOnly(String actionId, Map<String, String[]> parameterMap)
{
+
+        final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
+                actionId, Intent.ACCESS);
+
+        final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext,
action);
+        if(!actionSemantics.isQueryOnly()) {
+            throw JsonApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED,
+                    "Method not allowed; action '%s' is not query only", action.getId());
+        }
+
+        JsonRepresentation arguments = DomainResourceHelper.readParameterMapAsMap(parameterMap);
+        
+        return invokeActionUsingAdapters(action, arguments);
+    }
+
 
     Response invokeActionIdempotent(
             final String actionId, 
@@ -521,9 +538,7 @@ public final class DomainResourceHelper 
     private List<ObjectAdapter> parseArguments(
             final ObjectAction action, 
             final JsonRepresentation arguments) {
-        final ResourceContext resourceContext2 = resourceContext;
-        
-        return parseArguments(resourceContext2, action, arguments);
+        return parseArguments(resourceContext, action, arguments);
     }
 
     public static List<ObjectAdapter> parseArguments(final ResourceContext resourceContext,
final ObjectAction action, final JsonRepresentation arguments) {
@@ -585,6 +600,14 @@ public final class DomainResourceHelper 
         return argList;
     }
 
+    public static JsonRepresentation readParameterMapAsMap(Map<String, String[]> parameterMap)
{
+        final JsonRepresentation map = JsonRepresentation.newMap();
+        for(Map.Entry<String, String[]> parameter: parameterMap.entrySet()) {
+            map.mapPut(parameter.getKey(), parameter.getValue()[0]);
+        }
+        return map;
+    }
+
     public static JsonRepresentation readQueryStringAsMap(String queryString) {
         if(queryString == null) {
             return JsonRepresentation.newMap();
@@ -670,4 +693,5 @@ public final class DomainResourceHelper 
     }
 
 
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
Mon Nov 21 07:51:40 2011
@@ -18,6 +18,7 @@ package org.apache.isis.viewer.json.view
 
 import java.io.InputStream;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
@@ -145,7 +146,13 @@ public class DomainServiceResourceServer
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
         final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(),
serviceAdapter).using(new DomainServiceLinkTo());
 
-        return helper.invokeActionQueryOnly(actionId, arguments);
+        @SuppressWarnings("unchecked")
+        final Map<String,String[]> parameterMap = getResourceContext().getHttpServletRequest().getParameterMap();
+        if(parameterMap.containsKey("args")) {
+            return helper.invokeActionQueryOnly(actionId, arguments);
+        } else {
+            return helper.invokeActionQueryOnly(actionId, parameterMap);
+        }
     }
 
     @PUT

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java?rev=1204385&r1=1204384&r2=1204385&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java
Mon Nov 21 07:51:40 2011
@@ -168,10 +168,13 @@ public final class JsonValueEncoder {
         }
         final ObjectSpecification objectSpec = objectAdapter.getSpecification();
 
-        // special case handling for JSON built-ins
+        // special case handling for JSON built-ins (at least so far as json.org defines
them).
         if(     isBoolean(objectSpec) || 
-                isInteger(objectSpec) || isLong(objectSpec) || isBigInteger(objectSpec) ||

-                isDouble(objectSpec) || isBigDecimal(objectSpec) ) {
+                isInteger(objectSpec) || 
+                isLong(objectSpec) || 
+                isBigInteger(objectSpec) || 
+                isDouble(objectSpec) || 
+                isBigDecimal(objectSpec) ) {
             // simply return
             return objectAdapter.getObject();
         }



Mime
View raw message