rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jc...@apache.org
Subject svn commit: r1094732 - in /incubator/rave/trunk: ./ rave-portal/ rave-portal/src/main/java/org/apache/rave/portal/model/ rave-portal/src/main/java/org/apache/rave/portal/repository/ rave-portal/src/main/java/org/apache/rave/portal/repository/impl/ rave...
Date Mon, 18 Apr 2011 20:34:16 GMT
Author: jcian
Date: Mon Apr 18 20:34:15 2011
New Revision: 1094732

URL: http://svn.apache.org/viewvc?rev=1094732&view=rev
Log:
Updated HomeController to fetch all pages for the current authenticated user, add them to
the model and render out the regions and widgets for the first page in the view.  Currently
using static mock data for the authenticated user (until we wire in real authentication) and
static mock data for repository layer.  Once we're all comfortable with where the current
code is heading (or no one strongly objects) we can go ahead and annotate the models and start
doing real persistence.

Added:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.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/service/impl/DefaultUserService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
Modified:
    incubator/rave/trunk/pom.xml
    incubator/rave/trunk/rave-portal/pom.xml
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Person.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageRepository.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/web/controller/HomeController.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp

Modified: incubator/rave/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/pom.xml?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/pom.xml (original)
+++ incubator/rave/trunk/pom.xml Mon Apr 18 20:34:15 2011
@@ -48,6 +48,7 @@
   <properties>
     <apache.shindig.version>2.0.2</apache.shindig.version>
     <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
+    <jstl.version>1.2</jstl.version>
     <javax.servlet.version>2.5</javax.servlet.version>
     <org.slf4j.version>1.6.1</org.slf4j.version>
     <log4j.version>1.2.16</log4j.version>
@@ -56,6 +57,13 @@
     <icu4j.version>4.6.1</icu4j.version>
   </properties>
 
+  <repositories>
+    <repository>
+      <id>java.net</id>
+      <url>http://download.java.net/maven/2/</url>
+    </repository>
+  </repositories>
+
   <!-- Global management of all dependencies -->
   <dependencyManagement>
     <dependencies>
@@ -70,6 +78,11 @@
         <artifactId>spring-webmvc</artifactId>
         <version>${org.springframework.version}</version>
       </dependency>
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>jstl</artifactId>
+        <version>${jstl.version}</version>
+      </dependency>
 
       <!-- Logging -->
       <dependency>
