rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1171284 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/web/api/rest/PageApi.java test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java
Date Thu, 15 Sep 2011 21:42:07 GMT
Author: mfranklin
Date: Thu Sep 15 21:42:06 2011
New Revision: 1171284

URL: http://svn.apache.org/viewvc?rev=1171284&view=rev
Log:
Added Page API REST endpoint (Supports RAVE-256)

Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java?rev=1171284&r1=1171283&r2=1171284&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java
Thu Sep 15 21:42:06 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.rave.portal.web.api.rest;
 
+import org.apache.rave.portal.model.Page;
 import org.apache.rave.portal.service.PageService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -25,10 +26,7 @@ import org.springframework.beans.factory
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.util.ClassUtils;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -56,7 +54,13 @@ public class PageApi {
         
         // send a 204 back for success since there is no content being returned
         response.setStatus(HttpStatus.NO_CONTENT.value());
-    }    
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "{pageId}", method = RequestMethod.GET)
+    public Page getPage(@PathVariable long pageId) {
+        return pageService.getPage(pageId);
+    }
     
     // TODO RAVE-240 - when we implement security we can implement different exception
     //        handlers for different errors (unauthorized, resource not found, etc)

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java?rev=1171284&r1=1171283&r2=1171284&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java
(original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java
Thu Sep 15 21:42:06 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.rave.portal.web.api.rest;
 
+import org.apache.rave.portal.model.Page;
 import org.springframework.util.ClassUtils;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.http.HttpStatus;
@@ -48,6 +49,16 @@ public class PageApiTest {    
         pageService = createMock(PageService.class);
         pageApi = new PageApi(pageService);     
     }
+
+    @Test
+    public void getPage_validId() {
+        Page p = new Page();
+        expect(pageService.getPage(PAGE_ID)).andReturn(p).once();
+        replay(pageService);
+
+        Page returned = pageApi.getPage(PAGE_ID);
+        assertThat(returned, is(sameInstance(p)));
+    }
     
     @Test
     public void testDeletePage() {



Mime
View raw message