incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1177870 - in /incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer: resources/ resources/domainobjects/ resources/home/ resources/user/ webapp/
Date Fri, 30 Sep 2011 22:38:36 GMT
Author: danhaywood
Date: Fri Sep 30 22:38:35 2011
New Revision: 1177870

URL: http://svn.apache.org/viewvc?rev=1177870&view=rev
Log:
ISIS-109: refactoring/simplification

Added:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/PreProcessInterceptorForIsisSession.java
      - copied, changed from r1172691, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/PreProcessInterceptorForIsisSession.java
Removed:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/AbstractResourceHelper.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/PreProcessInterceptorForIsisSession.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java
Modified:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.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/home/HomePageReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.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/ResourceAbstract.java?rev=1177870&r1=1177869&r2=1177870&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
Fri Sep 30 22:38:35 2011
@@ -235,10 +235,6 @@ public abstract class ResourceAbstract {
         return responseOfOk(representationType, caching, jsonFor(representation));
     }
 
-    public static ResponseBuilder responseOfOk(RepresentationType representationType, Caching
caching, ReprBuilder representationBuilder) {
-        return responseOfOk(representationType, caching, representationBuilder.render());
-    }
-
     public static ResponseBuilder responseOfOk(Caching caching, ReprRenderer<?,?> renderer)
{
         RepresentationType representationType = renderer.getRepresentationType();
         return responseOfOk(representationType, caching, renderer.render());

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=1177870&r1=1177869&r2=1177870&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
Fri Sep 30 22:38:35 2011
@@ -78,8 +78,7 @@ public class DomainObjectResourceServers
                 (DomainObjectReprRenderer) rendererFactory.newRenderer(getResourceContext(),
JsonRepresentation.newMap());
         renderer.with(objectAdapter);
         
-        ResponseBuilder respBuilder = 
-                responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.NONE, renderer);
+        ResponseBuilder respBuilder = responseOfOk(Caching.NONE, renderer);
         
         Version version = objectAdapter.getVersion();
         if (version != null && version.getTime() != null) {
@@ -114,20 +113,10 @@ public class DomainObjectResourceServers
             @PathParam("propertyId") final String propertyId) {
         init();
         
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
-        final RendererFactory rendererFactory = 
-                rendererFactoryRegistry.find(RepresentationType.OBJECT_PROPERTY);
-        
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
-                objectAdapter, propertyId, Intent.ACCESS);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
         
-        final ObjectPropertyReprRenderer renderer = 
-                (ObjectPropertyReprRenderer) rendererFactory.newRenderer(getResourceContext(),
JsonRepresentation.newMap());
-        renderer.with(new ObjectAndProperty(objectAdapter, property));
-
-        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.NONE, renderer).build();
+        return helper.propertyDetails(objectAdapter, propertyId, Caching.NONE);
     }
 
     @PUT

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=1177870&r1=1177869&r2=1177870&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
Fri Sep 30 22:38:35 2011
@@ -21,6 +21,11 @@ import java.io.InputStream;
 import java.util.Collection;
 import java.util.List;
 
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
@@ -40,6 +45,7 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.RestfulMediaType;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
 import org.apache.isis.viewer.json.applib.blocks.Link;
 import org.apache.isis.viewer.json.applib.util.JsonMapper;
@@ -73,6 +79,27 @@ public class DomainResourceHelper {
     }
 
     // //////////////////////////////////////////////////////////////
+    // propertyDetails
+    // //////////////////////////////////////////////////////////////
+
+    Response propertyDetails(
+            final ObjectAdapter objectAdapter,
+            final String propertyId, 
+            final Caching caching) {
+
+        final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
+                objectAdapter, propertyId, Intent.ACCESS);
+
+        RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
+        final ObjectPropertyReprRenderer renderer = 
+                (ObjectPropertyReprRenderer) factory.newRenderer(resourceContext, JsonRepresentation.newMap());
+        
+        renderer.with(new ObjectAndProperty(objectAdapter, property));
+        
+        return ResourceAbstract.responseOfOk(caching, renderer).build();
+    }
+
+    // //////////////////////////////////////////////////////////////
     // action Prompt
     // //////////////////////////////////////////////////////////////
 
@@ -88,8 +115,7 @@ public class DomainResourceHelper {
                 .withSelf()
                 .withMutatorsIfEnabled();
 
-        return ResourceAbstract.responseOfOk(RepresentationType.OBJECT_ACTION, Caching.NONE,
renderer.render())
-                .build();
+        return ResourceAbstract.responseOfOk(Caching.NONE, renderer).build();
     }
 
     
@@ -232,7 +258,7 @@ public class DomainResourceHelper {
 
             ScalarValueReprRenderer renderer = (ScalarValueReprRenderer) factory.newRenderer(resourceContext,
representation);
             renderer.with(objectAdapter);
-            return ResourceAbstract.responseOfOk(RepresentationType.SCALAR_VALUE, Caching.NONE,
renderer).build();
+            return ResourceAbstract.responseOfOk(Caching.NONE, renderer).build();
         }
 
         final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);

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=1177870&r1=1177869&r2=1177870&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
Fri Sep 30 22:38:35 2011
@@ -56,10 +56,16 @@ public class DomainServiceResourceServer
     public Response services() {
         init();
 
-        final ReprBuilder builder = 
-                new DomainServiceResourceHelper(getResourceContext(), "services").services();
+        final List<ObjectAdapter> serviceAdapters = getResourceContext().getPersistenceSession().getServices();
+
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.LIST);
+        
+        final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(getResourceContext(),
JsonRepresentation.newMap());
+        renderer.usingLinkToBuilder(new DomainServiceLinkToBuilder())
+                .withSelf("services")
+                .with(serviceAdapters);
         
