Author: erinnp
Date: Mon Jul 22 20:51:00 2013
New Revision: 1505802

URL: http://svn.apache.org/r1505802
Log:
update to Resource interfaces to support proposed api specification

Added:
    
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesForRenderResource.java
      - copied, changed from r1504892, 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
    
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/JsonResponseWrapper.java
    
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageForRenderResource.java
      - copied, changed from r1504892, 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
Modified:
    
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
    
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionWidgetService.java
    
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
    
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/cxf-applicationContext.xml

Copied: 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesForRenderResource.java
 (from r1504892, 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java)
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesForRenderResource.java?p2=rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesForRenderResource.java&p1=rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java&r1=1504892&r2=1505802&rev=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
 (original)
+++ 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesForRenderResource.java
 Mon Jul 22 20:51:00 2013
@@ -28,240 +28,32 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.File;
 
-@Path("/pages")
-public interface PagesResource {
-
-    /**
-     * Deletes the given page
-     * @param id ID of the page on which the operation is to take place
-     * @return
-     */
-    @DELETE
-    @Path("/{id}")
-    Response deletePage(@PathParam("id") String id);
-
-    /**
-     * Returns the given page
-     * @param id ID of the page on which the operation is to take place
-     * @return
-     */
-    @GET
-    @Path("/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response getPage(@PathParam("id") String id);
-
-    /**
-     * Updates the given page
-     * @param id ID of the page on which the operation is to take place
-     * @param page the new definition of the page
-     * @return
-     */
-    @PUT
-    @Path("/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response updatePage(@PathParam("id") String id, Page page);
-
-    /**
-     * Returns the OMDL representation of the page
-     * @param id ID of the page on which the operation is to take place
-     * @return
-     */
-    @GET
-    @Path("/{id}")
-    @Produces({"application/vnd.omdl+xml"})
-    Response getPageOmdl(@PathParam("id") String id);
-
+@Path("/pages/render")
+public interface PagesForRenderResource {
 
     /**
      * Gets the render-ready page definitions for the given context & 
identifier
      *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
+     * @param context    the context under which the operation takes place 
(portal, profile, etc)
      * @param identifier the target context identifier (username, group, etc)
      * @return
      */
     @GET
     @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Produces(MediaType.APPLICATION_JSON)
     Response getPagesForRender(@PathParam("context") String context, 
@PathParam("identifier") String identifier);
 
-
     /**
      * Gets the render-ready page definition for the given context, identifier 
& page id
      *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
+     * @param context    the context under which the operation takes place 
(portal, profile, etc)
      * @param identifier the target context identifier (username, group, etc)
      * @return
      */
     @GET
     @Path("/{context}/{identifier}/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Produces(MediaType.APPLICATION_JSON)
     Response getPageForRender(@PathParam("context") String context,
                               @PathParam("identifier") String identifier,
                               @PathParam("id") String id);
-
-    /**
-     *
-     * Clones the specific page for the specified user
-     *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param id the page to clone to the new context identifier
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}/{id}/clone")
-    Response clonePage(@PathParam("context") String context,
-                       @PathParam("identifier") String identifier,
-                       @PathParam("id") String id);
-
-    /**
-     * Creates a new page
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param page the OMDL page to create
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({"application/vnd.omdl+xml"})
-    Response importOmdlPage(@PathParam("context") String context,
-                            @PathParam("identifier") String identifier,
-                            @Multipart(value = "root", type = 
"application/octet-stream") File page);
-
-    /**
-     * Creates a new page
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param page the page to create
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response createPage(@PathParam("context") String context,
-                        @PathParam("identifier") String identifier,
-                        Page page);
-
-    /**
-     * Deletes the given page
-     * @param id ID of the page on which the operation is to take place
-     * @return
-     */
-    @DELETE
-    @Path("/{context}/{identifier}/{id}")
-    Response deletePageInContext(@PathParam("id") String id);
-
-    /**
-     * Updates the given page
-     * @param id ID of the page on which the operation is to take place
-     * @param page the new definition of the page
-     * @return
-     */
-    @PUT
-    @Path("/{context}/{identifier}/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response updatePageInContext(@PathParam("id") String id, Page page);
-
-    /**
-     * Modifies the page's render order for the current user
-     * @param id ID of the page on which the operation is to take place
-     * @param moveAfterPageId ID of the page to move after
-     * @return
-     */
-    @PUT
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("/{context}/{identifier}/{id}/move")
-    Response movePage(@PathParam("id") String id, 
@QueryParam("moveAfterPageId") final String moveAfterPageId);
-
-
-    /**
-     * Adds the specified widget to the first region on the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param widget the widget to add.  widgetId is the only required property
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}/{id}/regionWidgets")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addWidgetToPage(@PathParam("id") String id, RegionWidget widget);
-
-    /**
-     * Removes the widget from the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param regionWidgetId ID of the regionWidget to move
-     * @return
-     */
-    @DELETE
-    @Path("/{context}/{identifier}/{id}/regionWidgets/{regionWidgetId}")
-    Response removeWidgetFromPage(@PathParam("id") String id, 
@PathParam("regionWidgetId") String regionWidgetId);
-
-    /**
-     * Adds the specified widget to the given region on the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param regionId the target Region ID
-     * @param widget the widget to add.  widgetId is the only required property
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}/{id}/regions/{regionId}/regionWidgets")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addWidgetToRegion(@PathParam("id") String id, 
@PathParam("regionId") String regionId, RegionWidget widget);
-
-    /**
-     * Moves the region widget to the specified Region
-     * @param id ID of the page on which the operation is to take place
-     * @param toRegionId the target Region ID
-     * @param regionWidgetId ID of the regionWidget to move
-     * @param position the position of the widget in the new region
-     * @return
-     */
-    @PUT
-    
@Path("/{context}/{identifier}/{id}/regions/{toRegionId}/regionWidgets/{regionWidgetId}/move")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response moveWidgetOnPage(@PathParam("id") String id,
-                              @PathParam("toRegionId") String toRegionId,
-                              @PathParam("regionWidgetId") String 
regionWidgetId,
-                              @QueryParam("position") int position);
-
-    /**
-     * Moves the region widget to the specified Region
-     * @param targetPageId ID of the page to move to
-     * @param regionWidgetId ID of the regionWidget to move
-     * @return
-     */
-    @PUT
-    
@Path("/{context}/{identifier}/{targetPageId}/regionWidgets/{regionWidgetId}/move")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response moveWidgetToPage(@PathParam("targetPageId") String targetPageId,
-                              @PathParam("regionWidgetId") String 
regionWidgetId);
-    /**
-     * Adds a new member to the page
-     * @param id ID of the page on which the operation is to take place
-     * @return
-     */
-    @POST
-    @Path("/{context}/{identifier}/{id}/members")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addMemberToPage(@PathParam("id") String id);
-
-    @DELETE
-    @Path("/{context}/{identifier}/{id}/members/{userId}")
-    Response removeMemberFromPage(@PathParam("id") String id, 
@PathParam("userId") String userId);
-
-    @PUT
-    @Path("/{context}/{identifier}/{id}/members/{userId}/status")
-    Response updateSharedPageStatus(@PathParam("id") String id, 
@PathParam("userId") String userId, String status);
-
-    @PUT
-    @Path("/{context}/{identifier}/{id}/members/{userId}/editor")
-    Response updatePageEditingStatus(@PathParam("id") String id, 
@PathParam("userId") String userId, boolean editor);
 }

Modified: 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java?rev=1505802&r1=1505801&r2=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
 (original)
+++ 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PagesResource.java
 Mon Jul 22 20:51:00 2013
@@ -19,249 +19,219 @@
 
 package org.apache.rave.rest;
 
-import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.rave.rest.model.Page;
+import org.apache.rave.rest.model.Region;
 import org.apache.rave.rest.model.RegionWidget;
 
 import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import java.io.File;
 
 @Path("/pages")
 public interface PagesResource {
 
-    /**
-     * Deletes the given page
-     * @param id ID of the page on which the operation is to take place
-     * @return
+    /*
+    --- Page operations
      */
-    @DELETE
-    @Path("/{id}")
-    Response deletePage(@PathParam("id") String id);
 
     /**
-     * Returns the given page
-     * @param id ID of the page on which the operation is to take place
+     * Returns a list of pages
+     *
      * @return
      */
     @GET
-    @Path("/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response getPage(@PathParam("id") String id);
+    @Path("/")
+    @Consumes(MediaType.APPLICATION_JSON)
+    Response getPages();
 
     /**
-     * Updates the given page
-     * @param id ID of the page on which the operation is to take place
-     * @param page the new definition of the page
+     * Creates a new page
+     *
+     * @param page the definition of the new page
      * @return
      */
-    @PUT
-    @Path("/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response updatePage(@PathParam("id") String id, Page page);
+    @POST
+    @Path("/")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    Response createPage(Page page);
 
     /**
-     * Returns the OMDL representation of the page
-     * @param id ID of the page on which the operation is to take place
+     * Deletes the given page
+     *
+     * @param pageId ID of the page on which the operation is to take place
      * @return
      */
-    @GET
-    @Path("/{id}")
-    @Produces({"application/vnd.omdl+xml"})
-    Response getPageOmdl(@PathParam("id") String id);
-
+    @DELETE
+    @Path("/{pageId}")
+    Response deletePage(@PathParam("pageId") String pageId);
 
     /**
-     * Gets the render-ready page definitions for the given context & 
identifier
+     * Returns the given page
      *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc)
+     * @param pageId ID of the page on which the operation is to take place
      * @return
      */
     @GET
-    @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response getPagesForRender(@PathParam("context") String context, 
@PathParam("identifier") String identifier);
-
+    @Path("/{pageId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getPage(@PathParam("pageId") String pageId);
 
     /**
-     * Gets the render-ready page definition for the given context, identifier 
& page id
+     * Updates the given page
      *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc)
+     * @param pageId ID of the page on which the operation is to take place
+     * @param page   the new definition of the page
      * @return
      */
-    @GET
-    @Path("/{context}/{identifier}/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response getPageForRender(@PathParam("context") String context,
-                              @PathParam("identifier") String identifier,
-                              @PathParam("id") String id);
+    @PUT
+    @Path("/{pageId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    Response updatePage(@PathParam("pageId") String pageId, Page page);
 
     /**
+     * Returns the OMDL representation of the page
      *
-     * Clones the specific page for the specified user
-     *
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param id the page to clone to the new context identifier
+     * @param pageId ID of the page on which the operation is to take place
      * @return
      */
-    @POST
-    @Path("/{context}/{identifier}/{id}/clone")
-    Response clonePage(@PathParam("context") String context,
-                       @PathParam("identifier") String identifier,
-                       @PathParam("id") String id);
+    @GET
+    @Path("/{pageId}")
+    @Produces({"application/vnd.omdl+xml"})
+    Response getPageOmdl(@PathParam("pageId") String pageId);
 
-    /**
-     * Creates a new page
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param page the OMDL page to create
-     * @return
+    /*
+    --- Region Operations
      */
-    @POST
-    @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({"application/vnd.omdl+xml"})
-    Response importOmdlPage(@PathParam("context") String context,
-                            @PathParam("identifier") String identifier,
-                            @Multipart(value = "root", type = 
"application/octet-stream") File page);
 
     /**
-     * Creates a new page
-     * @param context the context under which the operation takes place 
(portal, profile, etc)
-     * @param identifier the target context identifier (username, group, etc) 
to clone the page to
-     * @param page the page to create
+     * Returns the regions associated with a page
+     *
+     * @param pageId the page id
      * @return
      */
-    @POST
-    @Path("/{context}/{identifier}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response createPage(@PathParam("context") String context,
-                        @PathParam("identifier") String identifier,
-                        Page page);
+    @GET
+    @Path("/{pageId}/regions")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getPageRegions(@PathParam("pageId") String pageId);
 
     /**
-     * Deletes the given page
-     * @param id ID of the page on which the operation is to take place
+     * Creates a new page region
+     *
+     * @param pageId the page id
+     * @param region the definition of the region
      * @return
      */
-    @DELETE
-    @Path("/{context}/{identifier}/{id}")
-    Response deletePageInContext(@PathParam("id") String id);
+    @POST
+    @Path("/{pageId}/regions")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    Response createPageRegion(@PathParam("pageId") String pageId, Region 
region);
 
     /**
-     * Updates the given page
-     * @param id ID of the page on which the operation is to take place
-     * @param page the new definition of the page
+     * Returns a particular region associated with a page
+     *
+     * @param pageId   the page id
+     * @param regionId the region id
      * @return
      */
-    @PUT
-    @Path("/{context}/{identifier}/{id}")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response updatePageInContext(@PathParam("id") String id, Page page);
+    @GET
+    @Path("/{pageId}/regions/{regionId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getPageRegion(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId);
 
     /**
-     * Modifies the page's render order for the current user
-     * @param id ID of the page on which the operation is to take place
-     * @param moveAfterPageId ID of the page to move after
+     * Update a page region
+     *
+     * @param pageId   the page id
+     * @param regionId the region id
+     * @param region   the new region definition
      * @return
      */
     @PUT
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Path("/{context}/{identifier}/{id}/move")
-    Response movePage(@PathParam("id") String id, 
@QueryParam("moveAfterPageId") final String moveAfterPageId);
-
+    @Path("/{pageId}/regions/{regionId}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    Response updatePageRegion(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId, Region region);
 
     /**
-     * Adds the specified widget to the first region on the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param widget the widget to add.  widgetId is the only required property
+     * Deletes a page region
+     *
+     * @param pageId   the id of the page
+     * @param regionId the region id
      * @return
      */
-    @POST
-    @Path("/{context}/{identifier}/{id}/regionWidgets")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addWidgetToPage(@PathParam("id") String id, RegionWidget widget);
+    @DELETE
+    @Path("/{pageId}/regions/{regionId}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    Response deletePageRegion(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId);
 
-    /**
-     * Removes the widget from the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param regionWidgetId ID of the regionWidget to move
-     * @return
+    /*
+    --- RegionWidget Operations
      */
-    @DELETE
-    @Path("/{context}/{identifier}/{id}/regionWidgets/{regionWidgetId}")
-    Response removeWidgetFromPage(@PathParam("id") String id, 
@PathParam("regionWidgetId") String regionWidgetId);
 
     /**
-     * Adds the specified widget to the given region on the page
-     * @param id  ID of the page on which the operation is to take place
-     * @param regionId the target Region ID
-     * @param widget the widget to add.  widgetId is the only required property
+     * Returns the regionWidgets associated with a page and a region
+     *
+     * @param pageId   the page id
+     * @param regionId the region id
      * @return
      */
+    @GET
+    @Path("/{pageId}/regions/{regionId}/regionWidgets")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getPageRegionRegionWidgets(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId);
+
     @POST
-    @Path("/{context}/{identifier}/{id}/regions/{regionId}/regionWidgets")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addWidgetToRegion(@PathParam("id") String id, 
@PathParam("regionId") String regionId, RegionWidget widget);
+    @Path("/{pageId}/regions/{regionId}/regionWidgets")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    Response createPageRegionRegionWidget(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId,
+                                          RegionWidget regionWidget);
 
     /**
-     * Moves the region widget to the specified Region
-     * @param id ID of the page on which the operation is to take place
-     * @param toRegionId the target Region ID
-     * @param regionWidgetId ID of the regionWidget to move
-     * @param position the position of the widget in the new region
+     * Returns a regionWidget associated with a page and a region
+     *
+     * @param pageId         the page id
+     * @param regionId       the region id
+     * @param regionWidgetId the regionWidget id
      * @return
      */
-    @PUT
-    
@Path("/{context}/{identifier}/{id}/regions/{toRegionId}/regionWidgets/{regionWidgetId}/move")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response moveWidgetOnPage(@PathParam("id") String id,
-                              @PathParam("toRegionId") String toRegionId,
-                              @PathParam("regionWidgetId") String 
regionWidgetId,
-                              @QueryParam("position") int position);
+    @GET
+    @Path("/{pageId}/regions/{regionId}/regionWidgets/{regionWidgetId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response getPageRegionRegionWidget(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId,
+                                       @PathParam("regionWidgetId") String 
regionWidgetId);
 
     /**
-     * Moves the region widget to the specified Region
-     * @param targetPageId ID of the page to move to
-     * @param regionWidgetId ID of the regionWidget to move
+     * Updates a regionWidget associated with a page and a region
+     *
+     * @param pageId         the page id
+     * @param regionId       the region id
+     * @param regionWidgetId the regionWidget id
+     * @param regionWidget   the new regionWidget definition
      * @return
      */
     @PUT
-    
@Path("/{context}/{identifier}/{targetPageId}/regionWidgets/{regionWidgetId}/move")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response moveWidgetToPage(@PathParam("targetPageId") String targetPageId,
-                              @PathParam("regionWidgetId") String 
regionWidgetId);
+    @Path("/{pageId}/regions/{regionId}/regionWidgets/{regionWidgetId}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    Response updatePageRegionRegionWidget(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId,
+                                          @PathParam("regionWidgetId") String 
regionWidgetId, RegionWidget regionWidget);
+
     /**
-     * Adds a new member to the page
-     * @param id ID of the page on which the operation is to take place
+     * Deletes a regionWidget from a page region
+     *
+     * @param pageId         the page id
+     * @param regionId       the region id
+     * @param regionWidgetId the regionWidget id
      * @return
      */
-    @POST
-    @Path("/{context}/{identifier}/{id}/members")
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    Response addMemberToPage(@PathParam("id") String id);
-
     @DELETE
-    @Path("/{context}/{identifier}/{id}/members/{userId}")
-    Response removeMemberFromPage(@PathParam("id") String id, 
@PathParam("userId") String userId);
-
-    @PUT
-    @Path("/{context}/{identifier}/{id}/members/{userId}/status")
-    Response updateSharedPageStatus(@PathParam("id") String id, 
@PathParam("userId") String userId, String status);
-
-    @PUT
-    @Path("/{context}/{identifier}/{id}/members/{userId}/editor")
-    Response updatePageEditingStatus(@PathParam("id") String id, 
@PathParam("userId") String userId, boolean editor);
+    @Path("/{pageId}/regions/{regionId}/regionWidgets/{regionWidgetId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    Response deletePageRegionRegionWidget(@PathParam("pageId") String pageId, 
@PathParam("regionId") String regionId,
+                                          @PathParam("regionWidgetId") String 
regionWidgetId);
 }

Added: 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/JsonResponseWrapper.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/JsonResponseWrapper.java?rev=1505802&view=auto
==============================================================================
--- 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/JsonResponseWrapper.java
 (added)
+++ 
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/JsonResponseWrapper.java
 Mon Jul 22 20:51:00 2013
@@ -0,0 +1,77 @@
+package org.apache.rave.rest.model;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: erinnp
+ * Date: 7/19/13
+ * Time: 11:37 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JsonResponseWrapper {
+
+    private HashMap<String, String> metadata;
+    private Object data;
+
+    //constructor for single resource objects
+    public JsonResponseWrapper(Object data) {
+        this.metadata = new HashMap<String, String>();
+        this.data = data;
+    }
+
+    //constructor for list objects
+    public JsonResponseWrapper(Object data, Integer limit, Integer offset, 
Integer count) {
+        this.metadata = new HashMap<String, String>();
+        this.data = data;
+
+        buildPaginationData(limit, offset, count);
+    }
+
+    private void buildPaginationData(Integer limit, Integer offset, Integer 
count){
+        Integer prevOffset = null;
+        Integer nextOffset = null;
+
+        if(offset > 0) {
+            //build prev offset
+            prevOffset = offset - limit;
+            if(prevOffset < 0) {
+                prevOffset = 0;
+            }
+        }
+        if(limit+offset < count) {
+            //build next offset
+            nextOffset = limit+offset;
+        }
+
+        if(prevOffset != null) {
+            this.metadata.put("prev", "?limit=" + limit + "&offset=" + 
prevOffset);
+        }
+        if(nextOffset != null) {
+            this.metadata.put("next", "?limit=" + limit + "&offset=" + 
nextOffset);
+        }
+
+        this.metadata.put("limit", limit.toString());
+        this.metadata.put("offset", offset.toString());
+        this.metadata.put("count", count.toString());
+    }
+
+    public HashMap<String, String> getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(HashMap<String, String> metadata) {
+        this.metadata = metadata;
+    }
+
+    public Object getData() {
+        return data;
+    }
+
+    public void setData(Object data) {
+        this.data = data;
+    }
+
+
+}

Modified: 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionWidgetService.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionWidgetService.java?rev=1505802&r1=1505801&r2=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionWidgetService.java
 (original)
+++ 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionWidgetService.java
 Mon Jul 22 20:51:00 2013
@@ -34,7 +34,7 @@ import org.springframework.transaction.a
 import java.util.Arrays;
 import java.util.List;
 
-@Service
+@Service(value = "regionWidgetService")
 public class DefaultRegionWidgetService implements RegionWidgetService {
     private RegionWidgetRepository regionWidgetRepository;
 
@@ -91,7 +91,7 @@ public class DefaultRegionWidgetService 
         regionWidget.setCollapsed(collapsed);
         return saveRegionWidget(regionWidget);
     }
-    
+
     private RegionWidget getValidRegionWidget(String regionWidgetId) {
         RegionWidget regionWidget = this.getRegionWidget(regionWidgetId);
         if (regionWidget == null) {

Copied: 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageForRenderResource.java
 (from r1504892, 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java)
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageForRenderResource.java?p2=rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageForRenderResource.java&p1=rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java&r1=1504892&r2=1505802&rev=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
 (original)
+++ 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageForRenderResource.java
 Mon Jul 22 20:51:00 2013
@@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
 import org.apache.rave.portal.service.PageService;
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.web.renderer.RenderService;
+import org.apache.rave.rest.PagesForRenderResource;
 import org.apache.rave.rest.PagesResource;
 import org.apache.rave.rest.model.Page;
 import org.apache.rave.rest.model.PageList;
@@ -32,12 +33,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import java.io.File;
 import java.util.Arrays;
 import java.util.List;
 
-public class DefaultPageResource implements PagesResource {
+public class DefaultPageForRenderResource implements PagesForRenderResource {
 
     public static final String SELF = "@self";
     private Logger logger = LoggerFactory.getLogger(getClass());
@@ -46,31 +49,6 @@ public class DefaultPageResource impleme
     private UserService userService;
 
     @Override
-    public Response deletePage(String id) {
-        logger.debug("Deleting page " + id);
-        pageService.deletePage(id);
-        return Response.noContent().build();
-    }
-
-    @Override
-    public Response getPage(String id) {
-        logger.debug("Retrieving page for export: " + id);
-        org.apache.rave.model.Page fromDb = pageService.getPage(id);
-        return fromDb == null ? 
Response.status(Response.Status.NOT_FOUND).build() : Response.ok(new 
Page(fromDb)).build();
-    }
-
-    @Override
-    public Response updatePage(String id, Page page) {
-        org.apache.rave.model.Page fromDb = pageService.updatePage(id, 
page.getName(), page.getPageLayoutCode());
-        return Response.ok(new Page(fromDb)).build();
-    }
-
-    @Override
-    public Response getPageOmdl(String id) {
-        return null;
-    }
-
-    @Override
     public Response getPagesForRender(String context, String identifier) {
         List<org.apache.rave.model.Page> pages;
         if("portal".equals(context)) {
@@ -91,84 +69,9 @@ public class DefaultPageResource impleme
 
     @Override
     public Response getPageForRender(String context, String identifier, String 
id) {
-        return getPage(id);
-    }
-
-    @Override
-    public Response clonePage(String context, String identifier, String id) {
-        return null;
-    }
-
-    @Override
-    public Response importOmdlPage(String context, String identifier, File 
page) {
         return null;
     }
 
-    @Override
-    public Response createPage(String context, String identifier, Page page) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response deletePageInContext(String id) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response updatePageInContext(String id, Page page) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response movePage(String id, String moveAfterPageId) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response addWidgetToPage(String id, RegionWidget widget) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response removeWidgetFromPage(String id, String regionWidgetId) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response addWidgetToRegion(String id, String regionId, RegionWidget 
widget) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response moveWidgetOnPage(String id, String toRegionId, String 
regionWidgetId, int position) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response moveWidgetToPage(String targetPageId, String 
regionWidgetId) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response addMemberToPage(String id) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response removeMemberFromPage(String id, String userId) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response updateSharedPageStatus(String id, String userId, String 
status) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response updatePageEditingStatus(String id, String userId, boolean 
editor) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
     @Inject
     public void setPageService(PageService pageService) {
         this.pageService = pageService;

Modified: 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java?rev=1505802&r1=1505801&r2=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
 (original)
+++ 
rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/rest/impl/DefaultPageResource.java
 Mon Jul 22 20:51:00 2013
@@ -25,25 +25,27 @@ import org.apache.rave.portal.service.Pa
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.web.renderer.RenderService;
 import org.apache.rave.rest.PagesResource;
-import org.apache.rave.rest.model.Page;
-import org.apache.rave.rest.model.PageList;
-import org.apache.rave.rest.model.RegionWidget;
+import org.apache.rave.rest.model.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import javax.ws.rs.core.Response;
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
 
 public class DefaultPageResource implements PagesResource {
 
-    public static final String SELF = "@self";
     private Logger logger = LoggerFactory.getLogger(getClass());
     private PageService pageService;
-    private RenderService renderService;
-    private UserService userService;
+
+    @Override
+    public Response getPages() {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    @Override
+    public Response createPage(Page page) {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
 
     @Override
     public Response deletePage(String id) {
@@ -56,116 +58,76 @@ public class DefaultPageResource impleme
     public Response getPage(String id) {
         logger.debug("Retrieving page for export: " + id);
         org.apache.rave.model.Page fromDb = pageService.getPage(id);
-        return fromDb == null ? 
Response.status(Response.Status.NOT_FOUND).build() : Response.ok(new 
Page(fromDb)).build();
-    }
-
-    @Override
-    public Response updatePage(String id, Page page) {
-        org.apache.rave.model.Page fromDb = pageService.updatePage(id, 
page.getName(), page.getPageLayoutCode());
-        return Response.ok(new Page(fromDb)).build();
-    }
-
-    @Override
-    public Response getPageOmdl(String id) {
-        return null;
-    }
-
-    @Override
-    public Response getPagesForRender(String context, String identifier) {
-        List<org.apache.rave.model.Page> pages;
-        if("portal".equals(context)) {
-            String userId = SELF.equals(identifier) ? 
userService.getAuthenticatedUser().getId() : identifier;
-            pages = pageService.getAllUserPages(userId);
-        } else if("profile".equals(context)) {
-            pages = 
Arrays.asList(pageService.getPersonProfilePage(identifier));
-        } else {
-            return Response.status(Response.Status.BAD_REQUEST).build();
+        if(fromDb == null) {
+            return Response.status(Response.Status.NOT_FOUND).build();
         }
-        List<Page> converted = Lists.newArrayList();
-        for(org.apache.rave.model.Page page : pages) {
-            Page convert = new Page(page);
-            converted.add(renderService.prepareForRender(convert));
+        else {
+            Page responsePage =  new Page(fromDb);
+
+            return Response.ok(new JsonResponseWrapper(responsePage)).build();
         }
-        return Response.ok(new PageList(converted)).build();
     }
 
     @Override
-    public Response getPageForRender(String context, String identifier, String 
id) {
-        return getPage(id);
-    }
+    public Response updatePage(String id, Page page) {
+        org.apache.rave.model.Page fromDb = pageService.updatePage(id, 
page.getName(), page.getPageLayoutCode());
+        Page responsePage =  new Page(fromDb);
 
-    @Override
-    public Response clonePage(String context, String identifier, String id) {
-        return null;
+        return Response.ok(new JsonResponseWrapper(responsePage)).build();
     }
 
     @Override
-    public Response importOmdlPage(String context, String identifier, File 
page) {
+    public Response getPageOmdl(String id) {
         return null;
     }
 
     @Override
-    public Response createPage(String context, String identifier, Page page) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response deletePageInContext(String id) {
+    public Response getPageRegions(String pageId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response updatePageInContext(String id, Page page) {
+    public Response createPageRegion(String pageId, Region region) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response movePage(String id, String moveAfterPageId) {
+    public Response getPageRegion(String id, String regionId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response addWidgetToPage(String id, RegionWidget widget) {
+    public Response updatePageRegion(String pageId, String regionId, Region 
region) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response removeWidgetFromPage(String id, String regionWidgetId) {
+    public Response deletePageRegion(String pageId, String regionId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response addWidgetToRegion(String id, String regionId, RegionWidget 
widget) {
+    public Response createPageRegionRegionWidget(String pageId, String 
regionId, RegionWidget regionWidget) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response moveWidgetOnPage(String id, String toRegionId, String 
regionWidgetId, int position) {
+    public Response getPageRegionRegionWidgets(String id, String regionId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response moveWidgetToPage(String targetPageId, String 
regionWidgetId) {
+    public Response getPageRegionRegionWidget(String id, String regionId, 
String regionWidgetId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response addMemberToPage(String id) {
+    public Response updatePageRegionRegionWidget(String pageId, String 
regionId, String regionWidgetId, RegionWidget regionWidget) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
     @Override
-    public Response removeMemberFromPage(String id, String userId) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response updateSharedPageStatus(String id, String userId, String 
status) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
-    }
-
-    @Override
-    public Response updatePageEditingStatus(String id, String userId, boolean 
editor) {
+    public Response deletePageRegionRegionWidget(String pageId, String 
regionId, String regionWidgetId) {
         return null;  //To change body of implemented methods use File | 
Settings | File Templates.
     }
 
@@ -173,14 +135,4 @@ public class DefaultPageResource impleme
     public void setPageService(PageService pageService) {
         this.pageService = pageService;
     }
-
-    @Inject
-    public void setRenderService(RenderService renderService) {
-        this.renderService = renderService;
-    }
-
-    @Inject
-    public void setUserService(UserService userService) {
-        this.userService = userService;
-    }
 }

Modified: 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/cxf-applicationContext.xml
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/cxf-applicationContext.xml?rev=1505802&r1=1505801&r2=1505802&view=diff
==============================================================================
--- 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/cxf-applicationContext.xml
 (original)
+++ 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/cxf-applicationContext.xml
 Mon Jul 22 20:51:00 2013
@@ -41,6 +41,7 @@
             <ref bean="peopleBean"/>
             <ref bean="usersBean"/>
             <ref bean="pagesBean" />
+            <ref bean="pagesForRenderBean" />
             <ref bean="categoriesBean"/>
         </jaxrs:serviceBeans>
     </jaxrs:server>
@@ -59,5 +60,6 @@
     </bean>
 
     <bean id="pagesBean" class="org.apache.rave.rest.impl.DefaultPageResource" 
autowire="byType" />
+    <bean id="pagesForRenderBean" 
class="org.apache.rave.rest.impl.DefaultPageForRenderResource" 
autowire="byType" />
 
 </beans>
\ No newline at end of file


Reply via email to