Author: mfranklin
Date: Thu Mar 28 13:16:32 2013
New Revision: 1462082
URL: http://svn.apache.org/r1462082
Log:
Added REST API definition for page RAVE-924
Added:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PageResource.java
Modified:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Page.java
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/PageUser.java
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/RegionWidget.java
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/marshall/XmlMapAdapter.java
Added:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PageResource.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PageResource.java?rev=1462082&view=auto
==============================================================================
---
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PageResource.java
(added)
+++
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/PageResource.java
Thu Mar 28 13:16:32 2013
@@ -0,0 +1,247 @@
+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.RegionWidget;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.File;
+
+public interface PageResource {
+
+ /**
+ * Deletes the given page
+ * @param id ID of the page on which the operation is to take place
+ * @return
+ */
+ @DELETE
+ @Path("/pages/{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("/pages/{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("/pages/{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("/pages/{id}")
+ @Produces({"application/vnd.omdl+xml"})
+ Response getPageOmdl(@PathParam("id") String id);
+
+
+ /**
+ * 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 identifier the target context identifier (username, group, etc)
+ * @return
+ */
+ @GET
+ @Path("/{context}/{identifier}/pages")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ 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 identifier the target context identifier (username, group, etc)
+ * @return
+ */
+ @GET
+ @Path("/{context}/{identifier}/pages/{id}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ 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}/pages/{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}/pages")
+ @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}/pages")
+ @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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{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}/pages/{id}/members/{userId}")
+ Response removeMemberFromPage(@PathParam("id") String id,
@PathParam("userId") String userId);
+
+ @PUT
+ @Path("/{context}/{identifier}/pages/{id}/members/{userId}/status")
+ Response updateSharedPageStatus(@PathParam("id") String id,
@PathParam("userId") String userId, String status);
+
+ @PUT
+ @Path("/{context}/{identifier}/pages/{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/model/Page.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Page.java?rev=1462082&r1=1462081&r2=1462082&view=diff
==============================================================================
---
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Page.java
(original)
+++
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Page.java
Thu Mar 28 13:16:32 2013
@@ -10,6 +10,7 @@ import java.util.List;
})
@XmlRootElement(name = "Page")
public class Page {
+
@XmlAttribute(name="id")
private String id;
@XmlElement(name="name")
Modified:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/PageUser.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/PageUser.java?rev=1462082&r1=1462081&r2=1462082&view=diff
==============================================================================
---
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/PageUser.java
(original)
+++
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/PageUser.java
Thu Mar 28 13:16:32 2013
@@ -9,15 +9,18 @@ import javax.xml.bind.annotation.*;
@XmlRootElement(name = "PageUser")
public class PageUser {
@XmlElement(name="editor")
- boolean editor;
+ private boolean editor;
+ @XmlElement(name = "status")
+ private String status;
@XmlElement(name="personId")
- String personId;
+ private String personId;
public PageUser() { }
public PageUser(org.apache.rave.model.PageUser member) {
this.editor = member.isEditor();
this.personId = member.getUserId();
+ this.status = member.getPageStatus().getPageStatus();
}
public boolean isEditor() {
@@ -35,4 +38,12 @@ public class PageUser {
public void setPersonId(String personId) {
this.personId = personId;
}
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
}
Modified:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/RegionWidget.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/RegionWidget.java?rev=1462082&r1=1462081&r2=1462082&view=diff
==============================================================================
---
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/RegionWidget.java
(original)
+++
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/RegionWidget.java
Thu Mar 28 13:16:32 2013
@@ -33,7 +33,7 @@ public class RegionWidget {
@XmlElement(name = "hideChrome")
private boolean hideChrome;
@XmlElement(name = "userPrefs")
- @XmlJavaTypeAdapter(value = XmlMapAdapter.class, type=Map.class)
+ @XmlJavaTypeAdapter(value = XmlMapAdapter.class)
private Map<String, String> userPrefs;
public RegionWidget() { }
Modified:
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/marshall/XmlMapAdapter.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/marshall/XmlMapAdapter.java?rev=1462082&r1=1462081&r2=1462082&view=diff
==============================================================================
---
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/marshall/XmlMapAdapter.java
(original)
+++
rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/marshall/XmlMapAdapter.java
Thu Mar 28 13:16:32 2013
@@ -38,9 +38,7 @@ public class XmlMapAdapter<E, T> extends
}
@XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "entry", propOrder = {
- "key", "value"
- })
+ @XmlType(name = "entry", propOrder = { "key", "value" })
public static class Entry<E, T> {
@XmlElement(name = "key")
@@ -74,9 +72,7 @@ public class XmlMapAdapter<E, T> extends
}
@XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "map", propOrder = {
- "entries"
- })
+ @XmlType(name = "map", propOrder = { "entries" })
@XmlRootElement(name = "map")
public static class EntryList<E, T> {