rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r1201750 - in /incubator/rave/trunk: rave-components/rave-core/src/main/java/org/apache/rave/portal/model/ rave-components/rave-core/src/test/java/org/apache/rave/portal/model/ rave-components/rave-web/src/main/java/org/apache/rave/portal/w...
Date Mon, 14 Nov 2011 15:30:51 GMT
Author: jasha
Date: Mon Nov 14 15:30:51 2011
New Revision: 1201750

URL: http://svn.apache.org/viewvc?rev=1201750&view=rev
Log:
RAVE-355 basic preference management (with a few TODOs that will be picked up tomorrow)

Added:
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/PortalPreferenceController.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/PortalPreferenceForm.java
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/PortalPreferenceFormTest.java
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferencedetail.jsp
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferences.jsp
      - copied, changed from r1201232, incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/home.jsp
Modified:
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/WidgetCommentTest.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.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/views/admin/userdetail.jsp
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java
Mon Nov 14 15:30:51 2011
@@ -35,6 +35,7 @@ import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -139,6 +140,17 @@ public class PortalPreference implements
         throw new NotSupportedException("Cannot return single value for a List of size "
+ values.size());
     }
 
+    /**
+     * Sets a single value for a preference. Will overwrite any exisiting value(s)
+     *
+     * @param value String value of the preference
+     */
+    public void setValue(String value) {
+        List<String> values = new ArrayList<String>();
+        values.add(value);
+        this.values = values;
+    }
+
 
     @Override
     public boolean equals(Object obj) {

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java
Mon Nov 14 15:30:51 2011
@@ -66,6 +66,17 @@ public class PortalPreferenceTest {
         assertEquals(VALUES, preference.getValues());
     }
 
+    @Test
+    public void testSetValues() throws Exception {
+        PortalPreference preference = new PortalPreference(KEY, VALUES);
+        assertEquals(KEY, preference.getKey());
+        assertEquals(VALUES, preference.getValues());
+        preference.setValue("tree");
+        assertEquals("tree", preference.getValue());
+        assertEquals(1, preference.getValues().size());
+    }
+
+
     @Test(expected = NotSupportedException.class)
     public void getValueFailsForMultiValue() {
         PortalPreference preference = new PortalPreference(KEY, VALUES);

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/WidgetCommentTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/WidgetCommentTest.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/WidgetCommentTest.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/WidgetCommentTest.java
Mon Nov 14 15:30:51 2011
@@ -15,11 +15,15 @@
  */
 package org.apache.rave.portal.model;
 
-import java.util.Date;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import java.util.Date;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  *
@@ -58,14 +62,14 @@ public class WidgetCommentTest {
     
     @Test
     public void utility() {
+        assertNotNull(widgetComment);
+
         String toString = widgetComment.toString();
         assertNotNull(toString);
-        assertTrue(toString instanceof String);
-        
+
         int hashCode = widgetComment.hashCode();
         assertEquals(hashCode, widgetComment.hashCode());
-        
-        assertFalse(widgetComment.equals(null));
+
         assertFalse(widgetComment.equals(new WidgetComment()));
         assertFalse(widgetComment.equals(new String()));
         assertFalse(new WidgetComment().equals(widgetComment));

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java
(original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/AdminControllerUtil.java
Mon Nov 14 15:30:51 2011
@@ -48,6 +48,10 @@ public final class AdminControllerUtil {
         }
     }
 
+    static boolean isDeleteOrUpdate(String action) {
+        return "update".equals(action) || "delete".equals(action);
+    }
+
     static void addNavigationMenusToModel(String selectedItem, Model model) {
         final NavigationMenu topMenu = getTopMenu();
         model.addAttribute(topMenu.getName(), topMenu);
@@ -83,6 +87,10 @@ public final class AdminControllerUtil {
         widgets.setSelected("widgets".equals(selectedItem));
         menu.addNavigationItem(widgets);
 
+        NavigationItem preferences = new NavigationItem("admin.preferences.shorttitle", "/app/admin/preferences");
+        preferences.setSelected("preferences".equals(selectedItem));
+        menu.addNavigationItem(preferences);
+
         return menu;
     }
 

Added: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/PortalPreferenceController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/PortalPreferenceController.java?rev=1201750&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/PortalPreferenceController.java
(added)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/PortalPreferenceController.java
Mon Nov 14 15:30:51 2011
@@ -0,0 +1,98 @@
+/*
+ * 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.admin;
+
+import org.apache.rave.portal.model.PortalPreference;
+import org.apache.rave.portal.service.PortalPreferenceService;
+import org.apache.rave.portal.web.model.PortalPreferenceForm;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.ViewNames;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+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.SessionAttributes;
+import org.springframework.web.bind.support.SessionStatus;
+
+import java.util.Map;
+
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.checkTokens;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.isDeleteOrUpdate;
+
+/**
+ * Controller for portal preferences
+ * TODO RAVE-355 create unit tests
+ */
+@Controller
+@SessionAttributes({"preferenceForm", ModelKeys.TOKENCHECK})
+public class PortalPreferenceController {
+    private static final String SELECTED_ITEM = "preferences";
+
+    @Autowired
+    private PortalPreferenceService preferenceService;
+
+    @RequestMapping(value = {"/admin/preferences", "/admin/preferences/"}, method = RequestMethod.GET)
+    public String viewPreferences(@RequestParam(required = false) final String action, Model
model) {
+        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        
+        final Map<String, PortalPreference> preferenceMap = preferenceService.getPreferencesAsMap();
+
+        model.addAttribute("preferenceMap", preferenceMap);
+
+        if (isDeleteOrUpdate(action)) {
+            model.addAttribute("actionresult", action);
+        }
+
+        return ViewNames.ADMIN_PREFERENCES;
+    }
+
+    @RequestMapping(value = "/admin/preferencedetail/edit", method = RequestMethod.GET)
+    public String editPreferences(Model model) {
+        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        final Map<String, PortalPreference> preferenceMap = preferenceService.getPreferencesAsMap();
+
+        PortalPreferenceForm form = new PortalPreferenceForm(preferenceMap);
+        model.addAttribute("preferenceForm", form);
+        model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken());
+
+        return ViewNames.ADMIN_PREFERENCE_DETAIL;
+    }
+
+    @RequestMapping(value = "/admin/preferencedetail/update", method = RequestMethod.POST)
+    public String updatePreferences(@ModelAttribute("preferenceForm") PortalPreferenceForm
form, BindingResult result,
+                                    @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken,
+                                    @RequestParam() String token,
+                                    ModelMap modelMap,
+                                    SessionStatus status) {
+        checkTokens(sessionToken, token, status);
+        preferenceService.savePreference(form.getPageSize());
+        preferenceService.savePreference(form.getTitleSuffix());
+
+        modelMap.clear();
+        status.setComplete();
+        return "redirect:/app/admin/preferences?action=update";
+    }
+
+}

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
(original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
Mon Nov 14 15:30:51 2011
@@ -45,6 +45,9 @@ import org.springframework.web.bind.supp
 import java.beans.PropertyEditorSupport;
 
 import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.DEFAULT_PAGE_SIZE;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.addNavigationMenusToModel;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.checkTokens;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.isDeleteOrUpdate;
 
 /**
  * Admin controller to manipulate User data
@@ -74,7 +77,7 @@ public class UserController {
     public String viewUsers(@RequestParam(required = false, defaultValue = "0") int offset,
                             @RequestParam(required = false) final String action,
                             Model model) {
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<User> users = userService.getLimitedListOfUsers(offset,
DEFAULT_PAGE_SIZE);
         model.addAttribute(ModelKeys.SEARCHRESULT, users);
 
@@ -85,14 +88,10 @@ public class UserController {
         return ViewNames.ADMIN_USERS;
     }
 
-    private boolean isDeleteOrUpdate(String action) {
-        return "update".equals(action) || "delete".equals(action);
-    }
-
     @RequestMapping(value = "/admin/users/search", method = RequestMethod.GET)
     public String searchUsers(@RequestParam(required = true) String searchTerm,
                               @RequestParam(required = false, defaultValue = "0") int offset,
Model model) {
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<User> users = userService.getUsersByFreeTextSearch(
                 searchTerm, offset, DEFAULT_PAGE_SIZE);
         model.addAttribute(ModelKeys.SEARCH_TERM, searchTerm);
@@ -102,7 +101,7 @@ public class UserController {
 
     @RequestMapping(value = "/admin/userdetail/{userid}", method = RequestMethod.GET)
     public String viewUserDetail(@PathVariable("userid") Long userid, Model model) {
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         model.addAttribute(userService.getUserById(userid));
         model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken());
         return ViewNames.ADMIN_USERDETAIL;
@@ -114,7 +113,7 @@ public class UserController {
                                    @RequestParam() String token,
                                    ModelMap modelMap,
                                    SessionStatus status) {
-        AdminControllerUtil.checkTokens(sessionToken, token, status);
+        checkTokens(sessionToken, token, status);
         userProfileValidator.validate(user, result);
         if (result.hasErrors()) {
             AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, (Model) modelMap);
@@ -133,7 +132,7 @@ public class UserController {
                                    @RequestParam(required = false) String confirmdelete,
                                    ModelMap modelMap,
                                    SessionStatus status) {
-        AdminControllerUtil.checkTokens(sessionToken, token, status);
+        checkTokens(sessionToken, token, status);
         if (!Boolean.parseBoolean(confirmdelete)) {
             AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, (Model) modelMap);
             modelMap.addAttribute("missingConfirm", true);

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
(original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
Mon Nov 14 15:30:51 2011
@@ -43,6 +43,9 @@ import org.springframework.web.bind.supp
 
 import static org.apache.rave.portal.model.WidgetStatus.values;
 import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.DEFAULT_PAGE_SIZE;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.addNavigationMenusToModel;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.checkTokens;
+import static org.apache.rave.portal.web.controller.admin.AdminControllerUtil.isDeleteOrUpdate;
 
 /**
  * Admin controller to manipulate Widget data
@@ -68,7 +71,7 @@ public class WidgetController {
     public String viewWidgets(@RequestParam(required = false, defaultValue = "0") int offset,
                               @RequestParam(required = false) final String action,
                               Model model) {
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<Widget> widgets =
                 widgetService.getLimitedListOfWidgets(offset, DEFAULT_PAGE_SIZE);
         model.addAttribute(ModelKeys.SEARCHRESULT, widgets);
@@ -80,16 +83,12 @@ public class WidgetController {
         return ViewNames.ADMIN_WIDGETS;
     }
 
-    private boolean isDeleteOrUpdate(String action) {
-        return "update".equals(action) || "delete".equals(action);
-    }
-
     @RequestMapping(value = "/admin/widgets/search", method = RequestMethod.GET)
     public String searchWidgets(@RequestParam(required = false) String searchTerm,
                                 @RequestParam(required = false) String widgettype,
                                 @RequestParam(required = false) String widgetstatus,
                                 @RequestParam(required = false, defaultValue = "0") int offset,
Model model) {
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<Widget> widgets = widgetService.getWidgetsBySearchCriteria(searchTerm,
widgettype,
                 widgetstatus, offset, DEFAULT_PAGE_SIZE);
         model.addAttribute(ModelKeys.SEARCHRESULT, widgets);
@@ -101,7 +100,7 @@ public class WidgetController {
 
     @RequestMapping(value = "/admin/widgetdetail/{widgetid}", method = RequestMethod.GET)
     public String viewWidgetDetail(@PathVariable("widgetid") Long widgetid, Model model)
{
-        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, model);
+        addNavigationMenusToModel(SELECTED_ITEM, model);
         model.addAttribute(widgetService.getWidget(widgetid));
         model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken());
         return ViewNames.ADMIN_WIDGETDETAIL;
@@ -113,10 +112,10 @@ public class WidgetController {
                                      @RequestParam String token,
                                      ModelMap modelMap,
                                      SessionStatus status) {
-        AdminControllerUtil.checkTokens(sessionToken, token, status);
+        checkTokens(sessionToken, token, status);
         widgetValidator.validate(widget, result);
         if (result.hasErrors()) {
-            AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, (Model) modelMap);
+            addNavigationMenusToModel(SELECTED_ITEM, (Model) modelMap);
             return ViewNames.ADMIN_WIDGETDETAIL;
         }
         widgetService.updateWidget(widget);

Added: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/PortalPreferenceForm.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/PortalPreferenceForm.java?rev=1201750&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/PortalPreferenceForm.java
(added)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/model/PortalPreferenceForm.java
Mon Nov 14 15:30:51 2011
@@ -0,0 +1,74 @@
+/*
+ * 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.model;
+
+import org.apache.rave.portal.model.PortalPreference;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Form object for portal preferences
+ */
+public class PortalPreferenceForm {
+
+    public static final String KEY_PAGE_SIZE = "pageSize";
+    public static final String DEFAULT_PAGE_SIZE = "10";
+
+    public static final String KEY_TITLE_SUFFIX = "titleSuffix";
+    public static final String DEFAULT_TITLE_SUFFIX = "- Rave";
+
+
+    private Map<String, PortalPreference> preferenceMap;
+    
+    public PortalPreferenceForm() {
+        // TODO RAVE-355 populate preferences if they don't exist in the db
+        this(new HashMap<String, PortalPreference>());
+    }
+
+    public PortalPreferenceForm(Map<String, PortalPreference> preferenceMap) {
+        super();
+        this.preferenceMap = preferenceMap;
+    }
+
+    public PortalPreference getPageSize() {
+        return preferenceMap.get(KEY_PAGE_SIZE);
+    }
+
+    public void setPageSize(PortalPreference pageSize) {
+        preferenceMap.put(KEY_PAGE_SIZE, pageSize);
+    }
+
+    public PortalPreference getTitleSuffix() {
+        return preferenceMap.get(KEY_TITLE_SUFFIX);
+    }
+
+    public void setTitleSuffix(PortalPreference titleSuffix) {
+        preferenceMap.put(KEY_TITLE_SUFFIX, titleSuffix);
+    }
+
+    public Map<String, PortalPreference> getPreferenceMap() {
+        return preferenceMap;
+    }
+
+    public void setPreferenceMap(Map<String, PortalPreference> preferenceMap) {
+        this.preferenceMap = preferenceMap;
+    }
+}

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=1201750&r1=1201749&r2=1201750&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
Mon Nov 14 15:30:51 2011
@@ -35,6 +35,8 @@ public class ViewNames {
     public static final String USER_PROFILE = "userProfile";
 
     public static final String ADMIN_HOME = "admin/home";
+    public static final String ADMIN_PREFERENCES = "admin/preferences";
+    public static final String ADMIN_PREFERENCE_DETAIL = "admin/preferencedetail";
     public static final String ADMIN_USERS = "admin/users";
     public static final String ADMIN_USERDETAIL = "admin/userdetail";
     public static final String ADMIN_WIDGETS = "admin/widgets";

Added: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/PortalPreferenceFormTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/PortalPreferenceFormTest.java?rev=1201750&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/PortalPreferenceFormTest.java
(added)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/model/PortalPreferenceFormTest.java
Mon Nov 14 15:30:51 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.model;
+
+import org.apache.rave.portal.model.PortalPreference;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static org.apache.rave.portal.web.model.PortalPreferenceForm.KEY_PAGE_SIZE;
+import static org.apache.rave.portal.web.model.PortalPreferenceForm.KEY_TITLE_SUFFIX;
+
+/**
+ * Test for {@link PortalPreferenceForm}
+ */
+public class PortalPreferenceFormTest {
+    private Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
+
+    @Before
+    public void setUp() throws Exception {
+        PortalPreference titlePref = new PortalPreference(KEY_TITLE_SUFFIX, "Test portal");
+        preferenceMap.put(KEY_TITLE_SUFFIX, titlePref);
+        PortalPreference pageSizePref = new PortalPreference(KEY_PAGE_SIZE, "20");
+        preferenceMap.put(KEY_PAGE_SIZE, pageSizePref);
+    }
+
+    @Test
+    public void testEmptyConstructor() throws Exception {
+        PortalPreferenceForm form = new PortalPreferenceForm();
+        assertNull(form.getPageSize());
+        assertNull(form.getTitleSuffix());
+        assertTrue(form.getPreferenceMap().isEmpty());
+    }
+
+    @Test
+    public void testPopulatedForm() throws Exception {
+        PortalPreferenceForm form = new PortalPreferenceForm(preferenceMap);
+        assertEquals("Test portal", form.getTitleSuffix().getValue());
+        assertEquals("20", form.getPageSize().getValue());
+    }
+}

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=1201750&r1=1201749&r2=1201750&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 Mon
Nov 14 15:30:51 2011
@@ -151,6 +151,13 @@ admin.widgetdetail.editdata=Edit widget 
 admin.widgetdetail.updatebutton=Update widget
 admin.widgetdetail.action.delete.success=The widget has been removed
 admin.widgetdetail.action.update.success=The widget has been updated
+admin.preferences.title=Rave admin interface - Preferences
+admin.preferences.shorttitle=Preferences
+admin.preferencedetail.titleSuffix=Page title suffix
+admin.preferencedetail.pageSize=Number of items per page (list)
+admin.preferencedetail.updateButton=Update preferences
+admin.preferencedetail.action.update.success=Preferences have been updated
+admin.preferencedetail.goback=\u00AB Back to overview
 admin.clearsearch=Clear search
 admin.delete=Delete
 

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=1201750&r1=1201749&r2=1201750&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 Mon
Nov 14 15:30:51 2011
@@ -151,6 +151,13 @@ admin.widgetdetail.editdata=Pas widget g
 admin.widgetdetail.updatebutton=Update widget
 admin.widgetdetail.action.delete.success=De widget is verwijderd
 admin.widgetdetail.action.update.success=De widget is bijgewerkt
+admin.preferences.title=Rave admin interface - Voorkeuren
+admin.preferences.shorttitle=Voorkeuren
+admin.preferencedetail.titleSuffix=Toevoeging pagina titel
+admin.preferencedetail.pageSize=Aantal items per pagina (lijst)
+admin.preferencedetail.updateButton=Wijzig voorkeuren
+admin.preferencedetail.action.update.success=De voorkeuren zijn bijgewerkt
+admin.preferencedetail.goback=\u00AB Terug naar overzicht
 admin.clearsearch=Maak zoekveld leeg
 admin.delete=Verwijder
 

Added: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferencedetail.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferencedetail.jsp?rev=1201750&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferencedetail.jsp
(added)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferencedetail.jsp
Mon Nov 14 15:30:51 2011
@@ -0,0 +1,74 @@
+<%--
+  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.
+  --%>
+<%@ page language="java" trimDirectiveWhitespaces="true" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
+<fmt:setBundle basename="messages"/>
+
+<fmt:message key="admin.preferences.title" var="pagetitle"/>
+<rave:rave_generic_page pageTitle="${pagetitle}">
+    <rave:header pageTitle="${pagetitle}"/>
+    <rave:admin_tabsheader/>
+    <div class="pageContent">
+        <article class="admincontent">
+            <ul class="horizontal-list goback">
+                <li><a href="<spring:url value="/app/admin/preferences"/>">
+                    <fmt:message key="admin.preferencedetail.goback"/></a>
+                </li>
+            </ul>
+            <h2><fmt:message key="admin.preferences.shorttitle"/></h2>
+
+            <div class="leftcolumn">
+                <section class="formbox">
+                    <spring:url value="/app/admin/preferencedetail/update" var="formAction"/>
+                    <form:form action="${formAction}" method="POST" modelAttribute="preferenceForm">
+                        <form:errors cssClass="error" element="p"/>
+                        <fieldset>
+                            <input type="hidden" name="token" value="<c:out value="${tokencheck}"/>"/>
+
+                            <p>
+                                <form:label path="titleSuffix.value"><fmt:message
key="admin.preferencedetail.titleSuffix"/></form:label>
+                                <form:input path="titleSuffix.value"/>
+                                <form:errors path="titleSuffix.value" cssClass="error"/>
+                            </p>
+                        </fieldset>
+                        <fieldset>
+                            <p>
+                                <spring:bind path="pageSize.value">
+                                    <label for="pageSize"><fmt:message key="admin.preferencedetail.pageSize"/></label>
+                                    <input id="pageSize" name="pageSize.value" type="number"
step="1"
+                                           value="<c:out value="${status.value}"/>"/>
+                                </spring:bind>
+                                <form:errors path="pageSize.value" cssClass="error"/>
+                            </p>
+                        </fieldset>
+                        <fieldset>
+                            <fmt:message key="admin.preferencedetail.updateButton" var="updateButtonText"/>
+                            <input type="submit" value="${updateButtonText}"/>
+                        </fieldset>
+                    </form:form>
+                </section>
+                <div class="clear-float">
+
+                </div>
+
+            </div>
+        </article>
+    </div>
+</rave:rave_generic_page>
\ No newline at end of file

Copied: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferences.jsp
(from r1201232, incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/home.jsp)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferences.jsp?p2=incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferences.jsp&p1=incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/home.jsp&r1=1201232&r2=1201750&rev=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/home.jsp
(original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/preferences.jsp
Mon Nov 14 15:30:51 2011
@@ -17,24 +17,48 @@
   under the License.
   --%>
 <%@ page language="java" trimDirectiveWhitespaces="true" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-<%@ taglib tagdir="/WEB-INF/tags" prefix="rave" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
 <fmt:setBundle basename="messages"/>
 
-<fmt:message key="admin.home.title" var="pagetitle"/>
+<fmt:message key="admin.preferences.title" var="pagetitle"/>
 <rave:rave_generic_page pageTitle="${pagetitle}">
     <rave:header pageTitle="${pagetitle}"/>
     <rave:admin_tabsheader/>
     <div class="pageContent">
         <article class="admincontent">
-            <h2><fmt:message key="admin.home.subtitle"/></h2>
-            <fmt:message key="admin.home.intro"/>
-            <div class="clear-float">
+            <c:if test="${actionresult eq 'delete' or actionresult eq 'update'}">
+                <div class="alert-message success">
+                    <p>
+                        <fmt:message key="admin.preferencedetail.action.${actionresult}.success"/>
+                    </p>
+                </div>
+            </c:if>
 
-            </div>
+            <h2><fmt:message key="admin.preferences.shorttitle"/></h2>
+
+            <table class="datatable preferencestable">
+                <tbody>
+                <spring:url value="/app/admin/preferencedetail/edit" var="detaillink"/>
+                    <%--@elvariable id="preferenceMap" type="java.util.Map<java.lang.String,
org.apache.rave.portal.model.PortalPreference>"--%>
+                <c:forEach items="${preferenceMap}" var="entry">
+                    <c:set value="${entry.value}" var="portalPreference"/>
+                    <tr data-detaillink="${detaillink}">
+                        <th scope="row" class="largetextcell">
+                            <a href="${detaillink}"><fmt:message
+                                    key="admin.preferencedetail.${portalPreference.key}"/></a>
+                        </th>
+                        <td class="largetextcell">
+                            <ul>
+                                <c:forEach items="${portalPreference.values}" var="value">
+                                    <li><a href="${detaillink}"><c:out value="${value}"/></a></li>
+                                </c:forEach>
+                            </ul>
+                        </td>
+                    </tr>
+                </c:forEach>
+                </tbody>
+            </table>
         </article>
     </div>
 </rave:rave_generic_page>
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/userdetail.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/userdetail.jsp?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/userdetail.jsp
(original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/userdetail.jsp
Mon Nov 14 15:30:51 2011
@@ -85,6 +85,7 @@
                                     <input type="email" name="email" id="email" value="<c:out
value="${status.value}"/>"
                                            class="long"/>
                                 </spring:bind>
+                                <form:errors path="email" cssClass="error"/>
                             </p>
 
                             <p>

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css?rev=1201750&r1=1201749&r2=1201750&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css Mon Nov 14
15:30:51 2011
@@ -789,7 +789,12 @@ span.error, label.error {
     background-color: #B4C4CF;
 }
 
-.admincontent table a, .admincontent table a:visited {
+.admincontent th a, .admincontent th a:visited {
+    color: #FFFFFF;
+    text-decoration:none;
+}
+
+.admincontent td a, .admincontent td a:visited {
     color: #000000;
     text-decoration:none;
 }



Mime
View raw message