rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r1200352 - in /incubator/rave/trunk: rave-components/rave-core/src/main/java/org/apache/rave/portal/model/ rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/ rave-components/rave-core/src/main/java/org/apache/rave/po...
Date Thu, 10 Nov 2011 14:47:09 GMT
Author: jasha
Date: Thu Nov 10 14:47:08 2011
New Revision: 1200352

URL: http://svn.apache.org/viewvc?rev=1200352&view=rev
Log:
RAVE-355 As a Rave admin I want to change the title of the portal in the management interface (part 1: display value from the database)
TODO: manage this value from the management interface

Added:
    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/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PortalPreferenceService.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceService.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/repository/impl/JpaPortalPreferenceRepositoryTest.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceServiceTest.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptor.java
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptorTest.java
Modified:
    incubator/rave/trunk/rave-components/rave-core/src/main/resources/META-INF/persistence.xml
    incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/dispatcher-servlet.xml
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/base_layout.jsp

Added: 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=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PortalPreference.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,184 @@
+/*
+ * 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.model;
+
+import org.apache.rave.exception.NotSupportedException;
+import org.apache.rave.persistence.BasicEntity;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Bean to manage portal preferences like title suffix, logo, number of items per page etc
+ */
+@Entity
+@Table(name = "portal_preference")
+@NamedQueries({
+        @NamedQuery(name = PortalPreference.GET_ALL, query = "SELECT pp FROM PortalPreference pp"),
+        @NamedQuery(name = PortalPreference.GET_BY_KEY,
+                query = "SELECT pp FROM PortalPreference pp WHERE pp.key = :" + PortalPreference.PARAM_KEY)
+})
+public class PortalPreference implements BasicEntity, Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final String GET_ALL = "PortalPreference.getAll";
+    public static final String GET_BY_KEY = "PortalPreference.getByKey";
+    public static final String PARAM_KEY = "key";
+
+    @Id
+    @Column(name = "entity_id")
+    @GeneratedValue(strategy = GenerationType.TABLE, generator = "portalPreferenceIdGenerator")
+    @TableGenerator(name = "portalPreferenceIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName = "SEQ_NAME",
+            valueColumnName = "SEQ_COUNT", pkColumnValue = "portal_preference", allocationSize = 1, initialValue = 1)
+    private Long entityId;
+
+    @Basic
+    @Column(name = "preference_key", unique = true)
+    private String key;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    private List<String> values = new LinkedList<String>();
+
+    public PortalPreference() {
+        super();
+    }
+
+    public PortalPreference(String key, String value) {
+        super();
+        this.key = key;
+        this.values.add(value);
+    }
+
+    public PortalPreference(String key, List<String> values) {
+        super();
+        this.key = key;
+        this.values = values;
+    }
+
+    @Override
+    public Long getEntityId() {
+        return this.entityId;
+    }
+
+    @Override
+    public void setEntityId(Long entityId) {
+        this.entityId = entityId;
+    }
+
+    /**
+     * Gets the key of the preference, e.g. "availableFruit"
+     *
+     * @return name of the preference key
+     */
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    /**
+     * Gets a String array of the preference values, e.g. {"apple", "pear", "orange"}
+     *
+     * @return String array of the preference values
+     */
+    public List<String> getValues() {
+        return values;
+    }
+
+    public void setValues(List<String> values) {
+        this.values = values;
+    }
+
+    /**
+     * Helper method for the view layer to get a single value for a preference.
+     * If there is no value, it returns {@literal null}.
+     * If there is 1 value, it returns that value.
+     *
+     * @return the single value of the preference or {@literal null} if not set
+     * @throws NotSupportedException if the preference has multiple values
+     */
+    public String getValue() {
+        if (values.isEmpty()) {
+            return null;
+        } else if (values.size() == 1) {
+            return values.get(0);
+        }
+        throw new NotSupportedException("Cannot return single value for a List of size " + values.size());
+    }
+
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final PortalPreference other = (PortalPreference) obj;
+        if (this.entityId != other.entityId && (this.entityId == null || !this.entityId.equals(other.entityId))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 97 * hash + (this.entityId != null ? this.entityId.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer();
+        sb.append("PortalPreference");
+        sb.append("{entityId=").append(entityId);
+        sb.append(", key='").append(key).append('\'');
+        sb.append(", values={");
+        if (values != null) {
+            for (int i = 0; i < values.size(); i++) {
+                if (i > 0) {
+                    sb.append(',');
+                }
+                sb.append('\'').append(values.get(i)).append('\'');
+            }
+            sb.append('}');
+        }
+        sb.append('}');
+        return sb.toString();
+    }
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java Thu Nov 10 14:47:08 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.repository;
+
+import org.apache.rave.persistence.Repository;
+import org.apache.rave.portal.model.PortalPreference;
+
+import java.util.List;
+
+/**
+ * Provides persistence operations for the {@link PortalPreference}
+ */
+public interface PortalPreferenceRepository extends Repository<PortalPreference> {
+
+    List<PortalPreference> getAll();
+
+    PortalPreference getByKey(String key);
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepository.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepository.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepository.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.persistence.jpa.AbstractJpaRepository;
+import org.apache.rave.portal.model.PortalPreference;
+import org.apache.rave.portal.repository.PortalPreferenceRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.TypedQuery;
+import java.util.List;
+
+import static org.apache.rave.persistence.jpa.util.JpaUtil.getSingleResult;
+
+/**
+ * JPA implementation for {@link PortalPreferenceRepository}
+ */
+@Repository
+public class JpaPortalPreferenceRepository extends AbstractJpaRepository<PortalPreference> implements PortalPreferenceRepository {
+
+    public JpaPortalPreferenceRepository() {
+        super(PortalPreference.class);
+    }
+
+    @Override
+    public List<PortalPreference> getAll() {
+        final TypedQuery<PortalPreference> query =
+                manager.createNamedQuery(PortalPreference.GET_ALL, PortalPreference.class);
+        return query.getResultList();
+    }
+
+    @Override
+    public PortalPreference getByKey(String key) {
+        final TypedQuery<PortalPreference> query =
+                manager.createNamedQuery(PortalPreference.GET_BY_KEY, PortalPreference.class);
+        query.setParameter(PortalPreference.PARAM_KEY, key);
+        return getSingleResult(query.getResultList());
+    }
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PortalPreferenceService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PortalPreferenceService.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PortalPreferenceService.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PortalPreferenceService.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.PortalPreference;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Service for portal preferences
+ */
+public interface PortalPreferenceService {
+
+    /**
+     * Creates a Map of all {@link PortalPreference}'s using the preference key as key for the Map.Entry
+     *
+     * @return Map of PortalPreference's
+     */
+    Map<String, PortalPreference> getPreferencesAsMap();
+
+    /**
+     * Gets a {@link PortalPreference} by its key
+     *
+     * @param key unique name of the preference
+     * @return PortalPreference if it exists, otherwise {@literal null}
+     */
+    PortalPreference getPreference(String key);
+
+    /**
+     * Saves a {@link PortalPreference} with a single value.
+     * If a PortalPreference already exists with this key, its value(s) will be overwritten.
+     *
+     * @param key   of the preference, e.g. {@literal title}
+     * @param value of the preference, e.g. {@literal "Rave"}
+     */
+    void savePreference(String key, String value);
+
+    /**
+     * Saves a {@link PortalPreference} with a List of values.
+     * If a PortalPreference already exists with this key, its value(s) will be overwritten.
+     *
+     * @param key    of the preference, e.g. {@literal colors}
+     * @param values List of values of the preference, e.g. {@literal red}, {@literal yellow}, {@literal blue}
+     */
+    void savePreference(String key, List<String> values);
+
+    /**
+     * Saves a {@link PortalPreference}
+     *
+     * @param preference PortalPreference to save
+     */
+    void savePreference(PortalPreference preference);
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceService.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceService.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceService.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,84 @@
+/*
+ * 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.PortalPreference;
+import org.apache.rave.portal.repository.PortalPreferenceRepository;
+import org.apache.rave.portal.service.PortalPreferenceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Default implementation of {@link PortalPreferenceService}
+ */
+@Service
+public class DefaultPortalPreferenceService implements PortalPreferenceService {
+
+    private final PortalPreferenceRepository repository;
+
+    @Autowired
+    public DefaultPortalPreferenceService(PortalPreferenceRepository repository) {
+        this.repository = repository;
+    }
+
+    @Override
+    public Map<String, PortalPreference> getPreferencesAsMap() {
+        final List<PortalPreference> portalPreferences = repository.getAll();
+
+        Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
+        for (PortalPreference preference : portalPreferences) {
+            preferenceMap.put(preference.getKey(), preference);
+        }
+        return preferenceMap;
+    }
+
+    @Override
+    public PortalPreference getPreference(String key) {
+        return repository.getByKey(key);
+    }
+
+    @Override
+    public void savePreference(String key, String value) {
+        List<String> values = new ArrayList<String>();
+        values.add(value);
+        this.savePreference(key, values);
+    }
+
+    @Override
+    public void savePreference(String key, List<String> values) {
+        PortalPreference preference = getPreference(key);
+        if (preference == null) {
+            preference = new PortalPreference(key, values);
+        } else {
+            preference.setValues(values);
+        }
+        this.savePreference(preference);
+    }
+
+    @Override
+    public void savePreference(PortalPreference preference) {
+        repository.save(preference);
+    }
+}

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/resources/META-INF/persistence.xml?rev=1200352&r1=1200351&r2=1200352&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/resources/META-INF/persistence.xml Thu Nov 10 14:47:08 2011
@@ -29,8 +29,10 @@
             <class>org.apache.rave.portal.model.RegionWidget</class>
             <class>org.apache.rave.portal.model.RegionWidgetPreference</class>
             <class>org.apache.rave.portal.model.Widget</class>
+            <class>org.apache.rave.portal.model.WidgetComment</class>
             <class>org.apache.rave.portal.model.WidgetRating</class>
             <class>org.apache.rave.portal.model.PageLayout</class>
             <class>org.apache.rave.portal.model.Authority</class>
+            <class>org.apache.rave.portal.model.PortalPreference</class>
         </persistence-unit>
 </persistence>

Added: 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=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/model/PortalPreferenceTest.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.model;
+
+import org.apache.rave.exception.NotSupportedException;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNull;
+
+/**
+ * Test for {@link PortalPreference}
+ */
+public class PortalPreferenceTest {
+    private static final String KEY = "foo";
+    private static final List<String> VALUES = getValueList();
+
+    @Test
+    public void testGettersSetters() throws Exception {
+        Long entityId = 1L;
+        PortalPreference preference = new PortalPreference();
+
+        assertNull(preference.getValue());
+
+        preference.setEntityId(entityId);
+        preference.setKey(KEY);
+        preference.setValues(VALUES);
+
+        assertEquals(entityId, preference.getEntityId());
+        assertEquals(KEY, preference.getKey());
+        assertEquals(VALUES, preference.getValues());
+    }
+
+    @Test
+    public void singleValuePreference() throws Exception {
+        PortalPreference preference = new PortalPreference(KEY, "bar");
+        assertEquals(KEY, preference.getKey());
+        assertEquals("bar", preference.getValue());
+    }
+
+    @Test
+    public void testGetValues() throws Exception {
+        PortalPreference preference = new PortalPreference(KEY, VALUES);
+        assertEquals(KEY, preference.getKey());
+        assertEquals(VALUES, preference.getValues());
+    }
+
+    @Test(expected = NotSupportedException.class)
+    public void getValueFailsForMultiValue() {
+        PortalPreference preference = new PortalPreference(KEY, VALUES);
+        preference.getValue();
+        assertFalse("Expected exception", true);
+
+    }
+
+    private static List<String> getValueList() {
+        List<String> values = new ArrayList<String>();
+        values.add("bar");
+        values.add("baz");
+        return values;
+    }
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepositoryTest.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepositoryTest.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPortalPreferenceRepositoryTest.java Thu Nov 10 14:47:08 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.repository.impl;
+
+import org.apache.rave.portal.model.PortalPreference;
+import org.apache.rave.portal.repository.PortalPreferenceRepository;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Test class for {@link JpaPortalPreferenceRepository}
+ */
+@Transactional
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:test-dataContext.xml", "classpath:test-applicationContext.xml"})
+public class JpaPortalPreferenceRepositoryTest {
+
+    @PersistenceContext
+    private EntityManager manager;
+
+    @Autowired
+    private PortalPreferenceRepository repository;
+
+    @Test
+    public void testGetAll() {
+        final List<PortalPreference> preferences = repository.getAll();
+        assertTrue(preferences.size() == 2);
+    }
+
+    @Test
+    public void testGetByKey() {
+        PortalPreference preference = repository.getByKey("color");
+        assertNotNull(preference);
+        assertTrue("Expecting preference with one of the values to be red", preference.getValues().contains("red"));
+        assertTrue("Expecting preference with one of the values to be blue", preference.getValues().contains("blue"));
+    }
+
+    @Test
+    public void testGetByKey_notExisting() {
+        PortalPreference preference = repository.getByKey("foo");
+        assertNull(preference);
+    }
+
+    @Test
+    public void testValuesAreOverwritten() throws Exception {
+        PortalPreference preference = repository.getByKey("color");
+        List<String> newColors = new ArrayList<String>();
+        newColors.add("purple");
+        newColors.add("green");
+        preference.setValues(newColors);
+        final PortalPreference saved = repository.save(preference);
+        assertEquals(2, saved.getValues().size());
+    }
+
+    @Test
+    @Rollback(true)
+    public void testNoPreferences() {
+        final List<PortalPreference> preferences = repository.getAll();
+        for (PortalPreference preference : preferences) {
+            repository.delete(preference);
+        }
+
+        final List<PortalPreference> empty = repository.getAll();
+        assertTrue(empty.isEmpty());
+    }
+}

Added: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceServiceTest.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceServiceTest.java (added)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPortalPreferenceServiceTest.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,209 @@
+/*
+ * 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.PortalPreference;
+import org.apache.rave.portal.repository.PortalPreferenceRepository;
+import org.apache.rave.portal.service.PortalPreferenceService;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+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.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Test class for {@link DefaultPortalPreferenceService}
+ */
+public class DefaultPortalPreferenceServiceTest {
+
+    PortalPreferenceService service;
+    PortalPreferenceRepository repository;
+
+    @Before
+    public void setUp() throws Exception {
+        repository = createMock(PortalPreferenceRepository.class);
+        service = new DefaultPortalPreferenceService(repository);
+    }
+
+    @Test
+    public void testGetPreferencesAsMap() {
+        expect(repository.getAll()).andReturn(portalPreferenceList());
+        replay(repository);
+
+        final Map<String, PortalPreference> map = service.getPreferencesAsMap();
+        verify(repository);
+
+        assertEquals(2, map.size());
+        assertEquals("Rave", map.get("title").getValue());
+
+        final List<String> colors = map.get("colors").getValues();
+        assertTrue(colors.contains("red"));
+        assertTrue(colors.contains("yellow"));
+        assertTrue(colors.contains("blue"));
+    }
+
+    @Test
+    public void testGetPreferencesAsMap_noPreferences() {
+        expect(repository.getAll()).andReturn(Collections.<PortalPreference>emptyList());
+        replay(repository);
+
+        final Map<String, PortalPreference> map = service.getPreferencesAsMap();
+        verify(repository);
+
+        assertTrue(map.isEmpty());
+    }
+
+    @Test
+    public void testGetPreference() {
+        final String key = "title";
+        expect(repository.getByKey(key)).andReturn(titlePreference());
+        replay(repository);
+
+        final PortalPreference preference = service.getPreference(key);
+        verify(repository);
+
+        assertEquals("Rave", preference.getValue());
+    }
+
+    @Test
+    public void testGetPreference_notExisting() {
+        final String key = "foo";
+        expect(repository.getByKey(key)).andReturn(null);
+        replay(repository);
+
+        final PortalPreference preference = service.getPreference(key);
+        verify(repository);
+
+        assertNull(preference);
+    }
+
+    @Test
+    public void testSaveKeyValue_new() {
+        final String key = "foo";
+        final String value = "bar";
+        PortalPreference fooBar = new PortalPreference(key, value);
+        PortalPreference fooBarSaved = new PortalPreference(key, value);
+        fooBarSaved.setEntityId(123L);
+
+        expect(repository.getByKey(key)).andReturn(null).once();
+        expect(repository.save(fooBar)).andReturn(fooBarSaved).once();
+        replay(repository);
+        service.savePreference(key, value);
+        verify(repository);
+    }
+
+    @Test
+    public void testSaveKeyValue_existing() {
+        final String key = "foo";
+        final String value = "bar";
+        final String newValue = "baz";
+        PortalPreference fooBar = new PortalPreference(key, value);
+        fooBar.setEntityId(123L);
+        PortalPreference fooBarSaved = new PortalPreference(key, newValue);
+        fooBarSaved.setEntityId(123L);
+
+        expect(repository.getByKey(key)).andReturn(fooBar).once();
+        expect(repository.save(fooBar)).andReturn(fooBarSaved).once();
+        replay(repository);
+        service.savePreference(key, value);
+        verify(repository);
+    }
+
+    @Test
+    public void testSaveKeyValues_new() {
+        final String key = "foo";
+        List<String> values = new ArrayList<String>();
+        values.add("bar");
+        values.add("baz");
+        PortalPreference fooBar = new PortalPreference(key, values);
+        PortalPreference fooBarSaved = new PortalPreference(key, values);
+        fooBarSaved.setEntityId(123L);
+
+        expect(repository.getByKey(key)).andReturn(null).once();
+        expect(repository.save(fooBar)).andReturn(fooBarSaved).once();
+        replay(repository);
+        service.savePreference(key, values);
+        verify(repository);
+    }
+
+    @Test
+    public void testSaveKeyValues_existing() {
+        final String key = "foo";
+        List<String> values = new ArrayList<String>();
+        values.add("bar");
+        values.add("baz");
+        List<String> newValues = new ArrayList<String>();
+        values.add("bar2");
+        values.add("baz2");
+        PortalPreference fooBar = new PortalPreference(key, values);
+        fooBar.setEntityId(123L);
+        PortalPreference fooBarSaved = new PortalPreference(key, newValues);
+        fooBarSaved.setEntityId(123L);
+
+        expect(repository.getByKey(key)).andReturn(fooBar).once();
+        expect(repository.save(fooBar)).andReturn(fooBarSaved).once();
+        replay(repository);
+        service.savePreference(key, values);
+        verify(repository);
+    }
+
+    @Test
+    public void testSavePreference() {
+        PortalPreference title = titlePreference();
+        PortalPreference savedTitle = new PortalPreference("title", "Rave");
+        savedTitle.setEntityId(123L);
+
+        expect(repository.save(title)).andReturn(savedTitle).once();
+        replay(repository);
+
+        service.savePreference(title);
+        verify(repository);
+    }
+
+    private static List<PortalPreference> portalPreferenceList() {
+        PortalPreference title = titlePreference();
+
+        List<String> colors = new ArrayList<String>();
+        colors.add("red");
+        colors.add("yellow");
+        colors.add("blue");
+        PortalPreference colorPref = new PortalPreference("colors", colors);
+
+        List<PortalPreference> preferences = new ArrayList<PortalPreference>();
+        preferences.add(title);
+        preferences.add(colorPref);
+
+        return preferences;
+    }
+
+    private static PortalPreference titlePreference() {
+        return new PortalPreference("title", "Rave");
+    }
+}

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql?rev=1200352&r1=1200351&r2=1200352&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql Thu Nov 10 14:47:08 2011
@@ -33,6 +33,7 @@ set @widget_seq = 'widget';
 set @granted_authority_seq = 'granted_authority';
 set @widget_comment_seq = 'widget_comment';
 set @widget_rating_seq = 'widget_rating';
+set @portal_preference_seq = 'portal_preference';
 
 CREATE TABLE IF NOT EXISTS RAVE_PORTAL_SEQUENCES (seq_name VARCHAR(255) PRIMARY KEY NOT NULL, seq_count BIGINT(19));
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@page_seq, 1);
@@ -45,6 +46,7 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@widget_comment_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@widget_rating_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@granted_authority_seq, 1);
+INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@portal_preference_seq, 1);
 
   -- ***********************************************************************************
   -- start page layout data, required to make the portal work ---
@@ -766,3 +768,23 @@ values (@next_authority_id, 'administrat
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @granted_authority_seq;
 
 -- end authorities
+
+-- portal preferences
+set @next_portal_preference_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @portal_preference_seq);
+INSERT INTO portal_preference (entity_id, preference_key)
+values (@next_portal_preference_id, 'color');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, 'red');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, 'yellow');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, 'blue');
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @portal_preference_seq;
+
+set @next_portal_preference_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @portal_preference_seq);
+INSERT INTO portal_preference (entity_id, preference_key)
+values (@next_portal_preference_id, 'title');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, 'Rave');
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @portal_preference_seq;
+-- end portal preferences
\ No newline at end of file