@@ -150,6 +163,12 @@
       <version>${junit.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <version>3.0</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
   <build>

Modified: incubator/rave/trunk/rave-portal/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/pom.xml?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/pom.xml (original)
+++ incubator/rave/trunk/rave-portal/pom.xml Mon Apr 18 20:34:15 2011
@@ -77,6 +77,12 @@
       <groupId>org.springframework</groupId>
       <artifactId>spring-webmvc</artifactId>
     </dependency>
+
+    <!-- JSTL -->
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>jstl</artifactId>
+    </dependency>
     
     <!-- Logging -->
     <dependency>

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Person.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Person.java?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Person.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Person.java
Mon Apr 18 20:34:15 2011
@@ -22,5 +22,24 @@ package org.apache.rave.portal.model;
  * A person
  */
 public class Person {
+    private String userId;
 
+    public Person() {
+    }
+
+    public Person(String userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * Gets the unique identifier for this user.
+     * @return The unique identifier for this user.
+     */
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
 }

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
Mon Apr 18 20:34:15 2011
@@ -20,11 +20,28 @@ package org.apache.rave.portal.model;
 
 import org.apache.rave.portal.model.util.InternationalString;
 
+import java.net.URL;
+
 /**
  * A widget
  */
 public class Widget {
+    private Long id;
     private InternationalString title;
+    private URL url;
+
+    /**
+     * Gets the persistence unique identifier
+     *
+     * @return id The ID of persisted object; null if not persisted
+     */
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
 
     public InternationalString getTitle() {
         return title;
@@ -33,4 +50,12 @@ public class Widget {
     public void setTitle(InternationalString title) {
         this.title = title;
     }
+
+    public URL getUrl() {
+        return url;
+    }
+
+    public void setUrl(URL url) {
+        this.url = url;
+    }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageRepository.java?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageRepository.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageRepository.java
Mon Apr 18 20:34:15 2011
@@ -18,5 +18,10 @@
  */
 package org.apache.rave.portal.repository;
 
+import org.apache.rave.portal.model.Page;
+
+import java.util.List;
+
 public interface PageRepository {
+    List<Page> getAllPages(String userId);
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java?rev=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,104 @@
+/*
+ * 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.repository.impl;
+
+import org.apache.rave.portal.model.*;
+import org.apache.rave.portal.model.util.InternationalString;
+import org.apache.rave.portal.model.util.LocalizedString;
+import org.apache.rave.portal.repository.PageRepository;
+import org.springframework.stereotype.Repository;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Repository
+public class JpaPageRepository implements PageRepository {
+
+    @Override
+    public List<Page> getAllPages(String userId) {
+        /**************************************************************************************************************
+         ***************************************************************************************************************
+         TODO: Returning a static set of mock data here while we decide if this model looks
right - if it does we can go
+         ahead and add JPA annotations to our models and start using real persistence.
+         ***************************************************************************************************************
+         **************************************************************************************************************/
+
+        long widgetId = 1;
+        Region region1 = new Region();
+        region1.setId(1L);
+        ArrayList<RegionWidget> region1Widgets = new ArrayList<RegionWidget>();
+        region1Widgets.add(getRegionWidget("http://www.labpixies.com/campaigns/todo/todo.xml",
"LabPixies Todo",
+                widgetId++));
+        region1Widgets.add(getRegionWidget("http://widgets.nytimes.com/packages/html/igoogle/topstories.xml",
+                "The New York Times", widgetId++));
+        region1.setRegionWidgets(region1Widgets);
+
+        Region region2 = new Region();
+        region2.setId(2L);
+        ArrayList<RegionWidget> region2Widgets = new ArrayList<RegionWidget>();
+        region2Widgets.add(getRegionWidget(
+                "http://www.flightstats.com/go/FlightStatus/AddGoogleHomePageFlightStatus.module",
"Flight Status",
+                widgetId++));
+        region2Widgets.add(getRegionWidget("http://hosting.gmodules.com/ig/gadgets/file/100674619146546250953/wsj.xml",
+                "The Wall Street Journal", widgetId++));
+        region2.setRegionWidgets(region2Widgets);
+
+        PageLayout pageLayout = new PageLayout();
+        pageLayout.setId(1L);
+        pageLayout.setCode("one-column");
+        pageLayout.setNumberOfRegions(1L);
+
+        Person person = new Person();
+        person.setUserId(userId);
+
+        Page page = new Page();
+        page.setId(1L);
+        page.setName("Default Page");
+        page.setOwner(person);
+        page.setRenderSequence(1L);
+        page.setPageLayout(pageLayout);
+        page.setRegions(Arrays.asList(region1, region2));
+
+        return Arrays.asList(page);
+    }
+
+    private RegionWidget getRegionWidget(String specificationUrl, String title, Long id)
{
+        Widget widget = new Widget();
+        InternationalString widgetTitle = new InternationalString();
+        widgetTitle.setLocalizedString(new LocalizedString(title, "en"));
+        widget.setTitle(widgetTitle);
+        widget.setId(id);
+        try {
+            widget.setUrl(new URL(specificationUrl));
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        }
+
+        RegionWidget regionWidget = new RegionWidget();
+        regionWidget.setId(id);
+        regionWidget.setWidget(widget);
+        regionWidget.setRenderPosition(String.valueOf(id));
+        regionWidget.setCollapsed(false);
+        return regionWidget;
+    }
+}
\ No newline at end of file

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=1094732&r1=1094731&r2=1094732&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
Mon Apr 18 20:34:15 2011
@@ -18,5 +18,16 @@
  */
 package org.apache.rave.portal.service;
 
+import org.apache.rave.portal.model.Page;
+
+import java.util.List;
+
 public interface PageService {
+    /**
+     * Gets all pages for the given user.
+     *
+     * @param userId The user to retrieve pages for.
+     * @return A non null possible empty list of pages for the given user.
+     */
+    List<Page> getAllPages(String userId);
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java?rev=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.service;
+
+import org.apache.rave.portal.model.Person;
+
+public interface UserService {
+    /**
+     * Get the currently authenticated user.
+     *
+     * @return The authenticated user.
+     */
+    Person getAuthenticatedUser();
+}
\ No newline at end of file

Added: 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=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageService.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.service.impl;
+
+import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.repository.PageRepository;
+import org.apache.rave.portal.service.PageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class DefaultPageService implements PageService {
+    private PageRepository pageRepository;
+
+    @Autowired
+    public DefaultPageService(PageRepository pageRepository) {
+        this.pageRepository = pageRepository;
+    }
+
+    @Override
+    public List<Page> getAllPages(String userId) {
+        return pageRepository.getAllPages(userId);
+    }
+}
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java?rev=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.service.impl;
+
+import org.apache.rave.portal.model.Person;
+import org.apache.rave.portal.service.UserService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DefaultUserService implements UserService {
+    @Override
+    public Person getAuthenticatedUser() {
+        //TODO: Returning mock data until we hook in real authentication
+        Person person = new Person();
+        person.setUserId("jcian");
+        return person;
+    }
+}
\ No newline at end of file

Modified: 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/HomeController.java?rev=1094732&r1=1094731&r2=1094732&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/HomeController.java
Mon Apr 18 20:34:15 2011
@@ -18,9 +18,18 @@
  */
 package org.apache.rave.portal.web.controller;
 
+import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.Person;
+import org.apache.rave.portal.service.PageService;
+import org.apache.rave.portal.service.UserService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.util.List;
+
 /**
  * Minimal Home Controller
  * 
@@ -28,8 +37,20 @@ import org.springframework.web.bind.anno
  */
 @Controller
 public class HomeController {
+    private PageService pageService;
+    private UserService userService;
+
+    @Autowired
+    public HomeController(PageService pageService, UserService userService) {
+        this.pageService = pageService;
+        this.userService = userService;
+    }
+
     @RequestMapping(value = "/")
-    public String getHome() {
+    public String getHome(Model model) {
+        Person user = userService.getAuthenticatedUser();
+        List<Page> pages = pageService.getAllPages(user.getUserId());
+        model.addAttribute(ModelKeys.PAGES, pages);
         return "home";
     }
-}
+}
\ No newline at end of file

Added: 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=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,24 @@
+/*
+ * 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.util;
+
+public class ModelKeys {
+    public final static String PAGES = "pages";
+}
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml?rev=1094732&r1=1094731&r2=1094732&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml Mon Apr
18 20:34:15 2011
@@ -28,7 +28,7 @@
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
   <!-- Scans the classpath of this application for @Components to deploy as beans -->
-  <context:component-scan base-package="org.apache.rave.portal.web" />
+  <context:component-scan base-package="org.apache.rave.portal" />
 
   <!-- Configures the @Controller programming model -->
   <mvc:annotation-driven />

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=1094732&r1=1094731&r2=1094732&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 Mon Apr 18 20:34:15
2011
@@ -18,12 +18,28 @@
   
   $Id$
 --%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<jsp:useBean id="pages" type="java.util.List<org.apache.rave.portal.model.Page>"
scope="request"/>
 <html>
 <head>
   <title>Rave Home</title>
 </head>
 <body>
-  <h1>Hello Rave!</h1>
-  <iframe src="/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml" width="250"
height="250" frameborder="0"></iframe>
+<h1>Hello Rave!</h1>
+<table>
+  <tr>
+    <c:forEach var="region" items="${pages[0].regions}">
+      <td>
+        <c:forEach var="regionWidget" items="${region.regionWidgets}">
+          <c:set var="widget" value="${regionWidget.widget}"/>
+          ${widget.title.defaultLocalizedString.value}
+          <br>
+          <iframe src="/gadgets/ifr?url=${widget.url}&view=home" width="250" height="250"
frameborder="0"></iframe>
+          <br><br>
+        </c:forEach>
+      </td>
+    </c:forEach>
+  </tr>
+</table>
 </body>
 </html>
\ No newline at end of file

Added: 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=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java
(added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/PageServiceTest.java
Mon Apr 18 20:34:15 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.service;
+
+import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.repository.PageRepository;
+import org.apache.rave.portal.service.impl.DefaultPageService;
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertThat;
+
+public class PageServiceTest {
+    private PageRepository pageRepository;
+    private PageService pageService;
+
+    @Before
+    public void setup() {
+        pageRepository = createNiceMock(PageRepository.class);
+        pageService = new DefaultPageService(pageRepository);
+    }
+
+    @Test
+    public void getAllPages() {
+        final String VALID_USER_ID = "jcian";
+        final List<Page> VALID_PAGES = new ArrayList<Page>();
+
+        expect(pageRepository.getAllPages(VALID_USER_ID)).andReturn(VALID_PAGES);
+        replay(pageRepository);
+
+        assertThat(pageService.getAllPages(VALID_USER_ID), CoreMatchers.sameInstance(VALID_PAGES));
+    }
+}
\ No newline at end of file

Added: 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/HomeControllerTest.java?rev=1094732&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
(added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
Mon Apr 18 20:34:15 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.controller;
+
+import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.Person;
+import org.apache.rave.portal.service.PageService;
+import org.apache.rave.portal.service.UserService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertThat;
+
+public class HomeControllerTest {
+    private UserService userService;
+    private PageService pageService;
+    private HomeController homeController;
+
+    @Before
+    public void setup() {
+        userService = createNiceMock(UserService.class);
+        pageService = createNiceMock(PageService.class);
+        homeController = new HomeController(pageService, userService);
+    }
+
+    @Test
+    public void getHome() {
+        final String VALID_USER_ID = "jcian";
+        final String VALID_VIEW = "home";
+        final Model MODEL = new ExtendedModelMap();
+        final List<Page> VALID_PAGES = new ArrayList<Page>();
+
+        expect(userService.getAuthenticatedUser()).andReturn(new Person(VALID_USER_ID));
+        replay(userService);
+
+        expect(pageService.getAllPages(VALID_USER_ID)).andReturn(VALID_PAGES);
+        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));
+    }
+}
\ No newline at end of file



Mime
View raw message