You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2012/02/16 23:22:07 UTC
svn commit: r1245216 - in /incubator/rave/trunk:
rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/
rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/
rave-components/rave-web/src/test/java/org/apache/rav...
Author: mfranklin
Date: Thu Feb 16 22:22:07 2012
New Revision: 1245216
URL: http://svn.apache.org/viewvc?rev=1245216&view=rev
Log:
Applying patch for RAVE-457
Added:
incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp
Modified:
incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java
incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/ProfileControllerTest.java
incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties
incubator/rave/trunk/rave-portal-resources/src/main/resources/messages_nl.properties
incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp
Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/ProfileController.java Thu Feb 16 22:22:07 2012
@@ -37,11 +37,7 @@ import org.springframework.beans.factory
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
+import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping(value = {"/userInfo/*", "/userInfo", "/userInfo/"})
@@ -55,6 +51,26 @@ public class ProfileController {
public ProfileController(UserService userService) {
this.userService = userService;
}
+
+ /**
+ * Views the main page of another user's profile
+ *
+ * @param username username (allows for a period in the username)
+ * @param model {@link Model} map
+ * @param referringPageId page reference id (optional)
+ * @return the view name of the user profile page
+ */
+ @RequestMapping(value = {"/person/{username:.*}"}, method = RequestMethod.GET)
+ public String setUpPersonProfile(@PathVariable String username, ModelMap model, @RequestParam(required=false) Long referringPageId) {
+ logger.debug("Initializing User Info page");
+
+ User user = userService.getUserByUsername(username);
+
+ //set the posts tag page as default for first setup
+ addAttributesToModel(model, user, referringPageId, ViewNames.ABOUT_TAG_PAGE);
+
+ return ViewNames.ALL_USER_INFO;
+ }
/**
* Views the main page of the user profile
@@ -65,14 +81,14 @@ public class ProfileController {
*/
@RequestMapping(method = RequestMethod.GET)
public String setUpForm(ModelMap model,
- @RequestParam long referringPageId) {
+ @RequestParam Long referringPageId) {
logger.debug("Initializing User Info page");
User user = userService.getAuthenticatedUser();
//set the posts tag page as default for first setup
addAttributesToModel(model, user, referringPageId, ViewNames.ABOUT_TAG_PAGE);
-
+
return ViewNames.USER_INFO;
}
@@ -86,7 +102,7 @@ public class ProfileController {
*/
@RequestMapping(method = RequestMethod.POST)
public String updateUserProfile(ModelMap model,
- @RequestParam long referringPageId,
+ @RequestParam Long referringPageId,
@ModelAttribute("updatedUser") User updatedUser) {
logger.debug("Updating User's profile information");
@@ -112,7 +128,7 @@ public class ProfileController {
/*
* Function to add attributes to model map
*/
- private void addAttributesToModel(ModelMap model, User user, long referringPageId, String defaultTagPage) {
+ private void addAttributesToModel(ModelMap model, User user, Long referringPageId, String defaultTagPage) {
model.addAttribute(ModelKeys.USER_PROFILE, user);
model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId);
model.addAttribute(ModelKeys.DEFAULT_TAG_PAGE, defaultTagPage);
Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java Thu Feb 16 22:22:07 2012
@@ -35,6 +35,7 @@ public class ViewNames {
public static final String NEW_ACCOUNT = USER_PREFIX + "newaccount";
public static final String USER_PROFILE = USER_PREFIX + "userProfile";
public static final String USER_INFO = USER_PREFIX + "profile";
+ public static final String ALL_USER_INFO = USER_PREFIX + "personProfile";
public static final String ADMIN_HOME = ADMIN_PREFIX + "home";
public static final String ADMIN_PREFERENCES = ADMIN_PREFIX + "preferences";
@@ -54,4 +55,4 @@ public class ViewNames {
public static String getPageView(String layoutName) {
return new StringBuilder(PAGE).append(".").append(layoutName).toString();
}
-}
\ No newline at end of file
+}
Modified: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/ProfileControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/ProfileControllerTest.java?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/ProfileControllerTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/ProfileControllerTest.java Thu Feb 16 22:22:07 2012
@@ -50,18 +50,18 @@ private ProfileController userInfoContro
}
@Test
- public void setUpForm_ShouldAddAttributeForAuthenticatedUser() {
- //creating a mock authenticated user
- final User authUser = new User();
+ public void setUpPersonProfile_ShouldAddAttributeForUser() {
+ //creating a mock user
+ final User user = new User();
final ModelMap model = new ModelMap();
final int modelSize = 3;
- final long referringPageId = 1L;
+ final String username="Canonical";
String userProfile = new String(ModelKeys.USER_PROFILE);
- expect(userService.getAuthenticatedUser()).andReturn(authUser).anyTimes();
+ expect(userService.getUserByUsername(username)).andReturn(user).anyTimes();
replay(userService);
- userInfoController.setUpForm(model, referringPageId);
+ userInfoController.setUpPersonProfile(username, model, null);
//assert that the model is not null
assertThat(model, CoreMatchers.notNullValue());
@@ -77,6 +77,35 @@ private ProfileController userInfoContro
verify(userService);
}
+
+ @Test
+ public void setUpForm_ShouldAddAttributeForAuthenticatedUser() {
+ //creating a mock authenticated user
+ final User authUser = new User();
+ final ModelMap model = new ModelMap();
+ final int modelSize = 3;
+ final long referringPageId = 1L;
+ String userProfile = new String(ModelKeys.USER_PROFILE);
+
+ expect(userService.getAuthenticatedUser()).andReturn(authUser).anyTimes();
+ replay(userService);
+
+ userInfoController.setUpForm(model, referringPageId);
+
+ //assert that the model is not null
+ assertThat(model, CoreMatchers.notNullValue());
+
+ //assert that the model size is three
+ assertThat(model.size(), CoreMatchers.equalTo(modelSize));
+
+ //assert that the model does contain an attribute associated with the authenticated user after setUpForm() is called
+ assertThat(model.containsAttribute(userProfile), CoreMatchers.equalTo(true));
+
+ //assert that the model does not contain authenticated user as null
+ assertThat(model.get(userProfile), CoreMatchers.notNullValue());
+
+ verify(userService);
+ }
@Test
public void updateUserProfile_ShouldUpdateAuthenticatedUser() {
Modified: incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/resources/messages.properties Thu Feb 16 22:22:07 2012
@@ -167,6 +167,25 @@ page.profile.edit.option=Edit Your Profi
page.profile.save=Save
page.profile.cancel=Cancel
+page.personProfile.title={0}''s Profile
+page.personProfile.personal.info=Personal Information
+page.personProfile.first.name=First Name:
+page.personProfile.last.name=Last Name:
+page.personProfile.display.name=Display Name:
+page.personProfile.basic.info=Basic Information
+page.personProfile.about.me=About Me:
+page.personProfile.status=Status:
+page.personProfile.contact.info=Contact Information
+page.personProfile.email=Email ID:
+page.personProfile.posts=Posts
+page.personProfile.posts.page=/WEB-INF/jsp/views/profile_posts.jsp
+page.personProfile.about=About
+page.personProfile.about.page=/WEB-INF/jsp/views/profile_about.jsp
+page.personProfile.widgets=Widgets
+page.personProfile.widgets.page=/WEB-INF/jsp/views/profile_widgets.jsp
+page.personProfile.find.friends=Find Friends
+page.personProfile.friends.page=/WEB-INF/jsp/views/profile_friend_finder.jsp
+
admin.home.title=Rave admin interface
admin.home.shorttitle=Home
admin.home.subtitle=Welcome to the Rave admin interface
Modified: incubator/rave/trunk/rave-portal-resources/src/main/resources/messages_nl.properties
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/resources/messages_nl.properties?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/resources/messages_nl.properties (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/resources/messages_nl.properties Thu Feb 16 22:22:07 2012
@@ -178,6 +178,29 @@ page.profile.edit.option=Hun uw profiel
page.profile.save=Behalve
page.profile.cancel=annuleren
+page.personProfile.title=Profiel van {0}
+page.personProfile.personal.info=Persoonsgegevens
+page.personProfile.first.name=Voornaam:
+page.personProfile.last.name=Achternaam:
+page.personProfile.display.name=Naam te bezien:
+page.personProfile.basic.info=Algemene informatie
+page.personProfile.about.me=Over mij:
+page.personProfile.status=Burgerlijke staat:
+page.personProfile.contact.info=Contact informatie
+page.personProfile.email=E-mail:
+page.personProfile.posts=Posten
+page.personProfile.posts.page=/WEB-INF/jsp/views/profile_posts.jsp
+page.personProfile.about=Over mij
+page.personProfile.about.page=/WEB-INF/jsp/views/profile_about.jsp
+page.personProfile.widgets=Widgets
+page.personProfile.widgets.page=/WEB-INF/jsp/views/profile_widgets.jsp
+page.personProfile.find.friends=Vinden vrienden
+page.personProfile.friends.page=/WEB-INF/jsp/views/profile_friend_finder.jsp
+page.personProfile.edit=Hun
+page.personProfile.edit.option=Hun uw profiel hier
+page.personProfile.save=Behalve
+page.personProfile.cancel=annuleren
+
admin.home.title=Rave admin interface
admin.home.shorttitle=Home
admin.home.subtitle=Welkom in de Rave admin interface
Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp?rev=1245216&r1=1245215&r2=1245216&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp Thu Feb 16 22:22:07 2012
@@ -23,6 +23,7 @@ under the License.
<%-- Expose any attributes defined in the tiles-defs.xml to the request scope for use in other tiles --%>
<tiles:importAttribute scope="request"/>
<c:set var="profileTitleKey" value="page.profile.title" />
+<c:set var="personProfileTitleKey" value="page.personProfile.title" />
<%--@elvariable id="page" type="org.apache.rave.portal.model.Page"--%>
<!DOCTYPE html>
<html>
@@ -40,6 +41,11 @@ under the License.
<fmt:param><c:out value="${userProfile.displayName}" /></fmt:param>
</fmt:message>
</c:when>
+ <c:when test="${pageTitleKey == personProfileTitleKey}">
+ <fmt:message key="${pageTitleKey}">
+ <fmt:param><c:out value="${userProfile.displayName}" /></fmt:param>
+ </fmt:message>
+ </c:when>
<c:otherwise>
<fmt:message key="${pageTitleKey}"/>
</c:otherwise>
Added: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp?rev=1245216&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp (added)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/personProfile.jsp Thu Feb 16 22:22:07 2012
@@ -0,0 +1,107 @@
+<%--
+ 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.
+
+ Description:
+ User's information display and edit options
+ --%>
+
+<%@ page language="java" trimDirectiveWhitespaces="true" %>
+<%@ page errorPage="/WEB-INF/jsp/views/error.jsp" %>
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
+<fmt:setBundle basename="messages"/>
+<jsp:useBean id="userProfile" type="org.apache.rave.portal.model.User" scope="request"/>
+
+<!-- get the display name of user -->
+<fmt:message key="page.personProfile.title" var="pageTitle">
+ <fmt:param><c:out value="${userProfile.displayName}" /></fmt:param>
+</fmt:message>
+<tiles:putAttribute name="pageTitleKey" value="${pageTitle}"/>
+<tiles:importAttribute name="pageTitleKey" scope="request"/>
+
+<!-- get the title of personal information -->
+<fmt:message key="page.personProfile.personal.info" var="personalInfo"/>
+
+<!-- get the title of basic information -->
+<fmt:message key="page.personProfile.basic.info" var="basicInfo"/>
+
+<!-- get the title of contact information -->
+<fmt:message key="page.personProfile.contact.info" var="contactInfo"/>
+
+<header>
+ <nav class="topnav">
+ <ul class="horizontal-list">
+ <li>
+ <c:choose>
+ <c:when test="${empty referringPageId}">
+ <spring:url value="/index.html" var="gobackurl"/>
+ </c:when>
+ <c:otherwise>
+ <spring:url value="/app/page/view/${referringPageId}" var="gobackurl"/>
+ </c:otherwise>
+ </c:choose>
+ <a href="<c:out value="${gobackurl}"/>"><fmt:message key="page.general.back"/></a>
+ </li>
+ <sec:authorize url="/app/admin/">
+ <li>
+ <a href="<spring:url value="/app/admin/"/>">
+ <fmt:message key="page.general.toadmininterface"/>
+ </a>
+ </li>
+ </sec:authorize>
+ <li>
+ <a href="<spring:url value="/j_spring_security_logout" htmlEscape="true" />">
+ <fmt:message key="page.general.logout"/></a>
+ </li>
+ </ul>
+ </nav>
+ <h1>${pageTitle}</h1>
+</header>
+<div id="content">
+ <!-- Display personal information of user-->
+ <h2><fmt:message key="page.personProfile.personal.info" /></h2>
+ <p>
+ <fmt:message key="page.personProfile.first.name"/>
+ <c:out value="${userProfile.givenName}"/>
+ </p>
+ <p>
+ <fmt:message key="page.personProfile.last.name"/>
+ <c:out value="${userProfile.familyName}"/>
+ </p>
+ <p>
+ <fmt:message key="page.personProfile.display.name"/>
+ <c:out value="${userProfile.displayName}"/>
+ </p>
+
+ <!-- Display basic information of user -->
+ <h2><fmt:message key="page.personProfile.basic.info" /></h2>
+ <p>
+ <fmt:message key="page.personProfile.about.me"/>
+ <c:out value=" ${userProfile.aboutMe}"/>
+ </p>
+ <p>
+ <fmt:message key="page.personProfile.status"/>
+ <c:out value=" ${userProfile.status}"/>
+ </p>
+
+ <!-- Display contact information of user -->
+ <h2><fmt:message key="page.personProfile.contact.info" /></h2>
+ <p>
+ <fmt:message key="page.personProfile.email"/>
+ <c:out value=" ${userProfile.email}"/>
+ </p>
+</div>