Added: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptor.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptor.java (added)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptor.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.interceptors;
+
+import org.apache.rave.portal.service.PortalPreferenceService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Adds attributes to the ModelMap that are needed in every view
+ */
+@Component
+public class CommonModelHandlerInterceptor extends HandlerInterceptorAdapter {
+
+    private final PortalPreferenceService preferenceService;
+
+    @Autowired
+    public CommonModelHandlerInterceptor(PortalPreferenceService preferenceService) {
+        this.preferenceService = preferenceService;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
+        if (modelAndView != null) {
+            ModelMap map = modelAndView.getModelMap();
+            map.addAttribute(ModelKeys.PORTAL_SETTINGS, preferenceService.getPreferencesAsMap());
+        }
+        super.postHandle(request, response, handler, modelAndView);
+    }
+}

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1200352&r1=1200351&r2=1200352&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java Thu Nov 10 14:47:08 2011
@@ -40,4 +40,5 @@ public class ModelKeys {
     public static final String SEARCHRESULT = "searchResult";
     public static final String TOKENCHECK = "tokencheck";
     public static final String USER_MAP = "userMap";
+    public static final String PORTAL_SETTINGS = "portalSettings";
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptorTest.java?rev=1200352&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptorTest.java (added)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/interceptors/CommonModelHandlerInterceptorTest.java Thu Nov 10 14:47:08 2011
@@ -0,0 +1,81 @@
+/*
+ * 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.interceptors;
+
+import org.apache.rave.portal.model.PortalPreference;
+import org.apache.rave.portal.service.PortalPreferenceService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Test for {@link CommonModelHandlerInterceptor}
+ */
+public class CommonModelHandlerInterceptorTest {
+
+    CommonModelHandlerInterceptor interceptor;
+    PortalPreferenceService portalPreferenceService;
+
+    @Before
+    public void setUp() throws Exception {
+        portalPreferenceService = createMock(PortalPreferenceService.class);
+        interceptor = new CommonModelHandlerInterceptor(portalPreferenceService);
+    }
+
+    @Test
+    public void testPostHandle() throws Exception {
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        MockHttpServletResponse response = new MockHttpServletResponse();
+        Object handler = null;
+        ModelAndView modelAndView = new ModelAndView();
+
+        Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
+
+        expect(portalPreferenceService.getPreferencesAsMap()).andReturn(preferenceMap);
+        replay(portalPreferenceService);
+        interceptor.postHandle(request, response, handler, modelAndView);
+        verify(portalPreferenceService);
+
+        assertTrue(modelAndView.getModelMap().containsKey(ModelKeys.PORTAL_SETTINGS));
+    }
+    @Test
+    public void testPostHandle_noModelAndView() throws Exception {
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        MockHttpServletResponse response = new MockHttpServletResponse();
+        Object handler = null;
+        ModelAndView modelAndView = null;
+
+        interceptor.postHandle(request, response, handler, modelAndView);
+        assertNull(modelAndView);
+    }
+}

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql?rev=1200352&r1=1200351&r2=1200352&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql Thu Nov 10 14:47:08 2011
@@ -31,6 +31,9 @@ set @region_widget_seq = 'region_widget'
 set @user_seq = 'raveuser';
 set @widget_seq = 'widget';
 set @granted_authority_seq = 'granted_authority';
+set @widget_comment_seq = 'widget_comment';
+set @widget_rating_seq = 'widget_rating';
+set @portal_preference_seq = 'portal_preference';
 
 CREATE TABLE IF NOT EXISTS RAVE_PORTAL_SEQUENCES (seq_name VARCHAR(255) PRIMARY KEY NOT NULL, seq_count BIGINT(19));
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@page_seq, 1);
@@ -40,7 +43,10 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values ('region_widget_preference', 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@user_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@widget_seq, 1);
+INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@widget_comment_seq, 1);
+INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@widget_rating_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@granted_authority_seq, 1);
+INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@portal_preference_seq, 1);
   -- ***********************************************************************************
   -- start page layout data, required to make the portal work ---
 set @one_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
