You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by lr...@apache.org on 2011/06/04 06:58:10 UTC

svn commit: r1131334 - in /incubator/photark/branches/photark-rest: photark-filesystem/src/main/java/org/apache/photark/services/filesystem/ photark-filesystem/src/test/java/org/apache/photark/services/filesystem/ photark-jcr/src/test/java/org/apache/p...

Author: lresende
Date: Sat Jun  4 06:58:10 2011
New Revision: 1131334

URL: http://svn.apache.org/viewvc?rev=1131334&view=rev
Log:
Updating gallery service rest api definition and consumers

Modified:
    incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java
    incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java
    incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java
    incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/GalleryService.java

Modified: incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java?rev=1131334&r1=1131333&r2=1131334&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java (original)
+++ incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java Sat Jun  4 06:58:10 2011
@@ -156,7 +156,7 @@ public class FileSystemGallery implement
         this.albums.put(newAlbum.getName(), newAlbum);
     }
 
-    public void updateAlbum(Album album)  throws PhotarkRuntimeException {
+    public void updateAlbum(String albumId, Album album)  throws PhotarkRuntimeException {
         if(album.getName() == null || album.getName().isEmpty()) {
             throw new InvalidParameterException("Album has no name");
         }

Modified: incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java?rev=1131334&r1=1131333&r2=1131334&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java (original)
+++ incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java Sat Jun  4 06:58:10 2011
@@ -51,6 +51,7 @@ import com.meterware.httpunit.WebRespons
  */
 public class FileSystemGalleryTestCase {
     private static final String GALLERY_SERVICE_URL = "http://localhost:8085/gallery";
+    private static final String ALBUM_SERVICE_URL = GALLERY_SERVICE_URL + "/albums";
 
     private static Node node;
 
@@ -92,7 +93,7 @@ public class FileSystemGalleryTestCase {
     @Test
     public void testRemoveAlbums() throws IOException, JSONException {
         WebConversation wc = new WebConversation();
-        WebRequest request = new GetMethodWebRequest(GALLERY_SERVICE_URL + "/" + getLastAlbumName());
+        WebRequest request = new GetMethodWebRequest(ALBUM_SERVICE_URL + "/" + getLastAlbumName());
         ((GetMethodWebRequest) request).setMethod("DELETE");
         WebResponse response = wc.getResource(request);
 
@@ -103,11 +104,11 @@ public class FileSystemGalleryTestCase {
     private void addAlbum() throws IOException, JSONException {
         JSONObject jsonAlbum = new JSONObject();
         jsonAlbum.put("name", getNewAlbumName());
-        jsonAlbum.put("location", "http://localhost:8080/gallery/album/Boston");
+        jsonAlbum.put("location", ALBUM_SERVICE_URL + "/Boston");
         jsonAlbum.put("description", "Some description goes here");
 
         WebConversation wc = new WebConversation();
-        WebRequest request   = new PostMethodWebRequest(GALLERY_SERVICE_URL, new ByteArrayInputStream(jsonAlbum.toString().getBytes("UTF-8")),"application/json");
+        WebRequest request   = new PostMethodWebRequest(ALBUM_SERVICE_URL, new ByteArrayInputStream(jsonAlbum.toString().getBytes("UTF-8")),"application/json");
         request.setHeaderField("Content-Type", "application/json");
         WebResponse response = wc.getResource(request);
 
@@ -116,7 +117,7 @@ public class FileSystemGalleryTestCase {
 
     private String[] readAlbums()  throws IOException, JSONException {
         WebConversation wc = new WebConversation();
-        WebRequest request = new GetMethodWebRequest(GALLERY_SERVICE_URL);
+        WebRequest request = new GetMethodWebRequest(ALBUM_SERVICE_URL);
         WebResponse response = wc.getResource(request);
 
         JSONObject jsonResponse = new JSONObject(response.getText());

Modified: incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java?rev=1131334&r1=1131333&r2=1131334&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java (original)
+++ incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java Sat Jun  4 06:58:10 2011
@@ -27,6 +27,7 @@ import com.meterware.httpunit.WebRespons
 
 public class JCRGalleryTestCase {
     private static final String GALLERY_SERVICE_URL = "http://localhost:8085/gallery";
+    private static final String ALBUM_SERVICE_URL = GALLERY_SERVICE_URL + "/albums";
 
     private static Node node;
 
@@ -77,7 +78,7 @@ public class JCRGalleryTestCase {
     @Test
     public void testRemoveAlbums() throws IOException, JSONException {
         WebConversation wc = new WebConversation();
-        WebRequest request = new GetMethodWebRequest(GALLERY_SERVICE_URL + "/" + getLastAlbumName());
+        WebRequest request = new GetMethodWebRequest(ALBUM_SERVICE_URL + "/" + getLastAlbumName());
         ((GetMethodWebRequest) request).setMethod("DELETE");
         WebResponse response = wc.getResource(request);
 
@@ -91,7 +92,7 @@ public class JCRGalleryTestCase {
         jsonAlbum.put("description", "Some description to my album : " + albumName);
 
         WebConversation wc = new WebConversation();
-        WebRequest request   = new PostMethodWebRequest(GALLERY_SERVICE_URL, new ByteArrayInputStream(jsonAlbum.toString().getBytes("UTF-8")),"application/json");
+        WebRequest request   = new PostMethodWebRequest(ALBUM_SERVICE_URL, new ByteArrayInputStream(jsonAlbum.toString().getBytes("UTF-8")),"application/json");
         request.setHeaderField("Content-Type", "application/json");
         WebResponse response = wc.getResource(request);
 
@@ -100,7 +101,7 @@ public class JCRGalleryTestCase {
 
     private String[] readAlbums()  throws IOException, JSONException {
         WebConversation wc = new WebConversation();
-        WebRequest request = new GetMethodWebRequest(GALLERY_SERVICE_URL);
+        WebRequest request = new GetMethodWebRequest(ALBUM_SERVICE_URL);
         WebResponse response = wc.getResource(request);
 
         JSONObject jsonResponse = new JSONObject(response.getText());

Modified: incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/GalleryService.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/GalleryService.java?rev=1131334&r1=1131333&r2=1131334&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/GalleryService.java (original)
+++ incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/GalleryService.java Sat Jun  4 06:58:10 2011
@@ -46,6 +46,7 @@ public interface GalleryService {
      * @return
      */
     @GET
+    @Path("/albums")
     @Produces(MediaType.APPLICATION_JSON)
     AlbumList getAlbums() throws PhotarkRuntimeException;
 
@@ -57,7 +58,7 @@ public interface GalleryService {
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
-    @Path("{id}")
+    @Path("/albums/{id}")
     Album getAlbum(@PathParam("id") String albumId) throws PhotarkRuntimeException;
 
     /**
@@ -66,6 +67,7 @@ public interface GalleryService {
      * @throws PhotarkRuntimeException
      */
     @POST
+    @Path("/albums")
     @Consumes(MediaType.APPLICATION_JSON)
     void addAlbum(Album newAlbum) throws PhotarkRuntimeException;
 
@@ -75,8 +77,9 @@ public interface GalleryService {
      * @throws PhotarkRuntimeException
      */
     @PUT
+    @Path("/albums/{id}")
     @Consumes(MediaType.APPLICATION_JSON)
-    void updateAlbum(Album album) throws PhotarkRuntimeException;
+    void updateAlbum(@PathParam("id") String albumId, Album album) throws PhotarkRuntimeException;
 
     /**
      * Delete an existing album
@@ -84,6 +87,6 @@ public interface GalleryService {
      * @throws PhotarkRuntimeException
      */
     @DELETE
-    @Path("{id}")
+    @Path("/albums/{id}")
     void removeAlbum(@PathParam("id") String albumId) throws PhotarkRuntimeException;
 }