rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlu...@apache.org
Subject svn commit: r1159675 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/model/ main/java/org/apache/rave/portal/service/ main/java/org/apache/rave/portal/service/impl/ main/java/org/apache/rave/portal/web/api/rest/ main/java/o...
Date Fri, 19 Aug 2011 16:30:20 GMT
Author: carlucci
Date: Fri Aug 19 16:30:19 2011
New Revision: 1159675

URL: http://svn.apache.org/viewvc?rev=1159675&view=rev
Log:
RAVE-200: Delete a page
RAVE-204: View a page

These are sub tasks of RAVE-163: Page Management.  I realize I broke our rule of only doing atomic commits, but I had started down the path of doing Delete Page not realizing View Page hadn't been implemented.  

Added:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/PageController.java
      - copied, changed from r1158892, incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java
      - copied, changed from r1158892, incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
Removed:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
    incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
    incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css
    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js
    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_layout.js
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaPageRepositoryTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java
    incubator/rave/trunk/rave-portal/src/test/javascript/raveApiSpec.js

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java Fri Aug 19 16:30:19 2011
@@ -30,10 +30,13 @@ import java.util.List;
  * become more flexible to enable things like group ownership in the future).
  */
 @Entity
-@Table(name="page", uniqueConstraints=@UniqueConstraint(columnNames={"owner_id","name"}))
+@Table(name="page", uniqueConstraints={
+                        @UniqueConstraint(columnNames={"owner_id","name"}),
+                        @UniqueConstraint(columnNames={"owner_id","render_sequence"})}
+)
 @SequenceGenerator(name="pageIdSeq", sequenceName = "page_id_seq")
 @NamedQueries({
-        @NamedQuery(name = "Page.getByUserId", query="SELECT p FROM Page p WHERE p.owner.id = :userId")
+        @NamedQuery(name = "Page.getByUserId", query="SELECT p FROM Page p WHERE p.owner.id = :userId ORDER BY p.renderSequence")
 })
 @Access(AccessType.FIELD)
 public class Page implements BasicEntity, Serializable {
@@ -63,6 +66,10 @@ public class Page implements BasicEntity
 
     public Page() {
     }
+    
+    public Page(Long id) {
+        this.id = id;
+    }
 
     public Page(Long id, User owner) {
         this.id = id;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageService.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageService.java Fri Aug 19 16:30:19 2011
@@ -27,6 +27,14 @@ import org.apache.rave.portal.model.User
 
 public interface PageService {
     /**
+     * Gets a page based on the id
+     * 
+     * @param pageId to lookup
+     * @return the Page object 
+     */
+    Page getPage(long pageId);
+    
+    /**
      * Gets all pages for the given user.
      *
      * @param userId The user to retrieve pages for.
@@ -35,6 +43,15 @@ public interface PageService {
     List<Page> getAllPages(long userId);
     
     /**
+     * Return the page object from a list of pages given the pageId
+     * 
+     * @param pageId the pageId to look for
+     * @param pages a list of pages to search in
+     * @return the Page object representing the pageId, or null if not found
+     */
+    Page getPageFromList(long pageId, List<Page> pages);
+    
+    /**
      * Creates a new page with the supplied pageName and pageLayoutCode
      * 
      * @param pageName the name of the new page
@@ -62,6 +79,13 @@ public interface PageService {
     String getDefaultPageName();
     
     /**
+     * Deletes the page with the supplied pageId
+     * 
+     * @param pageId the pageId to delete
+     */
+    void deletePage(long pageId);
+    
+    /**
      * Moves a Region widget's position in a region or across regions
      *
      * @param regionWidgetId the id of the moved RegionWidget

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java Fri Aug 19 16:30:19 2011
@@ -69,11 +69,27 @@ public class DefaultPageService implemen
     }
 
     @Override
+    public Page getPage(long pageId) {
+        return pageRepository.get(pageId);
+    }
+    
+    @Override
     public List<Page> getAllPages(long userId) {
         return pageRepository.getAllPages(userId);
     }
     
     @Override
+    public Page getPageFromList(long pageId, List<Page> pages) {
+        Page pageToFind = new Page(pageId);
+        int index = pages.indexOf(pageToFind);
+        if (index == -1) {
+            return null;
+        } else {
+            return pages.get(index);
+        }        
+    }
+    
+    @Override
     @Transactional
     public Page addNewPage(String pageName, String pageLayoutCode) {                     
         return addNewPage(userService.getAuthenticatedUser(), pageName, pageLayoutCode);
@@ -92,6 +108,17 @@ public class DefaultPageService implemen
 
     @Override
     @Transactional
+    public void deletePage(long pageId) {                    
+        User user = userService.getAuthenticatedUser();
+        // first delete the page        
+        pageRepository.delete(pageRepository.get(pageId));
+        // now re-sequence the page sequence numbers
+        List<Page> pages = pageRepository.getAllPages(user.getId());
+        updatePageRenderSequences(pages);
+    }    
+    
+    @Override
+    @Transactional
     public RegionWidget moveRegionWidget(long regionWidgetId, int newPosition, long toRegion, long fromRegion) {
         Region target = getFromRepository(toRegion, regionRepository);
         if (toRegion == fromRegion) {
@@ -197,4 +224,18 @@ public class DefaultPageService implemen
         
         return page;
     }
+        
+    @Transactional(readOnly = false)
+    private void updatePageRenderSequences(List<Page> pages) {       
+        if (pages != null && !pages.isEmpty()) {
+            for (int i = 0; i < pages.size(); i++) {
+                Page p = pages.get(i);                
+                p.setRenderSequence((long)i+1);                               
+            }
+
+            for (Page page : pages) {
+                pageRepository.save(page);
+            }
+        }       
+    }
 }
\ No newline at end of file

Added: 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=1159675&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rest/PageApi.java Fri Aug 19 16:30:19 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rave.portal.web.api.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.rave.portal.service.PageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+/**
+ * Handler for all services exposed under the /api/rest/page path.
+ * 
+ * @author CARLUCCI
+ */
+@Controller(value="restPageApi")
+@RequestMapping("/api/rest/page/*")
+public class PageApi {
+    private static Logger logger = LoggerFactory.getLogger(PageApi.class);
+    private PageService pageService;
+    
+    @Autowired
+    public PageApi(PageService pageService) {
+        this.pageService = pageService;
+    }       
+          
+    @RequestMapping(value = "{pageId}", method = RequestMethod.DELETE)    
+    public void deletePage(@PathVariable long pageId, HttpServletResponse response) {
+        logger.debug("DELETE received for /api/rest/page/" + pageId);                              
+        pageService.deletePage(pageId);                               
+        
+        // send a 204 back for success since there is no content being returned
+        response.setStatus(HttpStatus.NO_CONTENT.value());
+    }    
+    
+    // TODO - when we implement security we can implement different exception
+    //        handlers for different errors (unauthorized, resource not found, etc)
+    @ExceptionHandler(Exception.class)
+    public String handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
+        logger.error("Error occured while accessing " + request.getRequestURL(), ex);        
+        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+        return ClassUtils.getShortName(ex.getClass());
+    }
+}
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java Fri Aug 19 16:30:19 2011
@@ -31,7 +31,7 @@ import org.springframework.web.bind.anno
 /**
  * Defines RPC operations for a Page or its components
  */
-@Controller
+@Controller(value="rpcPageApi")
 @RequestMapping(value = "/api/rpc/page/*")
 public class PageApi {
 

Copied: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/PageController.java (from r1158892, incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/PageController.java?p2=incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/PageController.java&p1=incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java&r1=1158892&r2=1159675&rev=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/PageController.java Fri Aug 19 16:30:19 2011
@@ -31,14 +31,21 @@ import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 /**
- * Minimal Home Controller
+ * Page Controller
  * 
- * @version $Id$
+ * @author carlucci
  */
 @Controller
-public class HomeController {
+//@RequestMapping(value={"/page/*","/index.html"})
+public class PageController {
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+         
     private PageService pageService;
     private UserService userService;
 
@@ -46,15 +53,30 @@ public class HomeController {
     private OpenSocialEnvironment openSocialEnvironment;
 
     @Autowired
-    public HomeController(PageService pageService, UserService userService) {
+    public PageController(PageService pageService, UserService userService) {
         this.pageService = pageService;
         this.userService = userService;
     }
-
-    @RequestMapping(value = {"/", "/index.html"})
-    public String getHome(Model model) {
+ 
+    @RequestMapping(value = {"/page/view", "/index.html"}, method = RequestMethod.GET)
+    public String viewDefault(Model model) {
+        User user = userService.getAuthenticatedUser();
+        List<Page> pages = pageService.getAllPages(user.getId());
+        model.addAttribute(ModelKeys.PAGE, pages.get(0));
+        model.addAttribute(ModelKeys.PAGES, pages);
+        model.addAttribute(ModelKeys.OPENSOCIAL_ENVIRONMENT, openSocialEnvironment);
+        return ViewNames.HOME;
+    }          
+    
+    @RequestMapping(value = "/page/view/{pageId}", method = RequestMethod.GET)
+    public String view(@PathVariable Long pageId, Model model) {
         User user = userService.getAuthenticatedUser();
+        logger.debug("attempting to get pageId " + pageId + " for " + user);
+        
         List<Page> pages = pageService.getAllPages(user.getId());
+        Page page = pageService.getPageFromList(pageId, pages);
+               
+        model.addAttribute(ModelKeys.PAGE, page);
         model.addAttribute(ModelKeys.PAGES, pages);
         model.addAttribute(ModelKeys.OPENSOCIAL_ENVIRONMENT, openSocialEnvironment);
         return ViewNames.HOME;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java Fri Aug 19 16:30:19 2011
@@ -24,6 +24,7 @@ package org.apache.rave.portal.web.util;
  */
 public class ModelKeys {
     private ModelKeys() {}
+    public static final String PAGE = "page"; // the current page object
     public static final String PAGES = "pages"; // a list of pages available for the current user
     public static final String ERROR_MESSAGE = "errorMessage"; // an error message to be reported to the user
     public static final String WIDGETS = "widgets"; // a list of widget objects

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java Fri Aug 19 16:30:19 2011
@@ -28,6 +28,6 @@ public class ViewNames {
     public static final String STORE = "store";
     public static final String WIDGET = "widget";
     public static final String NEW_ACCOUNT = "newaccount";
-	 public static final String USER_PROFILE = "userProfile";
+    public static final String USER_PROFILE = "userProfile";
     public static final String REDIRECT = "redirect:/";
 }

Modified: incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql (original)
+++ incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql Fri Aug 19 16:30:19 2011
@@ -121,7 +121,7 @@ INSERT INTO region_widget(id, widget_id,
 values (next value for region_widget_id_seq, @tabnews_widget_id, @page_1_region_2, 1, 'N');
 
 INSERT INTO page (id, name, owner_id, render_sequence, page_layout_id)
-values (set(@page_1_id, next value for page_id_seq), 'Social', @user_id_1, 1, @two_col_id);
+values (set(@page_1_id, next value for page_id_seq), 'Social', @user_id_1, 2, @two_col_id);
 
 INSERT INTO region(id, page_id)
 values (set(@page_1_region_1, next value for region_id_seq), @page_1_id);

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp Fri Aug 19 16:30:19 2011
@@ -28,16 +28,15 @@
 <jsp:useBean id="openSocialEnv" scope="request" type="org.apache.rave.provider.opensocial.config.OpenSocialEnvironment"/>
 <c:set var="opensocial_engine_url" value="${openSocialEnv.engineProtocol}://${openSocialEnv.engineRoot}${openSocialEnv.engineGadgetPath}"/>
 
-<rave:rave_generic_page pageTitle="Home - Rave">
-    <c:set var="defaultPage" value="${pages[0]}"/>
+<rave:rave_generic_page pageTitle="Rave - ${page.name}">    
     <div id="header">
         <div class="header-a">
             <a href="<spring:url value="/j_spring_security_logout" htmlEscape="true" />">Logout</a>
         </div>
         <div class="widget-a">
-            <a href="<spring:url value="/app/store?referringPageId=${defaultPage.id}" />">Widget Store</a>
+            <a href="<spring:url value="/app/store?referringPageId=${page.id}" />">Widget Store</a>
         </div>
-        <h1>Hello ${defaultPage.owner.username}, welcome to Rave!</h1>
+        <h1>Hello ${page.owner.username}, welcome to Rave!</h1>
     </div>
     <div id="dialog" title="Tab data" class="dialog">
         <form id="pageForm">
@@ -58,18 +57,18 @@
             </fieldset>
         </form>
     </div>
-    <button id="add_tab">Add Tab</button>
+    <button id="add_page">Add Page</button>
+    <%-- render the page tabs --%>
     <div id="tabs" class="rave-ui-tabs">
-    <ul class="rave-ui-tabs ui-tabs-nav">
-	<c:forEach var="page" items="${pages}">
-    		<li>
-				<a href="#page-${page.id}-id">${page.name}</a> <span class="ui-icon ui-icon-close">Remove Tab</span>
-			</li>
-	</c:forEach>
-	</ul>
-   <c:forEach var="page" items="${pages}">
-    	<div id="page-${page.id}-id">
-	    <c:forEach var="region" items="${page.regions}">
+        <c:forEach var="userPage" items="${pages}">
+             <div id="tab-${userPage.id}" class="rave-ui-tab<c:if test="${page.id == userPage.id}"> rave-ui-tab-selected</c:if>" onclick="rave.viewPage(${userPage.id});">
+                <span id="pageTitle-${userPage.id}" class="pageTitle">${userPage.name}</span><c:if test="${page.id == userPage.id}"><span class="ui-icon ui-icon-close">Remove Tab</span></c:if>
+            </div>
+        </c:forEach>        
+    </div>   
+    <%--render the main page content (regions/widgets) --%>
+    <div id="pageContent">
+        <c:forEach var="region" items="${page.regions}">
             <div class="region" id="region-${region.id}-id">
                 <c:forEach var="regionWidget" items="${region.regionWidgets}">
                     <div class="widget-wrapper" id="widget-${regionWidget.id}-wrapper">
@@ -96,10 +95,9 @@
                 </c:forEach>
             </div>
         </c:forEach>
-    	</div>
-         </c:forEach>
-        <div class="clear-float">&nbsp;</div>
     </div>
+
+    <div class="clear-float">&nbsp;</div>
     <script src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
     <script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
     <script src="//ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/jquery-ui.min.js"></script>
@@ -118,24 +116,20 @@
            Among other things, the render-widget tag will populate the widgets[] array.
            See the markup text in OpenSocialWidgetRenderer.java, for example.
         --%>
-        <c:forEach var="page" items="${pages}">
+
         <c:forEach var="region" items="${page.regions}">
-        <c:forEach var="regionWidget" items="${region.regionWidgets}">
-        <portal:render-widget regionWidget="${regionWidget}" />
-        </c:forEach>
-        </c:forEach>
+            <c:forEach var="regionWidget" items="${region.regionWidgets}">
+                <portal:render-widget regionWidget="${regionWidget}" />
+            </c:forEach>
         </c:forEach>
+
         $(function() {
             rave.setContext("<spring:url value="/app/" />");
             rave.initProviders();
             rave.initWidgets(widgets);
-            rave.initUI();
-        });
-        $(function() {
-    		$( "#tabs" ).tabs();
-    	});
-        
-        // initialize the page form validator
-        rave.forms.validateUserProfileForm();
+            rave.initUI();  
+            rave.layout.init();            
+            rave.forms.validateUserProfileForm();
+        });     
     </script>
 </rave:rave_generic_page>

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css Fri Aug 19 16:30:19 2011
@@ -449,10 +449,33 @@ label.error {
     float: none;
     margin: 0.5em 0 auto 120px;
 }
-
+/*
 .rave-ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: #F2F2F2; height: 800px; }
 .rave-ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; background: #666666}
 .rave-ui-tabs add_tab { cursor: pointer; }
+*/
+.rave-ui-tab {
+    background-color: #FFFFFF;
+    border: 1px solid #B4C4CF;
+    color: #767676;
+    cursor: pointer;
+    display: inline-block;
+    font-style: italic;
+    font-weight: normal;
+    padding: 2px 8px 4px;
+    position: relative;
+    top: 4px;    
+}
+
+.rave-ui-tab-selected {
+    background-color: #EFF3F5;
+    border-bottom: 1px solid #EFF3F5;
+    color: #000000;
+    font-style: normal;
+    font-weight: bold;
+}
+
+
 #tabs { margin-top: 1em; length: 95%; }
 #tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
 #dialog {
@@ -463,6 +486,4 @@ label.error {
 #dialog label { margin-top: 0.5em; }
 #dialog input { width: 95%; }
 #dialog textarea { width: 95%; }
-#add_tab { cursor: pointer; }
-
-
+#add_page { cursor: pointer; }

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave.js Fri Aug 19 16:30:19 2011
@@ -499,6 +499,11 @@ var rave = rave || (function() {
         return widgetByIdMap[regionWidgetId];
     }
 
+    function viewPage(pageId) {                
+        var fragment = (pageId != null) ? ("/" + pageId) : "";
+        window.location.href = rave.getContext() + "page/view" + fragment;      
+    }
+
     /**
      * Public API
      */
@@ -574,6 +579,13 @@ var rave = rave || (function() {
         /**
          * Gets a widget by id
          */
-        getWidgetById: getWidgetById
+        getWidgetById: getWidgetById,
+        
+        /**
+         * View a page
+         * 
+         * @param pageId the pageId to view, or if null, the user's default page
+         */
+        viewPage: viewPage
     }
 })();

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js Fri Aug 19 16:30:19 2011
@@ -66,10 +66,24 @@ rave.api = rave.api || (function() {
                 error: handleError
             });
         }
+        
+        function deletePage(args) {
+            $.ajax({
+                type: 'DELETE',
+                url: rave.getContext() + path + "page/" + args.pageId,                              
+                success: function(result) {
+                    if (typeof args.successCallback == 'function') {
+                        args.successCallback();
+                    }
+                },
+                error: handleError
+            });            
+        }
 
         return {
             saveWidgetPreferences : saveWidgetPreferences,
-            saveWidgetPreference : saveWidgetPreference
+            saveWidgetPreference : saveWidgetPreference,
+            deletePage : deletePage
         };
     })();
 
@@ -147,7 +161,7 @@ rave.api = rave.api || (function() {
                         }
                     } else {
                         if (typeof args.successCallback == 'function') {
-                            args.successCallback();
+                            args.successCallback(result);
                         }
                     }
                 }).error(handleError);

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_layout.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_layout.js?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_layout.js (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_layout.js Fri Aug 19 16:30:19 2011
@@ -16,21 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-$(function() {
-    var $tab_title_input = $( "#tab_title"),
+
+var rave = rave || {};
+rave.layout = rave.layout || (function() {
+    var $tab_title_input = $("#tab_title"),
         $page_layout_input = $("#pageLayout"),
-        $tab_content_input = $( "#tab_content" );
+        $tab_content_input = $("#tab_content");
         
-    var tab_counter = 2;
-    // tabs init with a custom tab template and an "add" callback filling in the content
-    var $tabs = $( "#tabs").tabs({
-            tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
-            add: function( event, ui ) {
-                    var tab_content = $tab_content_input.val() || "Tab " + tab_counter + " content.";
-                    $( ui.panel ).append( "<p>" + tab_content + "</p>" );
-            }
-    });
-
     // modal dialog init: custom buttons and a "close" callback reseting the form inside
     var $dialog = $( "#dialog" ).dialog({
             autoOpen: false,
@@ -50,8 +42,8 @@ $(function() {
                     $form[ 0 ].reset();
                     $("#pageFormErrors").html("");
             }
-    });
-
+    });        
+   
     // define the form object    
     var $form = $("#pageForm", $dialog);  
 
@@ -64,32 +56,37 @@ $(function() {
             // send the rpc request to create the new page
             rave.api.rpc.addPage({pageName: newPageTitle, 
                                   pageLayoutCode: newPageLayoutCode,
-                                  successCallback: function() { addPageCallback(newPageTitle); } 
-                                 });      
+                                  successCallback: function(result) {                                      
+                                      rave.viewPage(result.result.id); 
+                                  } 
+            });      
         }
     }
-        
-    function addPageCallback(newPageTitle) {
-        // add the new page tab to the list of pages
-        // TODO - in the future this should be changed to redirect to the new page after creating it
-        var pageTitle = newPageTitle;
-        $tabs.tabs("add", "#tabs-" + tab_counter, pageTitle);
-        tab_counter++;
-        
-        $dialog.dialog( "close" );
+    
+    function deletePage(pageId) {
+        // send the rpc request to delete the page
+        rave.api.rest.deletePage({pageId: pageId, successCallback: rave.viewPage});  
     }
-
-    // addTab button: just opens the dialog
-    $( "#add_tab" )
-            .button()
-            .click(function() {
-                    $dialog.dialog( "open" );
-            });
-
-    // close icon: removing the tab on click
-    // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
-    $( "#tabs span.ui-icon-close" ).live( "click", function() {
-            var index = $( "li", $tabs ).index( $( this ).parent() );
-            $tabs.tabs( "remove", index );
-    });
-});
\ No newline at end of file
+   
+    function init() {
+        // add_page button to open the dialog for creating a new page
+        $( "#add_page" )
+                .button()
+                .click(function() {
+                        $dialog.dialog( "open" );
+                });
+
+        // close icon: removing the tab on click
+        // TODO - move this into a common page menu in the future along with edit page, etc
+        $( "#tabs span.ui-icon-close" ).live( "click", function() {
+                var pageId = this.parentNode.id.replace("tab-","");            
+                deletePage(pageId);                       
+        });    
+    }
+   
+    // public rave.layout API
+    return {
+        init: init 
+    };
+    
+})();
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaPageRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaPageRepositoryTest.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaPageRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaPageRepositoryTest.java Fri Aug 19 16:30:19 2011
@@ -31,10 +31,7 @@ import org.springframework.test.context.
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.transaction.annotation.Transactional;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 @Transactional
@@ -60,6 +57,14 @@ public class JpaPageRepositoryTest {
         assertThat(pages.get(0).getRegions().size(), equalTo(2));
         assertThat(pages.get(0).getRegions().get(0).getRegionWidgets().size(), equalTo(2));
         assertThat(pages.get(0).getRegions().get(0).getRegionWidgets().get(0).getWidget().getUrl(), equalTo(WIDGET_URL));
+        
+        // test that the query returns the pages in proper render sequence order
+        Long lastRenderSequence = -1L;
+        for (Page p : pages) {
+            Long currentRenderSequence = p.getRenderSequence();
+            assertThat(currentRenderSequence > lastRenderSequence, is(true));
+            lastRenderSequence = currentRenderSequence;
+        }
     }
     @Test
     public void getAllPages_invalidUser_emptySet() {

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java Fri Aug 19 16:30:19 2011
@@ -52,16 +52,21 @@ public class PageServiceTest {
     private PageLayoutRepository pageLayoutRepository;
     private UserService userService;
 
-    private static final long REGION_WIDGET_ID = 5L;
-    private static final long TO_REGION_ID = 1L;
-    private static final long FROM_REGION_ID = 2L;
-    private static final String PAGE_LAYOUT_CODE = "layout1";
+    private final long REGION_WIDGET_ID = 5L;
+    private final long TO_REGION_ID = 1L;
+    private final long FROM_REGION_ID = 2L;
+    private final String PAGE_LAYOUT_CODE = "layout1";
+    private final long PAGE_ID = 1L;
+    private final long INVALID_PAGE_ID = -1L;
+            
     private Region targetRegion;
     private Region originalRegion;
     private Widget validWidget;
     private User user;
     private PageLayout pageLayout;
     private String defaultPageName = "Main";
+    private Page page;
+    private List<Page> pageList;
 
     @Before
     public void setup() {
@@ -98,6 +103,12 @@ public class PageServiceTest {
         pageLayout.setId(1L);
         pageLayout.setCode(PAGE_LAYOUT_CODE);
         pageLayout.setNumberOfRegions(3L);
+        
+        page = new Page(PAGE_ID, user);
+        
+        pageList = new ArrayList<Page>();        
+        pageList.add(new Page(99L));
+        pageList.add(page);
     }
 
     @Test
@@ -112,7 +123,7 @@ public class PageServiceTest {
     }
 
     @Test
-    public void createNewPage_noExistingPages() {
+    public void addNewPage_noExistingPages() {
         final String PAGE_NAME = "my new page";
         final Long EXPECTED_RENDER_SEQUENCE = 1L;
                       
@@ -142,7 +153,7 @@ public class PageServiceTest {
     }
     
     @Test
-    public void createNewPage_existingPages() {
+    public void addNewPage_existingPages() {
         final String PAGE_NAME = "my new page";
         final Long EXPECTED_RENDER_SEQUENCE = 2L;
         List<Page> existingPages = new ArrayList<Page>();
@@ -174,7 +185,7 @@ public class PageServiceTest {
     }    
    
     @Test
-    public void createNewDefaultPage() {
+    public void addNewDefaultPage() {
         final Long EXPECTED_RENDER_SEQUENCE = 1L;
                       
         Page expectedPage = new Page();
@@ -205,6 +216,30 @@ public class PageServiceTest {
     }
   
     @Test
+    public void deletePage() {               
+        expect(userService.getAuthenticatedUser()).andReturn(user);
+        expect(pageRepository.get(PAGE_ID)).andReturn(page);
+        replay(userService);
+        replay(pageRepository);
+        pageService.deletePage(PAGE_ID);
+        verify(userService);
+        verify(pageRepository);
+    }
+    
+    @Test
+    public void deletePage_invalidId() {               
+        final long INVALID_PAGE_ID = -999L;
+        
+        expect(userService.getAuthenticatedUser()).andReturn(user);
+        expect(pageRepository.get(INVALID_PAGE_ID)).andReturn(page);
+        replay(userService);
+        replay(pageRepository);
+        pageService.deletePage(INVALID_PAGE_ID);
+        verify(userService);
+        verify(pageRepository);
+    }    
+    
+    @Test
     public void moveRegionWidget_validMiddle() {
         final int newPosition = 0;
         createMoveBetweenRegionsExpectations();
@@ -296,7 +331,6 @@ public class PageServiceTest {
 
     @Test
     public void addWigetToPage_valid() {
-        final long PAGE_ID = 1L;
         final long WIDGET_ID = 1L;
 
         Page value = new Page();
@@ -326,7 +360,6 @@ public class PageServiceTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void addWidgetToPage_invalidWidget() {
-        long PAGE_ID = 1L;
         long WIDGET_ID = -1L;
         expect(pageRepository.get(PAGE_ID)).andReturn(new Page());
         expect(widgetRepository.get(WIDGET_ID)).andReturn(null);
@@ -339,7 +372,6 @@ public class PageServiceTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void addWidgetToPage_invalidPage() {
-        long PAGE_ID = 1L;
         long WIDGET_ID = -1L;
         expect(pageRepository.get(PAGE_ID)).andReturn(null);
         expect(widgetRepository.get(WIDGET_ID)).andReturn(new Widget());
@@ -380,7 +412,27 @@ public class PageServiceTest {
 
         pageService.removeWidgetFromPage(WIDGET_ID);
     }
+    
+    @Test
+    public void getPage() {
+        expect(pageRepository.get(PAGE_ID)).andReturn(page);
+        replay(pageRepository);
+          
+        assertThat(pageService.getPage(PAGE_ID), is(page));
+        
+        verify(pageRepository);
+    }
+    
+    @Test
+    public void getPageFromList() {
+        assertThat(pageService.getPageFromList(PAGE_ID, pageList), is(page));
+    }
 
+    @Test
+    public void getPageFromList_invalidId() {
+        assertThat(pageService.getPageFromList(INVALID_PAGE_ID, pageList), is(nullValue(Page.class)));
+    }
+    
     private void verifyPositions(int newPosition, RegionWidget widget, boolean sameRegion) {
         assertThat(widget.getRenderOrder(), is(equalTo(newPosition)));        
         assertOrder(originalRegion);

Added: 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=1159675&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java (added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rest/PageApiTest.java Fri Aug 19 16:30:19 2011
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rave.portal.web.api.rest;
+
+import org.springframework.util.ClassUtils;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.http.HttpStatus;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.apache.rave.portal.service.PageService;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+import static org.hamcrest.CoreMatchers.*;
+
+/**
+ *
+ * @author CARLUCCI
+ */
+public class PageApiTest {    
+    private PageApi pageApi;    
+    private PageService pageService;
+    private MockHttpServletRequest request;
+    private MockHttpServletResponse response;
+    
+    private final long PAGE_ID = 1L;
+    
+    @Before
+    public void setUp() {
+        request = new MockHttpServletRequest();
+        response = new MockHttpServletResponse();
+        pageService = createMock(PageService.class);
+        pageApi = new PageApi(pageService);     
+    }
+    
+    @Test
+    public void testDeletePage() {
+        pageService.deletePage(PAGE_ID);
+        expectLastCall();
+        replay(pageService);
+        
+        pageApi.deletePage(PAGE_ID, response);
+        
+        assertThat(response.getStatus(), is(HttpStatus.NO_CONTENT.value()));   
+        verify(pageService);
+    }
+    
+    @Test
+    public void tesHandleException() {
+        RuntimeException re = new RuntimeException("error");        
+        String value = pageApi.handleException(re, request, response);
+        
+        assertThat(value, is(ClassUtils.getShortName(re.getClass())));
+        assertThat(response.getStatus(), is(HttpStatus.INTERNAL_SERVER_ERROR.value()));   
+    }
+}

Copied: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java (from r1158892, incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java?p2=incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java&p1=incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java&r1=1158892&r2=1159675&rev=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java Fri Aug 19 16:30:19 2011
@@ -36,33 +36,67 @@ import java.util.List;
 import static org.easymock.EasyMock.*;
 import static org.junit.Assert.assertThat;
 
-public class HomeControllerTest {
+public class PageControllerTest {
     private UserService userService;
     private PageService pageService;
-    private HomeController homeController;
+    private PageController pageController;
+    
+    private Model model;
+    private Page defaultPage, otherPage;
+    private List<Page> allPages;
+    
+    private final Long DEFAULT_PAGE_ID = 99L;
+    private final Long OTHER_PAGE_ID = 22L;
+    private final Long USER_ID = 1L;
+    private final String HOME_VIEW = "home";
 
     @Before
     public void setup() {
-        userService = createNiceMock(UserService.class);
-        pageService = createNiceMock(PageService.class);
-        homeController = new HomeController(pageService, userService);
+        userService = createMock(UserService.class);
+        pageService = createMock(PageService.class);
+        pageController = new PageController(pageService, userService);
+        model = new ExtendedModelMap();
+        
+        defaultPage = new Page(DEFAULT_PAGE_ID);
+        otherPage = new Page(OTHER_PAGE_ID);
+        
+        allPages = new ArrayList<Page>();
+        allPages.add(defaultPage);   
+        allPages.add(otherPage);            
     }
 
     @Test
-    public void getHome() {
-        final Long VALID_USER_ID = 1L;
-        final String VALID_VIEW = "home";
-        final Model MODEL = new ExtendedModelMap();
-        final List<Page> VALID_PAGES = new ArrayList<Page>();
-
-        expect(userService.getAuthenticatedUser()).andReturn(new User(VALID_USER_ID));
-        replay(userService);
+    public void view_pageId() {
+        expect(userService.getAuthenticatedUser()).andReturn(new User(USER_ID)); 
+        expect(pageService.getAllPages(USER_ID)).andReturn(allPages);
+        expect(pageService.getPageFromList(OTHER_PAGE_ID, allPages)).andReturn(otherPage);
+        replay(userService);       
+        replay(pageService);
 
-        expect(pageService.getAllPages(VALID_USER_ID)).andReturn(VALID_PAGES);
+        String results = pageController.view(OTHER_PAGE_ID, model);
+        
+        assertThat(results, CoreMatchers.equalTo(HOME_VIEW));
+        assertThat((Page) model.asMap().get(ModelKeys.PAGE), CoreMatchers.sameInstance(otherPage));
+        assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), CoreMatchers.sameInstance(allPages));
+        
+        verify(userService);
+        verify(pageService);
+    }
+    
+    @Test
+    public void viewDefault_pageId() {
+        expect(userService.getAuthenticatedUser()).andReturn(new User(USER_ID)); 
+        expect(pageService.getAllPages(USER_ID)).andReturn(allPages);
+        replay(userService);       
         replay(pageService);
 
-        String results = homeController.getHome(MODEL);
-        assertThat(results, CoreMatchers.equalTo(VALID_VIEW));
-        assertThat((List<Page>) MODEL.asMap().get(ModelKeys.PAGES), CoreMatchers.sameInstance(VALID_PAGES));
+        String results = pageController.viewDefault(model);
+        
+        assertThat(results, CoreMatchers.equalTo(HOME_VIEW));
+        assertThat((Page) model.asMap().get(ModelKeys.PAGE), CoreMatchers.sameInstance(defaultPage));
+        assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), CoreMatchers.sameInstance(allPages));
+        
+        verify(userService);
+        verify(pageService);
     }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/test/javascript/raveApiSpec.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/javascript/raveApiSpec.js?rev=1159675&r1=1159674&r2=1159675&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/javascript/raveApiSpec.js (original)
+++ incubator/rave/trunk/rave-portal/src/test/javascript/raveApiSpec.js Fri Aug 19 16:30:19 2011
@@ -88,6 +88,28 @@ describe("Rave API", function() {
                 expect(callbackCalled).toBeTruthy();
             });
         });
+                
+        describe("deletePage", function() {
+            it("DELETEs the correct Page using the REST service", function() {
+                $.ajax = function(args) {
+                    expect(args.url).toEqual("api/rest/page/9");                                                  
+                    expect(typeof(callback)).toEqual("function");
+                    callback({error:false});
+                    return {
+                        error: function(a, b, c) {
+                        }
+                    }
+                };
+
+                var callbackCalled = false;
+                var callback = function() {
+                    callbackCalled = true
+                };
+                             
+                rave.api.rest.deletePage({pageId: 9, successCallback: callback});
+                expect(callbackCalled).toBeTruthy();
+            });
+        });                
     });
 
     describe("rpc", function() {



Mime
View raw message