@@ -767,3 +773,19 @@ insert into user_authorities (user_id, a
 values (@user_id_12, @user_authority_id);
 insert into user_authorities (user_id, authority_id)
 values (@user_id_13, @user_authority_id);
+
+-- portal preferences
+set @next_portal_preference_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @portal_preference_seq);
+INSERT INTO portal_preference (entity_id, preference_key)
+values (@next_portal_preference_id, 'titleSuffix');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, ' - Rave');
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @portal_preference_seq;
+
+set @next_portal_preference_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @portal_preference_seq);
+INSERT INTO portal_preference (entity_id, preference_key)
+values (@next_portal_preference_id, 'pageSize');
+INSERT INTO portalpreference_values
+values (@next_portal_preference_id, '10');
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @portal_preference_seq;
+-- end portal preferences
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=1200352&r1=1200351&r2=1200352&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/dispatcher-servlet.xml (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/dispatcher-servlet.xml Thu Nov 10 14:47:08 2011
@@ -29,10 +29,14 @@
 
     <!-- Scans the classpath of this application for @Components to deploy as beans -->
     <context:component-scan base-package="org.apache.rave.portal.web.controller"/>
+    <context:component-scan base-package="org.apache.rave.portal.web.interceptors"/>
     <context:component-scan base-package="org.apache.rave.portal.web.api"/>
 
     <!-- Configures the @Controller programming model -->
     <mvc:annotation-driven/>
+    <mvc:interceptors>
+        <bean class="org.apache.rave.portal.web.interceptors.CommonModelHandlerInterceptor"/>
+    </mvc:interceptors>
 
     <!-- Forwards requests to the "/" resource to the "home" view -->
     <mvc:view-controller path="/" view-name="home"/>
@@ -52,7 +56,7 @@
     <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
         <property name="messageConverters">
             <list>
-            	<bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter"></bean>
+                <bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter"/>
                 <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"
                       p:marshaller-ref="marshaller" p:unmarshaller-ref="marshaller"/>
             </list>

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=1200352&r1=1200351&r2=1200352&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 Nov 10 14:47:08 2011
@@ -26,7 +26,9 @@ under the License.
 <html>
 <head>
     <meta charset="ISO-8859-1"/>
-    <title><fmt:message key="${pageTitleKey}"/>&nbsp;<fmt:message key="${pageTitleSuffixKey}"/></title>
+    <title><fmt:message key="${pageTitleKey}"/>
+    <c:if test="${not empty portalSettings and not empty portalSettings['titleSuffix']}">
+        &nbsp;<c:out value="${portalSettings['titleSuffix'].value}"/></c:if></title>
     <link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/themes/base/jquery-ui.css"/>
     <link rel="stylesheet" href="<c:url value="/css/default.css" />"/>
     <rave:custom_css/>



Mime
View raw message