-        return responseOfOk(RepresentationType.LIST, Caching.ONE_DAY, builder).build();
+        return responseOfOk(Caching.ONE_DAY, renderer).build();
     }
 
     ////////////////////////////////////////////////////////////
@@ -83,7 +89,7 @@ public class DomainServiceResourceServer
                     .includesSelf()
                     .with(serviceAdapter);
         
-        return responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.ONE_DAY, renderer).build();
+        return responseOfOk(Caching.ONE_DAY, renderer).build();
     }
 
 
@@ -99,20 +105,10 @@ public class DomainServiceResourceServer
             @PathParam("propertyId") final String propertyId) {
         init();
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
-        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
-                serviceAdapter, propertyId, Intent.ACCESS);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
 
-        RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
-        final ObjectPropertyReprRenderer renderer = 
-                (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
-        
-        renderer.with(new ObjectAndProperty(serviceAdapter, property))
-                .withDetailsLink();
-        
-        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.ONE_DAY, renderer.render()).build();
+        return helper.propertyDetails(serviceAdapter, propertyId, Caching.ONE_DAY);
     }
 
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.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/home/HomePageReprRenderer.java?rev=1177870&r1=1177869&r2=1177870&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.java
Fri Sep 30 22:38:35 2011
@@ -2,6 +2,7 @@ package org.apache.isis.viewer.json.view
 
 import java.util.List;
 
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulRequest.QueryParameter;
@@ -9,11 +10,11 @@ import org.apache.isis.viewer.json.viewe
 import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
 import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
 import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilder;
 import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
 import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
 import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
-import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainServiceResourceHelper;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainServiceLinkToBuilder;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ListReprRenderer;
 import org.apache.isis.viewer.json.viewer.resources.user.UserReprRenderer;
 
 public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRenderer, Void>
{
@@ -43,7 +44,7 @@ public class HomePageReprRenderer extend
         
         // self
         if(includesSelf) {
-            withSelf("/");
+            withSelf("");
         }
 
         // user
@@ -68,9 +69,17 @@ public class HomePageReprRenderer extend
         
         final List<String> followLinks = getResourceContext().getArg(QueryParameter.FOLLOW_LINKS);
         if(followLinks.contains("services")) {
-            final ReprBuilder reprBuilder = 
-                    new DomainServiceResourceHelper(getResourceContext()).services();
-            servicesLinkBuilder.withValue(reprBuilder.render());
+            
+            final List<ObjectAdapter> serviceAdapters = getResourceContext().getPersistenceSession().getServices();
+
+            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.LIST);
+            
+            final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(getResourceContext(),
JsonRepresentation.newMap());
+            renderer.usingLinkToBuilder(new DomainServiceLinkToBuilder())
+                    .withSelf("services")
+                    .with(serviceAdapters);
+            
+            servicesLinkBuilder.withValue(renderer.render());
         }
         
         representation.mapPut("services", servicesLinkBuilder.render());

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.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/home/HomePageResourceServerside.java?rev=1177870&r1=1177869&r2=1177870&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java
Fri Sep 30 22:38:35 2011
@@ -47,7 +47,7 @@ public class HomePageResourceServerside 
                 (HomePageReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
         renderer.includesSelf();
 
-        return responseOfOk(RepresentationType.HOME_PAGE, Caching.ONE_DAY, renderer).build();
+        return responseOfOk(Caching.ONE_DAY, renderer).build();
     }
 
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.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/user/UserResourceServerside.java?rev=1177870&r1=1177869&r2=1177870&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java
Fri Sep 30 22:38:35 2011
@@ -42,7 +42,7 @@ public class UserResourceServerside exte
         renderer.includesSelf()
                 .with(getAuthenticationSession());
 
-        return responseOfOk(RepresentationType.USER, Caching.ONE_HOUR, renderer.render()).build();
+        return responseOfOk(Caching.ONE_HOUR, renderer).build();
     }
 
 

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/PreProcessInterceptorForIsisSession.java
(from r1172691, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/PreProcessInterceptorForIsisSession.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/PreProcessInterceptorForIsisSession.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/PreProcessInterceptorForIsisSession.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/PreProcessInterceptorForIsisSession.java&r1=1172691&r2=1177870&rev=1177870&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/PreProcessInterceptorForIsisSession.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/webapp/PreProcessInterceptorForIsisSession.java
Fri Sep 30 22:38:35 2011
@@ -1,4 +1,4 @@
-package org.apache.isis.viewer.json.viewer.resources;
+package org.apache.isis.viewer.json.viewer.webapp;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.ext.Provider;



Mime
View raw message