rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpie...@apache.org
Subject svn commit: r1144091 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/model/ main/java/org/apache/rave/portal/repository/ main/java/org/apache/rave/portal/repository/impl/ main/java/org/apache/rave/portal/service/ main/java/...
Date Thu, 07 Jul 2011 23:08:58 GMT
Author: mpierce
Date: Thu Jul  7 23:08:58 2011
New Revision: 1144091

URL: http://svn.apache.org/viewvc?rev=1144091&view=rev
Log:
(RAVE-89) Creating a blank Page, Regions for newly registered user. Widgets can then be added
from the widget store.


Added:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/RegionService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionService.java
Removed:
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/NewAccountRequestReceived.jsp
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/model/PageLayout.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
    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/PageService.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/controller/NewAccountController.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java

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=1144091&r1=1144090&r2=1144091&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
Thu Jul  7 23:08:58 2011
@@ -51,7 +51,7 @@ public class Page {
     @JoinColumn(name="page_layout_id")
     private PageLayout pageLayout;
 
-    @OneToMany(fetch = FetchType.EAGER)
+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
     @JoinColumn(name="page_id")
     private List<Region> regions;
 

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/PageLayout.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/PageLayout.java?rev=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/PageLayout.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/PageLayout.java
Thu Jul  7 23:08:58 2011
@@ -27,6 +27,10 @@ import javax.persistence.*;
 @Entity
 @Table(name="page_layout")
 @SequenceGenerator(name="pageLayoutIdSeq", sequenceName = "page_layout_id_seq")
+@NamedQueries({
+    @NamedQuery(name="PageLayout.getByLayoutCode", query = "select pl from PageLayout pl
where pl.code = :code")
+})
+
 public class PageLayout {
     @Id @Column(name="id")
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "pageLayoutIdSeq")

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java?rev=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
Thu Jul  7 23:08:58 2011
@@ -20,4 +20,6 @@ package org.apache.rave.portal.repositor
 
 import org.apache.rave.portal.model.PageLayout;
 
-public interface PageLayoutRepository extends Repository<PageLayout> { }
\ No newline at end of file
+public interface PageLayoutRepository extends Repository<PageLayout> { 
+	 PageLayout getByPageLayoutCode(String codename);
+}
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java?rev=1144091&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
Thu Jul  7 23:08:58 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.commons.lang.NotImplementedException;
+import org.apache.rave.portal.model.PageLayout;
+import org.apache.rave.portal.repository.PageLayoutRepository;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+
+import static org.apache.rave.portal.repository.impl.util.JpaUtil.getSingleResult;
+import static org.apache.rave.portal.repository.impl.util.JpaUtil.saveOrUpdate;
+
+/**
+ */
+@Repository
+public class JpaPageLayoutRepository implements PageLayoutRepository{
+
+    @PersistenceContext
+    private EntityManager manager;
+
+    @Override
+    public PageLayout get(long layoutId) {
+        return manager.find(PageLayout.class, layoutId);
+    }
+	 
+	 @Override
+	 public PageLayout getByPageLayoutCode(String codename){
+		  TypedQuery<PageLayout>query = manager.createNamedQuery("PageLayout.getByLayoutCode",PageLayout.class);
+		  query.setParameter("code",codename);
+		  return getSingleResult(query.getResultList());
+	 }
+
+    @Override
+    public PageLayout save(PageLayout pageLayout) {
+		  return saveOrUpdate(pageLayout.getId(),manager,pageLayout);
+    }
+}

Modified: 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=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
Thu Jul  7 23:08:58 2011
@@ -29,6 +29,8 @@ import javax.persistence.PersistenceCont
 import javax.persistence.TypedQuery;
 import java.util.List;
 
+import static org.apache.rave.portal.repository.impl.util.JpaUtil.saveOrUpdate;
+
 @Repository
 public class JpaPageRepository implements PageRepository {
 
@@ -49,6 +51,7 @@ public class JpaPageRepository implement
 
     @Override
     public Page save(Page item) {
-        throw new NotImplementedException("Save is not implemented for this repository");
+		  return saveOrUpdate(item.getId(),manager,item);
+		  //        throw new NotImplementedException("Save is not implemented for this repository");
     }
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageLayoutService.java?rev=1144091&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
Thu Jul  7 23:08:58 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.PageLayout;
+
+public interface PageLayoutService {
+	 public PageLayout getPageLayoutByCode(String code);
+}
\ 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=1144091&r1=1144090&r2=1144091&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
Thu Jul  7 23:08:58 2011
@@ -60,4 +60,10 @@ public interface PageService {
 	  * @return the updated Region. //TODO need to make sure this is the right return.
 	  */
 	 Region removeWidgetFromPage(long regionWidgetId, long regionId);
+
+	 /**
+	  * Registers a new page. 
+	  * @param page the page object to register with the data management system.
+	  */
+	 void registerNewPage(Page page);
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/RegionService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/RegionService.java?rev=1144091&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/RegionService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/RegionService.java
Thu Jul  7 23:08:58 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.Region;
+
+public interface RegionService {
+
+	 /**
+	  * Register a new region
+	  * @param region the region object to register
+	  */
+	 void registerNewRegion(Region region);
+	 
+}

Modified: 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=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/UserService.java
Thu Jul  7 23:08:58 2011
@@ -44,6 +44,17 @@ public interface UserService extends Use
 
 	 /**
 	  * Registers a new user object.
+	  * @param user the new user object to register with the data management system.
 	  */
 	 void registerNewUser(User user);
+
+	 /**
+	  * Return the requested user object using the user's name.
+	  */ 
+	 User getUserByUsername(String userName);
+	 
+	 /**
+	  * Return a user object by the user ID.
+	  */
+	 User getUserById(Long id);
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java?rev=1144091&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
Thu Jul  7 23:08:58 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.PageLayout;
+import org.apache.rave.portal.service.PageLayoutService;
+import org.apache.rave.portal.repository.PageLayoutRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DefaultPageLayoutService implements PageLayoutService {
+	 private final PageLayoutRepository pageLayoutRepository;
+
+	 @Autowired
+	 public DefaultPageLayoutService(PageLayoutRepository pageLayoutRepository) {
+		  this.pageLayoutRepository=pageLayoutRepository;
+	 }
+
+	 @Override
+	 public PageLayout getPageLayoutByCode(String code) {
+		  return pageLayoutRepository.getByPageLayoutCode(code);
+	 }
+}
+

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=1144091&r1=1144090&r2=1144091&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
Thu Jul  7 23:08:58 2011
@@ -68,7 +68,6 @@ public class DefaultPageService implemen
 	 @Override
 	 @Transactional
 	 public Region removeWidgetFromPage(long regionWidgetId, long regionId){
-		  //TODO must implement.  Returns null for the time being.
         Region region = getFromRepository(regionId, regionRepository);
         return removeWidgetInstance(regionWidgetId, region);
 	 }
@@ -82,6 +81,12 @@ public class DefaultPageService implemen
         return createWidgetInstance(widget, region, 0);
     }
 
+	 @Override
+	 @Transactional
+	 public void registerNewPage(Page page) {
+		  pageRepository.save(page);
+	 }
+
     private RegionWidget createWidgetInstance(Widget widget, Region region, int position)
{
         RegionWidget regionWidget = new RegionWidget();
         regionWidget.setRenderOrder(position);

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionService.java?rev=1144091&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionService.java
(added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultRegionService.java
Thu Jul  7 23:08:58 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.Region;
+import org.apache.rave.portal.service.RegionService;
+import org.apache.rave.portal.repository.RegionRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class DefaultRegionService implements RegionService {
+	 
+	 private final RegionRepository regionRepository;
+	 
+	 @Autowired
+	 public DefaultRegionService(RegionRepository regionRepository) {
+		  this.regionRepository = regionRepository;
+	 }
+	 
+	 @Override
+	 @Transactional
+	 public void registerNewRegion(Region region) {
+		  regionRepository.save(region);
+	 }
+	 
+}
\ No newline at end of file

Modified: 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=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
Thu Jul  7 23:08:58 2011
@@ -113,4 +113,14 @@ public class DefaultUserService implemen
 	 public void registerNewUser(User user) {
 		  userRepository.save(user);
 	 }
+	 
+	 @Override
+	 public User getUserById(Long id) {
+		  return userRepository.get(id);
+	 }
+
+	 @Override
+	 public User getUserByUsername(String userName){
+		  return userRepository.getByUsername(userName);
+	 }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/NewAccountController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/NewAccountController.java?rev=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/NewAccountController.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/NewAccountController.java
Thu Jul  7 23:08:58 2011
@@ -20,9 +20,15 @@
 package org.apache.rave.portal.web.controller;
 
 import org.apache.rave.portal.service.UserService;
+import org.apache.rave.portal.service.PageService;
+import org.apache.rave.portal.service.PageLayoutService;
+import org.apache.rave.portal.service.RegionService;
 import org.apache.rave.portal.web.util.ModelKeys;
 import org.apache.rave.portal.web.util.ViewNames;
 import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.PageLayout;
+import org.apache.rave.portal.model.Region;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -30,22 +36,31 @@ import org.springframework.web.bind.anno
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
-
+import java.util.List;
+import java.util.ArrayList;
 
 @Controller
 @RequestMapping(value = { "/newaccount/*", "/newaccount" })
 public class NewAccountController {
 
     private final UserService userService;
-
+	 private final PageService pageService;
+	 private final PageLayoutService pageLayoutService;
+	 private final RegionService regionService;
+	 
     @Autowired
-    public NewAccountController(UserService userService) {
+    public NewAccountController(UserService userService, PageService pageService, PageLayoutService
pageLayoutService, RegionService regionService) {
         this.userService = userService;
+		  this.pageService = pageService;
+		  this.pageLayoutService = pageLayoutService;
+		  this.regionService = regionService;
     }
 
     @RequestMapping(method = RequestMethod.POST)
 	 //Needs to be specified by action.
-    public String create(Model model, @RequestParam String userName, @RequestParam String
password) {	  
+	 //TODO: have a more elegant way of adding a user
+	 public String create(Model model, @RequestParam String userName, @RequestParam String password)
{	  
+	 //Create a new user object and register it.
 		  User user=new User();
 		  user.setUsername(userName);
 		  user.setPassword(password);
@@ -53,9 +68,31 @@ public class NewAccountController {
 		  user.setLocked(false);
 		  user.setEnabled(true);
 		  userService.registerNewUser(user);
-								 
+		  
+		  //Return the newly registered user
+		  User registeredUser=userService.getUserByUsername(userName);
+		  
+		  //Create a PageLayout object.  We will default to 
+		  //the two-column layout
+		  PageLayout pageLayout=pageLayoutService.getPageLayoutByCode("columns_2");
+
+		  //Create regions
+		  List<Region> regions=new ArrayList<Region>();
+		  Region region1=new Region();
+		  Region region2=new Region();
+		  regions.add(region1);
+		  regions.add(region2);
+
+		  //Create a Page object and register it.
+		  Page page=new Page();
+		  page.setName("main");
+		  page.setOwner(registeredUser);
+		  page.setPageLayout(pageLayout);
+		  page.setRenderSequence(1L);
+								 page.setRegions(regions);
+		  pageService.registerNewPage(page);
+
         return "redirect:/";
     }
-		  
 
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java?rev=1144091&r1=1144090&r2=1144091&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java
(original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java
Thu Jul  7 23:08:58 2011
@@ -22,6 +22,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+
 import java.util.ArrayList;
 import java.util.List;
 



Mime
View raw message