You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ca...@apache.org on 2011/12/21 21:49:01 UTC

svn commit: r1221873 - 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/model/util/ rave-components/rave-core/src/main/java/org/apache/rave/po...

Author: carlucci
Date: Wed Dec 21 20:49:00 2011
New Revision: 1221873

URL: http://svn.apache.org/viewvc?rev=1221873&view=rev
Log:
RAVE-73: Users can see the most popular widgets in the widget repository

Modified:
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/RegionWidget.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/User.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/WidgetStatistics.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/UserService.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaUserRepositoryTest.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaWidgetRepositoryTest.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultUserServiceTest.java
    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/api/rest/WidgetApi.java
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/api/rest/WidgetApiTest.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/db/initial_data.sql
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/css/default.css
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_api.js
    incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveApiSpec.js

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/RegionWidget.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/RegionWidget.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/RegionWidget.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/RegionWidget.java Wed Dec 21 20:49:00 2011
@@ -21,19 +21,7 @@ package org.apache.rave.portal.model;
 import org.apache.rave.persistence.BasicEntity;
 import org.codehaus.jackson.annotate.JsonBackReference;
 
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
+import javax.persistence.*;
 import java.io.Serializable;
 import java.util.List;
 
@@ -42,9 +30,20 @@ import java.util.List;
  */
 @Entity
 @Table(name = "region_widget")
+@NamedQueries({
+        @NamedQuery(name = RegionWidget.REGION_WIDGET_GET_DISTINCT_USER_COUNT_ALL_WIDGETS,
+                    query = "select rw.widget.entityId, count(distinct rw.region.page.owner) from RegionWidget rw group by rw.widget.entityId"),
+        @NamedQuery(name = RegionWidget.REGION_WIDGET_GET_DISTINCT_USER_COUNT_SINGLE_WIDGET,
+                    query = "select count(distinct rw.region.page.owner) from RegionWidget rw where rw.widget.entityId = :widgetId")
+})
 public class RegionWidget implements BasicEntity, Serializable {
     private static final long serialVersionUID = 1L;
-    
+
+    public static final String REGION_WIDGET_GET_DISTINCT_USER_COUNT_ALL_WIDGETS = "RegionWidget.getDistinctUserCountForAllWidgets";
+    public static final String REGION_WIDGET_GET_DISTINCT_USER_COUNT_SINGLE_WIDGET = "RegionWidget.getDistinctUserCount";
+
+    public static final String PARAM_WIDGET_ID = "widgetId";
+
     @Id
     @Column(name = "entity_id")
     @GeneratedValue(strategy = GenerationType.TABLE, generator = "regionWidgetIdGenerator")

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/User.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/User.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/User.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/User.java Wed Dec 21 20:49:00 2011
@@ -22,23 +22,7 @@ import org.apache.rave.persistence.Basic
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.UserDetails;
 
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PreRemove;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Transient;
+import javax.persistence.*;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -58,8 +42,8 @@ import java.util.Collections;
         @NamedQuery(name = User.USER_FIND_BY_USERNAME_OR_EMAIL, query = "select u from User u " +
                 "where lower(u.username) like :"+User.PARAM_SEARCHTERM+" or lower(u.email) like :"+User.PARAM_SEARCHTERM+" order by u.username asc"),
         @NamedQuery(name = User.USER_COUNT_FIND_BY_USERNAME_OR_EMAIL, query = "select count(u) from User u " +
-                "where lower(u.username) like :"+User.PARAM_SEARCHTERM+" or lower(u.email) like :"+User.PARAM_SEARCHTERM)
-
+                "where lower(u.username) like :"+User.PARAM_SEARCHTERM+" or lower(u.email) like :"+User.PARAM_SEARCHTERM),
+        @NamedQuery(name = User.USER_GET_ALL_FOR_ADDED_WIDGET, query = "select distinct(rw.region.page.owner) from RegionWidget rw where rw.widget.entityId = :widgetId order by rw.region.page.owner.familyName, rw.region.page.owner.givenName")
 })
 public class User extends Person implements UserDetails, BasicEntity, Serializable {
     private static final long serialVersionUID = 1L;
@@ -71,6 +55,7 @@ public class User extends Person impleme
     public static final String USER_FIND_BY_USERNAME_OR_EMAIL = "User.findByUsernameOrEmail";
     public static final String USER_COUNT_FIND_BY_USERNAME_OR_EMAIL = "User.countFindByUsernameOrEmail";
     public static final String USER_GET_COMMENTERS = "User.getCommenters";
+    public static final String USER_GET_ALL_FOR_ADDED_WIDGET = "User.getAllForAddedWidget";
 
     public static final String PARAM_USERNAME = "username";
     public static final String PARAM_EMAIL = "email";
@@ -334,4 +319,31 @@ public class User extends Person impleme
         sb.append('}');
         return sb.toString();
     }
+
+    /**
+     * Conversion function to create a new Person object based off of this User class.  This is useful for when you
+     * have a User object and want to pass on the Person data without the User class data (like password, etc)
+     * 
+     * @return a Person object representing the data contained in this class
+     */
+    public Person toPerson() {
+        Person p = new Person();
+        p.setAboutMe(this.getAboutMe());
+        p.setAdditionalName(this.getAdditionalName());
+        p.setAddresses(this.getAddresses());
+        p.setDisplayName(this.getDisplayName());
+        p.setEmail(this.getEmail());
+        p.setEntityId(this.getEntityId());
+        p.setFamilyName(this.getFamilyName());
+        p.setFriends(this.getFriends());
+        p.setGivenName(this.getGivenName());
+        p.setHonorificPrefix(this.getHonorificPrefix());
+        p.setHonorificSuffix(this.getHonorificSuffix());
+        p.setOrganizations(this.getOrganizations());
+        p.setPreferredName(this.getPreferredName());
+        p.setProperties(this.getProperties());
+        p.setStatus(this.getStatus());
+        p.setUsername(this.getUsername());
+        return p;
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/WidgetStatistics.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/WidgetStatistics.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/WidgetStatistics.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/WidgetStatistics.java Wed Dec 21 20:49:00 2011
@@ -15,14 +15,11 @@
  */
 package org.apache.rave.portal.model.util;
 
-/**
- *
- * @author ISIS
- */
 public class WidgetStatistics {
     private int totalLike;
     private int totalDislike;
     private int userRating;
+    private int totalUserCount;
     
     public void setTotalLike(int totalLike) {
         this.totalLike = totalLike;
@@ -44,13 +41,22 @@ public class WidgetStatistics {
     public int getUserRating() {
         return userRating;
     }
-    
+
+    public int getTotalUserCount() {
+        return totalUserCount;
+    }
+
+    public void setTotalUserCount(int totalUserCount) {
+        this.totalUserCount = totalUserCount;
+    }
+
     @Override
     public String toString() {
         return "WidgetStatistics{" +
                 "totalLike=" + totalLike +
                 ", totalDislike=" + totalDislike + 
-                ", userRating=" + userRating + 
+                ", userRating=" + userRating +
+                ", totalUserCount=" + totalUserCount +
                 '}';
     }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java Wed Dec 21 20:49:00 2011
@@ -79,4 +79,12 @@ public interface UserRepository extends 
      * @param user {@link User} to delete
      */
     void removeUser(User user);
+
+    /**
+     * List of users whom have added the supplied widget to one or more pages
+     *
+     * @param widgetId the entityId of the Widget to search
+     * @return List of User objects in alphabetical order sorted by familyname, givenname
+     */
+    List<User> getAllByAddedWidget(long widgetId);
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java Wed Dec 21 20:49:00 2011
@@ -95,6 +95,13 @@ public class JpaUserRepository extends A
         this.delete(user);
     }
 
+    @Override
+    public List<User> getAllByAddedWidget(long widgetId) {
+        TypedQuery<User> query = manager.createNamedQuery(User.USER_GET_ALL_FOR_ADDED_WIDGET, User.class);
+        query.setParameter(User.PARAM_WIDGET_ID, widgetId);
+        return query.getResultList();
+    }
+
     private void deletePages(User user) {
         TypedQuery<Page> pageQuery = manager.createNamedQuery("Page.getByUserId", Page.class);
         pageQuery.setParameter("userId", user.getEntityId());

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java Wed Dec 21 20:49:00 2011
@@ -22,10 +22,7 @@ package org.apache.rave.portal.repositor
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.rave.persistence.jpa.AbstractJpaRepository;
-import org.apache.rave.portal.model.User;
-import org.apache.rave.portal.model.Widget;
-import org.apache.rave.portal.model.WidgetRating;
-import org.apache.rave.portal.model.WidgetStatus;
+import org.apache.rave.portal.model.*;
 import org.apache.rave.portal.model.util.WidgetStatistics;
 import org.apache.rave.portal.repository.WidgetRepository;
 import org.slf4j.Logger;
@@ -35,12 +32,7 @@ import org.springframework.stereotype.Re
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Order;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
+import javax.persistence.criteria.*;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -149,65 +141,6 @@ public class JpaWidgetRepository extends
         return countResult.intValue();
     }
 
-    private Predicate[] getStatusAndTypeAndFreeTextPredicates(CriteriaBuilder cb, Root<Widget> widgetType,
-                                                              WidgetStatus widgetStatus, String type,
-                                                              String searchTerm) {
-        List<Predicate> predicates = new ArrayList<Predicate>();
-        if (StringUtils.isNotBlank(searchTerm)) {
-            predicates.add(
-                    cb.or(
-                            cb.like(cb.lower(getTitleField(widgetType)), getLowercaseWildcardSearchTerm(searchTerm)),
-                            cb.like(cb.lower(getDescriptionField(widgetType)), getLowercaseWildcardSearchTerm(searchTerm))
-                    )
-            );
-        }
-        if (StringUtils.isNotBlank(type)) {
-            predicates.add(cb.and(cb.equal(getTypeField(widgetType), type)));
-        }
-        if (widgetStatus != null) {
-            predicates.add(cb.and(cb.equal(getWidgetStatusField(widgetType), widgetStatus)));
-        }
-
-        return predicates.toArray(new Predicate[predicates.size()]);
-    }
-
-    private Order getOrderByTitleAsc(CriteriaBuilder cb, Root<Widget> widgetType) {
-        return cb.asc(getTitleField(widgetType));
-    }
-
-    private Path<String> getTitleField(Root<Widget> widgetType) {
-        return widgetType.get("title");
-    }
-
-    private Path<String> getDescriptionField(Root<Widget> widgetType) {
-        return widgetType.get("description");
-    }
-
-    private Path<String> getTypeField(Root<Widget> widgetType) {
-        return widgetType.get("type");
-    }
-
-    private Path<WidgetStatus> getWidgetStatusField(Root<Widget> widgetType) {
-        return widgetType.get("widgetStatus");
-    }
-
-    /**
-     * Sets input as free text search term to a query
-     *
-     * @param query      {@link javax.persistence.Query}
-     * @param searchTerm free text
-     */
-    protected void setFreeTextSearchTerm(Query query, final String searchTerm) {
-        query.setParameter(Widget.PARAM_SEARCH_TERM, getLowercaseWildcardSearchTerm(searchTerm));
-    }
-
-    private String getLowercaseWildcardSearchTerm(String searchTerm) {
-        if (StringUtils.isBlank(searchTerm)) {
-            return searchTerm;
-        }
-        return "%" + searchTerm.toLowerCase() + "%";
-    }
-
     @Override
     public Widget getByUrl(String widgetUrl) {
         if (StringUtils.isBlank(widgetUrl)) {
@@ -233,6 +166,10 @@ public class JpaWidgetRepository extends
         query.setParameter(WidgetRating.PARAM_WIDGET_ID, widget_id);
         widgetStatistics.setTotalDislike(((Number) query.getSingleResult()).intValue());
 
+        query = manager.createNamedQuery(RegionWidget.REGION_WIDGET_GET_DISTINCT_USER_COUNT_SINGLE_WIDGET);
+        query.setParameter(RegionWidget.PARAM_WIDGET_ID, widget_id);
+        widgetStatistics.setTotalUserCount(((Number) query.getSingleResult()).intValue());
+
         try {
             query = manager.createNamedQuery(WidgetRating.WIDGET_USER_RATING);
             query.setParameter(WidgetRating.PARAM_WIDGET_ID, widget_id);
@@ -286,6 +223,19 @@ public class JpaWidgetRepository extends
             widgetStatistics.setTotalDislike(totalDislikes.intValue());
         }
 
+        //get the total user count for widgets
+        query = manager.createNamedQuery(RegionWidget.REGION_WIDGET_GET_DISTINCT_USER_COUNT_ALL_WIDGETS);
+        for (Object[] result : (List<Object[]>) query.getResultList()) {
+            Long widgetId = (Long) result[0];
+            Long totalUserCount = (Long) result[1];
+            WidgetStatistics widgetStatistics = map.get(widgetId);
+            if (widgetStatistics == null) {
+                widgetStatistics = new WidgetStatistics();
+                map.put(widgetId, widgetStatistics);
+            }
+            widgetStatistics.setTotalUserCount(totalUserCount.intValue());
+        }
+
         //Add the current user's current rating of the widget
         Map<Long, WidgetRating> userRatings = getUsersWidgetRatings(userId);
         for (Map.Entry<Long, WidgetStatistics> entry : map.entrySet()) {
@@ -302,5 +252,62 @@ public class JpaWidgetRepository extends
         return map;
     }
 
+    /**
+     * Sets input as free text search term to a query
+     *
+     * @param query      {@link javax.persistence.Query}
+     * @param searchTerm free text
+     */
+    protected void setFreeTextSearchTerm(Query query, final String searchTerm) {
+        query.setParameter(Widget.PARAM_SEARCH_TERM, getLowercaseWildcardSearchTerm(searchTerm));
+    }
+
+    private Predicate[] getStatusAndTypeAndFreeTextPredicates(CriteriaBuilder cb, Root<Widget> widgetType,
+                                                              WidgetStatus widgetStatus, String type,
+                                                              String searchTerm) {
+        List<Predicate> predicates = new ArrayList<Predicate>();
+        if (StringUtils.isNotBlank(searchTerm)) {
+            predicates.add(
+                    cb.or(
+                            cb.like(cb.lower(getTitleField(widgetType)), getLowercaseWildcardSearchTerm(searchTerm)),
+                            cb.like(cb.lower(getDescriptionField(widgetType)), getLowercaseWildcardSearchTerm(searchTerm))
+                    )
+            );
+        }
+        if (StringUtils.isNotBlank(type)) {
+            predicates.add(cb.and(cb.equal(getTypeField(widgetType), type)));
+        }
+        if (widgetStatus != null) {
+            predicates.add(cb.and(cb.equal(getWidgetStatusField(widgetType), widgetStatus)));
+        }
+
+        return predicates.toArray(new Predicate[predicates.size()]);
+    }
+
+    private Order getOrderByTitleAsc(CriteriaBuilder cb, Root<Widget> widgetType) {
+        return cb.asc(getTitleField(widgetType));
+    }
+
+    private Path<String> getTitleField(Root<Widget> widgetType) {
+        return widgetType.get("title");
+    }
 
+    private Path<String> getDescriptionField(Root<Widget> widgetType) {
+        return widgetType.get("description");
+    }
+
+    private Path<String> getTypeField(Root<Widget> widgetType) {
+        return widgetType.get("type");
+    }
+
+    private Path<WidgetStatus> getWidgetStatusField(Root<Widget> widgetType) {
+        return widgetType.get("widgetStatus");
+    }
+
+    private String getLowercaseWildcardSearchTerm(String searchTerm) {
+        if (StringUtils.isBlank(searchTerm)) {
+            return searchTerm;
+        }
+        return "%" + searchTerm.toLowerCase() + "%";
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/UserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/UserService.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/UserService.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/UserService.java Wed Dec 21 20:49:00 2011
@@ -19,10 +19,13 @@
 
 package org.apache.rave.portal.service;
 
+import org.apache.rave.portal.model.Person;
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.util.SearchResult;
 import org.springframework.security.core.userdetails.UserDetailsService;
 
+import java.util.List;
+
 public interface UserService extends UserDetailsService {
     /**
      * Get the currently authenticated user.
@@ -106,4 +109,12 @@ public interface UserService extends Use
      * @param userId {@link Long} id if the user
      */
     void deleteUser(Long userId);
+
+    /**
+     * List of persons whom have added the supplied widget to one or more pages
+     *
+     * @param widgetId the entityId of the Widget to search
+     * @return List of Person objects in alphabetical order sorted by familyname, givenname
+     */
+    List<Person> getAllByAddedWidget(long widgetId);
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java Wed Dec 21 20:49:00 2011
@@ -19,6 +19,7 @@
 
 package org.apache.rave.portal.service.impl;
 
+import org.apache.rave.portal.model.Person;
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.util.SearchResult;
 import org.apache.rave.portal.repository.UserRepository;
@@ -37,6 +38,7 @@ import org.springframework.security.core
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -167,4 +169,13 @@ public class DefaultUserService implemen
         userRepository.removeUser(user);
     }
 
+    @Override
+    public List<Person> getAllByAddedWidget(long widgetId) {
+        List<Person> persons = new ArrayList<Person>();
+        List<User> users = userRepository.getAllByAddedWidget(widgetId);
+        for (User u : users) {
+            persons.add(u.toPerson());
+        }
+        return persons;
+    }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaUserRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaUserRepositoryTest.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaUserRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaUserRepositoryTest.java Wed Dec 21 20:49:00 2011
@@ -25,7 +25,6 @@ import org.apache.rave.portal.model.Page
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.repository.AuthorityRepository;
 import org.apache.rave.portal.repository.UserRepository;
-import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,14 +37,8 @@ import javax.persistence.PersistenceCont
 import javax.persistence.TypedQuery;
 import java.util.List;
 
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
 
 @Transactional
 @RunWith(SpringJUnit4ClassRunner.class)
@@ -62,6 +55,7 @@ public class JpaUserRepositoryTest {
     private static final String HASHED_SALTED_PASSWORD = "b97fd0fa25ba8a504309be2b6651ac6dee167ded";
     private static final Long INVALID_USER = -2L;
     private static final String USER_EMAIL = "canonical@example.com";
+    private static final Long VALID_WIDGET_ID = 1L;
 
     @Autowired
     private UserRepository repository;
@@ -72,7 +66,7 @@ public class JpaUserRepositoryTest {
     @Test
     public void getById_validId() {
         User user = repository.get(USER_ID);
-        assertThat(user, CoreMatchers.notNullValue());
+        assertThat(user, notNullValue());
         assertThat(user.getUsername(), is(equalTo(USER_NAME)));
         assertThat(user.getPassword(), is(equalTo(HASHED_SALTED_PASSWORD)));
         assertThat(user.isAccountNonExpired(), is(true));
@@ -88,7 +82,7 @@ public class JpaUserRepositoryTest {
     @Test
     public void getByUsername_valid() {
         User user = repository.getByUsername(USER_NAME);
-        assertThat(user, CoreMatchers.notNullValue());
+        assertThat(user, notNullValue());
         assertThat(user.getEntityId(), is(equalTo(USER_ID)));
         assertThat(user.getPassword(), is(equalTo(HASHED_SALTED_PASSWORD)));
         assertThat(user.isAccountNonExpired(), is(true));
@@ -104,7 +98,7 @@ public class JpaUserRepositoryTest {
     @Test
     public void getByUserEmail_valid() {
         User user = repository.getByUserEmail(USER_EMAIL);
-        assertThat(user, CoreMatchers.notNullValue());
+        assertThat(user, notNullValue());
         assertThat(user.getEntityId(), is(equalTo(USER_ID)));
         assertThat(user.getPassword(), is(equalTo(HASHED_SALTED_PASSWORD)));
         assertThat(user.isAccountNonExpired(), is(true));
@@ -183,4 +177,18 @@ public class JpaUserRepositoryTest {
         pages = pageQuery.getResultList();
         assertTrue("User has no pages", pages.isEmpty());
     }
+
+    @Test
+    public void getAllByAddedWidget() {
+        String searchTerm = "Doe";
+        List<User> users = repository.getAllByAddedWidget(VALID_WIDGET_ID);
+        // verify that the names are in alphabetical order
+        assertThat(users.isEmpty(), is(false));
+        String previousFamilyName = "";
+        for (User user : users) {
+            String familyName = user.getFamilyName();
+            assertThat(previousFamilyName.compareTo(familyName) <= 0 , is(true));
+            previousFamilyName = familyName;
+        }
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaWidgetRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaWidgetRepositoryTest.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaWidgetRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaWidgetRepositoryTest.java Wed Dec 21 20:49:00 2011
@@ -218,11 +218,13 @@ public class JpaWidgetRepositoryTest {
         assertEquals(0, gadgetOne.getTotalLike());
         assertEquals(1, gadgetOne.getTotalDislike());
         assertEquals(0, gadgetOne.getUserRating());
+        assertEquals(10, gadgetOne.getTotalUserCount());
         
         WidgetStatistics gadgetTwo = widgetStatistics.get(2L);
         assertEquals(1, gadgetTwo.getTotalLike());
         assertEquals(0, gadgetTwo.getTotalDislike());
         assertEquals(10, gadgetTwo.getUserRating());
+        assertEquals(10, gadgetOne.getTotalUserCount());
     }
     
     @Test
@@ -260,11 +262,12 @@ public class JpaWidgetRepositoryTest {
         assertNotNull(widgetStatistics);
         assertEquals(0, widgetStatistics.getTotalLike());
         assertEquals(1, widgetStatistics.getTotalDislike());
+        assertEquals(10, widgetStatistics.getTotalUserCount());
         assertEquals(WidgetRating.DISLIKE.intValue(), widgetStatistics.getUserRating());
     }
     
     @Test
-    public void getPositiveWidgetStatsitics() {
+    public void getPositiveWidgetStatistics() {
         Widget widget = repository.get(2L);
         List<WidgetRating> ratings = widget.getRatings();
         assertNotNull(ratings);
@@ -274,6 +277,7 @@ public class JpaWidgetRepositoryTest {
         assertNotNull(widgetStatistics);
         assertEquals(1, widgetStatistics.getTotalLike());
         assertEquals(0, widgetStatistics.getTotalDislike());
+        assertEquals(10, widgetStatistics.getTotalUserCount());
         assertEquals(WidgetRating.LIKE.intValue(), widgetStatistics.getUserRating());
     }
     
@@ -289,7 +293,7 @@ public class JpaWidgetRepositoryTest {
         assertEquals(0, widgetStatistics.getTotalDislike());
         assertEquals(0, widgetStatistics.getTotalLike());
         assertEquals(WidgetRating.UNSET.intValue(), widgetStatistics.getUserRating());
-    }
+    }  
     
     @Test
     public void addWidgetRating() {

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultUserServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultUserServiceTest.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultUserServiceTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultUserServiceTest.java Wed Dec 21 20:49:00 2011
@@ -21,6 +21,7 @@ package org.apache.rave.portal.service.i
 
 import org.apache.rave.portal.model.Authority;
 import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.Person;
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.util.SearchResult;
 import org.apache.rave.portal.repository.UserRepository;
@@ -40,17 +41,9 @@ import org.springframework.security.core
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.easymock.EasyMock.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
 
 public class DefaultUserServiceTest {
 
@@ -59,10 +52,11 @@ public class DefaultUserServiceTest {
     private UserRepository userRepository;
     private static final String USER_NAME = "1234";
     private static final String USER_EMAIL = "test@test.com";
+    private static final Long VALID_WIDGET_ID = 1L;
 
     @Before
     public void setup() {
-        userRepository = createNiceMock(UserRepository.class);
+        userRepository = createMock(UserRepository.class);
         service = new DefaultUserService(userRepository);
     }
 
@@ -85,6 +79,7 @@ public class DefaultUserServiceTest {
         User result = service.getAuthenticatedUser();
 
         assertThat(result, is(sameInstance(authUser)));
+        verify(auth);
     }
 
     @Test(expected = SecurityException.class)
@@ -105,7 +100,9 @@ public class DefaultUserServiceTest {
         SecurityContextHolder.setContext(context);
 
         service.getAuthenticatedUser();
+        verify(auth);
     }
+    
 
     @Test
     public void setAuthenticatedUser_valid() {
@@ -116,6 +113,7 @@ public class DefaultUserServiceTest {
         service.setAuthenticatedUser(USER_ID);
         assertThat((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(),
                 is(sameInstance(authUser)));
+        verify(userRepository);
     }
 
     @Test
@@ -133,6 +131,7 @@ public class DefaultUserServiceTest {
         final GrantedAuthority grantedAuthority =
                 SecurityContextHolder.getContext().getAuthentication().getAuthorities().iterator().next();
         assertEquals("has authority admin", "admin", grantedAuthority.getAuthority());
+        verify(userRepository);
     }
 
 
@@ -142,6 +141,7 @@ public class DefaultUserServiceTest {
         replay(userRepository);
 
         service.setAuthenticatedUser(USER_ID);
+        verify(userRepository);
     }
 
     @Test
@@ -152,14 +152,15 @@ public class DefaultUserServiceTest {
 
         UserDetails result = service.loadUserByUsername(USER_NAME);
         assertThat((User)result, is(sameInstance(authUser)));
+        verify(userRepository);
     }
 
     @Test(expected = UsernameNotFoundException.class)
     public void loadByUsername_invalid_exception() {
-        expect(userRepository.getByUsername(USER_NAME)).andThrow(new IncorrectResultSizeDataAccessException(1));
+        expect(userRepository.getByUsername(USER_NAME)).andReturn(null);
         replay(userRepository);
-
-        service.setAuthenticatedUser(USER_ID);
+        service.loadUserByUsername(USER_NAME);
+        verify(userRepository);
     }
 
     @Test(expected = UsernameNotFoundException.class)
@@ -168,6 +169,7 @@ public class DefaultUserServiceTest {
         replay(userRepository);
 
         service.setAuthenticatedUser(USER_ID);
+        verify(userRepository);
     }
 
      @Test
@@ -179,6 +181,7 @@ public class DefaultUserServiceTest {
 
         UserDetails result = service.getUserByEmail(USER_EMAIL);
         assertThat((User)result, is(sameInstance(authUser)));
+        verify(userRepository);
      }
 
 
@@ -199,6 +202,7 @@ public class DefaultUserServiceTest {
         users.add(user2);
         final int offset = 0;
         final int pageSize = 10;
+        expect(userRepository.getCountAll()).andReturn(users.size());
         expect(userRepository.getLimitedList(offset, pageSize)).andReturn(users);
         replay(userRepository);
 
@@ -206,6 +210,7 @@ public class DefaultUserServiceTest {
         assertEquals(pageSize, result.getPageSize());
         assertEquals(users.size(), result.getResultSet().size());
         assertEquals(user1, result.getResultSet().get(0));
+        verify(userRepository);
     }
 
     @Test
@@ -218,6 +223,7 @@ public class DefaultUserServiceTest {
         users.add(user2);
         final int offset = 0;
         final int pageSize = 10;
+        expect(userRepository.getCountByUsernameOrEmail(searchTerm)).andReturn(users.size());
         expect(userRepository.findByUsernameOrEmail(searchTerm, offset, pageSize)).andReturn(users);
         replay(userRepository);
 
@@ -225,6 +231,7 @@ public class DefaultUserServiceTest {
         assertEquals(pageSize, result.getPageSize());
         assertEquals(users.size(), result.getResultSet().size());
         assertEquals(user1, result.getResultSet().get(0));
+        verify(userRepository);
     }
 
     @Test
@@ -235,6 +242,7 @@ public class DefaultUserServiceTest {
 
         service.updateUserProfile(user);
         assertTrue("Save called", true);
+        verify(userRepository);
     }
 
     @Test
@@ -244,6 +252,7 @@ public class DefaultUserServiceTest {
         List<Page> pages = new ArrayList<Page>();
         pages.add(page);
         expect(userRepository.get(USER_ID)).andReturn(user).times(1);
+        userRepository.removeUser(user);
         expectLastCall();
         replay(userRepository);
 
@@ -253,4 +262,21 @@ public class DefaultUserServiceTest {
         assertTrue("Deleted", true);
     }
 
+    @Test
+    public void getAllByAddedWidget() {
+        List<User> userList = new ArrayList<User>();
+        userList.add(new User());
+        userList.add(new User());
+
+        List<Person> personList = new ArrayList<Person>();
+        personList.add(userList.get(0).toPerson());
+        personList.add(userList.get(1).toPerson());
+        
+        expect(userRepository.getAllByAddedWidget(VALID_WIDGET_ID)).andReturn(userList);
+        replay(userRepository);
+
+        assertThat(service.getAllByAddedWidget(VALID_WIDGET_ID), is(personList));
+        
+        verify(userRepository);
+    }
 }

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=1221873&r1=1221872&r2=1221873&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 Wed Dec 21 20:49:00 2011
@@ -89,69 +89,69 @@ UPDATE RAVE_PORTAL_SEQUENCES SET seq_cou
   -- ***********************************************************************************
   --- start user data ---
 set @user_id_1 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_1, 'canonical', 'b97fd0fa25ba8a504309be2b6651ac6dee167ded', FALSE, FALSE, TRUE,'canonical@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_1, 'canonical', 'b97fd0fa25ba8a504309be2b6651ac6dee167ded', FALSE, FALSE, TRUE,'canonical@example.com', @three_col_id, 'User', 'Canonical', 'Paul');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_2 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_2, 'john.doe', '49e5f5c7c7ae8372af9b3063c493f080d16411f5', FALSE, FALSE, TRUE,'john.doe@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_2, 'john.doe', '49e5f5c7c7ae8372af9b3063c493f080d16411f5', FALSE, FALSE, TRUE,'john.doe@example.com', @three_col_id, 'User', 'Doe', 'John');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_3 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_3, 'jane.doe', '30dd37e81704bbbd4e235c22990802ae25b187da', FALSE, FALSE, TRUE,'jane.doe@example.net', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_3, 'jane.doe', '30dd37e81704bbbd4e235c22990802ae25b187da', FALSE, FALSE, TRUE,'jane.doe@example.net', @three_col_id, 'User', 'Doe', 'Jane');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_4 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_4, 'george.doe', '452802e3f2ff8b7b28785f50dfaaaaf80fc1430f', FALSE, FALSE, TRUE,'george.doe@example.org', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_4, 'george.doe', '452802e3f2ff8b7b28785f50dfaaaaf80fc1430f', FALSE, FALSE, TRUE,'george.doe@example.org', @three_col_id, 'User', 'Doe', 'George');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_5 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_5,'mario.rossi', '8aadae9f6e73a479cb8a565bcfa6e8de2b074e89', FALSE, FALSE, TRUE,'mario.rossi@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_5,'mario.rossi', '8aadae9f6e73a479cb8a565bcfa6e8de2b074e89', FALSE, FALSE, TRUE,'mario.rossi@example.com', @three_col_id, 'User', 'Rossi', 'Mario');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_6 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_6, 'maija.m', '18550acca1b36af6cfa41c82e1caab12073475a1', FALSE, FALSE, TRUE,'maijam@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_6, 'maija.m', '18550acca1b36af6cfa41c82e1caab12073475a1', FALSE, FALSE, TRUE,'maijam@example.com', @three_col_id, 'User', 'M', 'Maija');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_7 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_7, 'one.col', '07acee6193e84ba9ae2f7b2bf26538f2d6e4b0a1', FALSE, FALSE, TRUE,'one.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_7, 'one.col', '07acee6193e84ba9ae2f7b2bf26538f2d6e4b0a1', FALSE, FALSE, TRUE,'one.col@example.com', @three_col_id, 'User', 'Column', 'One');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_8 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_8, 'twown.col', '24159ea43cbcecb50021cd14a1d41a8079fd9714', FALSE, FALSE, TRUE,'twown.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_8, 'twown.col', '24159ea43cbcecb50021cd14a1d41a8079fd9714', FALSE, FALSE, TRUE,'twown.col@example.com', @three_col_id, 'User', 'Column', 'Two');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_9 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_9, 'three.col', 'c736434430af90772bfd4351bffa3da04cec0403', FALSE, FALSE, TRUE,'three.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_9, 'three.col', 'c736434430af90772bfd4351bffa3da04cec0403', FALSE, FALSE, TRUE,'three.col@example.com', @three_col_id, 'User', 'Column', 'Three');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_10 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_10, 'threewn.col', 'ad67065a5bc25f86036508971a09a58e9c9131e8', FALSE, FALSE, TRUE,'threewn.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_10, 'threewn.col', 'ad67065a5bc25f86036508971a09a58e9c9131e8', FALSE, FALSE, TRUE,'threewn.col@example.com', @three_col_id, 'User', 'Column2', 'Three');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_11 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_11, 'four.col', 'c875ce4416fc56cd34c01bd366a3af5468137155', FALSE, FALSE, TRUE,'four.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_11, 'four.col', 'c875ce4416fc56cd34c01bd366a3af5468137155', FALSE, FALSE, TRUE,'four.col@example.com', @three_col_id, 'User', 'Column', 'Four');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_12 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_12, 'fourwn.col', 'eb0b450eff79a33027a41a05051f5609a83667e8', FALSE, FALSE, TRUE,'fourwn.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_12, 'fourwn.col', 'eb0b450eff79a33027a41a05051f5609a83667e8', FALSE, FALSE, TRUE,'fourwn.col@example.com', @three_col_id, 'User', 'Column2', 'Four');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 -- duplicate user id!!
 set @user_id_13 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_13, 'http://rave2011.myopenid.com/', 'cdf15c184b7d2539b0cfc29ee9f10bad62793d50', FALSE, FALSE, TRUE,'rave2011_openid@example.org', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_13, 'http://rave2011.myopenid.com/', 'cdf15c184b7d2539b0cfc29ee9f10bad62793d50', FALSE, FALSE, TRUE,'rave2011_openid@example.org', @three_col_id, 'User', 'Openid', 'Rave');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 --- end user data ---

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/api/rest/WidgetApi.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/api/rest/WidgetApi.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/api/rest/WidgetApi.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/api/rest/WidgetApi.java Wed Dec 21 20:49:00 2011
@@ -19,6 +19,8 @@
 
 package org.apache.rave.portal.web.api.rest;
 
+import org.apache.rave.portal.model.Person;
+import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.WidgetComment;
 import org.apache.rave.portal.model.WidgetRating;
 import org.apache.rave.portal.service.UserService;
@@ -29,13 +31,12 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-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.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 /**
  * Handler for all services exposed under the /api/widgets path.
@@ -140,4 +141,10 @@ public class WidgetApi extends AbstractR
         // send a 204 back for success since there is no content being returned
         response.setStatus(HttpStatus.NO_CONTENT.value());
     }
+
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.GET, value = "/{widgetId}/users")
+    public List<Person> getAllUsers(@PathVariable long widgetId) {
+        return userService.getAllByAddedWidget(widgetId);
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/api/rest/WidgetApiTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/api/rest/WidgetApiTest.java?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/api/rest/WidgetApiTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/api/rest/WidgetApiTest.java Wed Dec 21 20:49:00 2011
@@ -19,10 +19,7 @@
 
 package org.apache.rave.portal.web.api.rest;
 
-import org.apache.rave.portal.model.User;
-import org.apache.rave.portal.model.Widget;
-import org.apache.rave.portal.model.WidgetComment;
-import org.apache.rave.portal.model.WidgetRating;
+import org.apache.rave.portal.model.*;
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.service.WidgetCommentService;
 import org.apache.rave.portal.service.WidgetRatingService;
@@ -32,10 +29,13 @@ import org.springframework.http.HttpStat
 import org.springframework.mock.web.MockHttpServletResponse;
 
 import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
+import java.awt.*;
+import java.util.*;
+import java.util.List;
 
+import static org.hamcrest.CoreMatchers.*;
 import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 public class WidgetApiTest {
     private WidgetApi widgetApi;
@@ -45,6 +45,9 @@ public class WidgetApiTest {
     private MockHttpServletResponse response;
 
     private final Long VALID_USER_ID = 5L;
+    private final Long VALID_WIDGET_ID = 10L;
+    
+    private User user;
 
     @Before
     public void setup() {
@@ -52,10 +55,8 @@ public class WidgetApiTest {
         widgetRatingService = createMock(WidgetRatingService.class);
         userService = createMock(UserService.class);
 
-        User user = new User();
+        user = new User();
         user.setEntityId(VALID_USER_ID);
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        replay(userService);
 
         response = createMock(MockHttpServletResponse.class);
         widgetApi = new WidgetApi(widgetRatingService, widgetCommentService, userService);
@@ -76,12 +77,12 @@ public class WidgetApiTest {
 
         HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
         httpServletResponse.setStatus(HttpStatus.NO_CONTENT.value());
-        replay(httpServletResponse);
+        expect(userService.getAuthenticatedUser()).andReturn(user);
+        replay(userService, httpServletResponse);
 
         widgetApi.createWidgetComment(1L, comment, httpServletResponse);
 
-        verify(userService);
-        verify(httpServletResponse);
+        verify(userService, httpServletResponse);
     }
 
     @Test
@@ -105,9 +106,10 @@ public class WidgetApiTest {
         widgetComment.setText(message);
         widgetComment.setUser(new User(VALID_USER_ID, "John.Doe"));
 
+        expect(userService.getAuthenticatedUser()).andReturn(user);
         expect(widgetCommentService.getWidgetComment(3L)).andReturn(null);
         widgetCommentService.saveWidgetComment(widgetComment);
-        replay(widgetCommentService);
+        replay(userService, widgetCommentService);
 
         HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
         httpServletResponse.setStatus(HttpStatus.NO_CONTENT.value());
@@ -115,8 +117,7 @@ public class WidgetApiTest {
 
         widgetApi.updateWidgetComment(2L, 3L, message, httpServletResponse);
 
-        verify(widgetCommentService);
-        verify(httpServletResponse);
+        verify(userService, widgetCommentService, httpServletResponse);
     }
 
     @Test
@@ -137,8 +138,7 @@ public class WidgetApiTest {
 
         assertEquals(message, widgetComment.getText());
 
-        verify(widgetCommentService);
-        verify(httpServletResponse);
+        verify(widgetCommentService, httpServletResponse);
     }
 
     @Test
@@ -158,17 +158,13 @@ public class WidgetApiTest {
 
     @Test
     public void deleteWidgetRating() {
+        expect(userService.getAuthenticatedUser()).andReturn(user);
         widgetRatingService.removeWidgetRating(1L, VALID_USER_ID);
         expectLastCall();
-        replay(widgetRatingService);
-
         response.setStatus(HttpStatus.NO_CONTENT.value());
-        replay(response);
-
+        replay(userService, widgetRatingService, response);
         widgetApi.deleteWidgetRating(1L, response);
-
-        verify(widgetRatingService, userService);
-        verify(response);
+        verify(widgetRatingService, userService, response);
     }
 
     @Test
@@ -177,17 +173,28 @@ public class WidgetApiTest {
         widgetRating.setScore(5);
         widgetRating.setUserId(2L);
         widgetRating.setWidgetId(1L);
+        expect(userService.getAuthenticatedUser()).andReturn(user);
         widgetRatingService.saveWidgetRating(widgetRating);
         expectLastCall();
-        replay(widgetRatingService);
-
         response.setStatus(HttpStatus.NO_CONTENT.value());
-        replay(response);
+        replay(userService, widgetRatingService, response);
 
         User user = new User(2L);
         widgetApi.setWidgetRating(1L, 5, response);
 
-        verify(widgetRatingService, userService);
-        verify(response);
+        verify(widgetRatingService, userService, response);
+    }
+
+    @Test
+    public void getAllUsers() {
+        List<Person> persons = new ArrayList<Person>();
+        persons.add(new Person());
+        persons.add(new Person());
+        
+        expect(userService.getAllByAddedWidget(VALID_WIDGET_ID)).andReturn(persons);
+        replay(userService);
+        assertThat(widgetApi.getAllUsers(VALID_WIDGET_ID), sameInstance(persons));
+
+        verify(userService);
     }
 }

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=1221873&r1=1221872&r2=1221873&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 Wed Dec 21 20:49:00 2011
@@ -120,6 +120,7 @@ page.widget.rate.like=Like
 page.widget.rate.dislike=Dislike
 page.widget.comments=Comments
 page.widget.comment.edit=Edit Comment
+page.widget.usercount=users
 
 page.addwidget.title=Add new widget
 page.addwidget.form.header=Widget

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=1221873&r1=1221872&r2=1221873&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 Wed Dec 21 20:49:00 2011
@@ -120,6 +120,7 @@ page.widget.rate.like=Leuk
 page.widget.rate.dislike=Niet leuk
 page.widget.comments=Commentaren
 page.widget.comment.edit=Bewerk commentaar
+page.widget.usercount=gebruikers
 
 page.addwidget.title=Voeg nieuwe widget toe
 page.addwidget.form.header=Widget

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=1221873&r1=1221872&r2=1221873&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 Wed Dec 21 20:49:00 2011
@@ -101,69 +101,69 @@ UPDATE RAVE_PORTAL_SEQUENCES SET seq_cou
   -- ***********************************************************************************
   --- start user data ---
 set @user_id_1 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_1, 'canonical', 'b97fd0fa25ba8a504309be2b6651ac6dee167ded', FALSE, FALSE, TRUE,'canonical@example.com', @three_col_id, 'User', 'Canonical User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_1, 'canonical', 'b97fd0fa25ba8a504309be2b6651ac6dee167ded', FALSE, FALSE, TRUE,'canonical@example.com', @three_col_id, 'User', 'Canonical User', 'User', 'Canonical');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_2 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_2, 'john.doe', '49e5f5c7c7ae8372af9b3063c493f080d16411f5', FALSE, FALSE, TRUE,'john.doe@example.com', @three_col_id, 'User', 'John Doe');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_2, 'john.doe', '49e5f5c7c7ae8372af9b3063c493f080d16411f5', FALSE, FALSE, TRUE,'john.doe@example.com', @three_col_id, 'User', 'John Doe', 'Doe', 'John');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_3 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_3, 'jane.doe', '30dd37e81704bbbd4e235c22990802ae25b187da', FALSE, FALSE, TRUE,'jane.doe@example.net', @three_col_id, 'User', 'Jane Doe');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_3, 'jane.doe', '30dd37e81704bbbd4e235c22990802ae25b187da', FALSE, FALSE, TRUE,'jane.doe@example.net', @three_col_id, 'User', 'Jane Doe', 'Doe', 'Jane');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_4 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_4, 'george.doe', '452802e3f2ff8b7b28785f50dfaaaaf80fc1430f', FALSE, FALSE, TRUE,'george.doe@example.org', @three_col_id, 'User', 'George Doe');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_4, 'george.doe', '452802e3f2ff8b7b28785f50dfaaaaf80fc1430f', FALSE, FALSE, TRUE,'george.doe@example.org', @three_col_id, 'User', 'George Doe', 'Doe', 'George');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_5 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_5,'mario.rossi', '8aadae9f6e73a479cb8a565bcfa6e8de2b074e89', FALSE, FALSE, TRUE,'mario.rossi@example.com', @three_col_id, 'User', 'Mario Rossi');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_5,'mario.rossi', '8aadae9f6e73a479cb8a565bcfa6e8de2b074e89', FALSE, FALSE, TRUE,'mario.rossi@example.com', @three_col_id, 'User', 'Mario Rossi', 'Rossi', 'Mario');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_6 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name)
-values (@user_id_6, 'maija.m', '18550acca1b36af6cfa41c82e1caab12073475a1', FALSE, FALSE, TRUE,'maijam@example.com', @three_col_id, 'User', 'Maija M');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, display_name, family_name, given_name)
+values (@user_id_6, 'maija.m', '18550acca1b36af6cfa41c82e1caab12073475a1', FALSE, FALSE, TRUE,'maijam@example.com', @three_col_id, 'User', 'Maija M', 'M', 'Maija');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_7 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_7, 'one.col', '07acee6193e84ba9ae2f7b2bf26538f2d6e4b0a1', FALSE, FALSE, TRUE,'one.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_7, 'one.col', '07acee6193e84ba9ae2f7b2bf26538f2d6e4b0a1', FALSE, FALSE, TRUE,'one.col@example.com', @three_col_id, 'User', 'Column', 'One');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_8 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_8, 'twown.col', '24159ea43cbcecb50021cd14a1d41a8079fd9714', FALSE, FALSE, TRUE,'twown.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_8, 'twown.col', '24159ea43cbcecb50021cd14a1d41a8079fd9714', FALSE, FALSE, TRUE,'twown.col@example.com', @three_col_id, 'User', 'Column', 'Two');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_9 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_9, 'three.col', 'c736434430af90772bfd4351bffa3da04cec0403', FALSE, FALSE, TRUE,'three.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_9, 'three.col', 'c736434430af90772bfd4351bffa3da04cec0403', FALSE, FALSE, TRUE,'three.col@example.com', @three_col_id, 'User', 'Column', 'Three');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_10 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_10, 'threewn.col', 'ad67065a5bc25f86036508971a09a58e9c9131e8', FALSE, FALSE, TRUE,'threewn.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_10, 'threewn.col', 'ad67065a5bc25f86036508971a09a58e9c9131e8', FALSE, FALSE, TRUE,'threewn.col@example.com', @three_col_id, 'User', 'ColumnWide', 'Three');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_11 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_11, 'four.col', 'c875ce4416fc56cd34c01bd366a3af5468137155', FALSE, FALSE, TRUE,'four.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_11, 'four.col', 'c875ce4416fc56cd34c01bd366a3af5468137155', FALSE, FALSE, TRUE,'four.col@example.com', @three_col_id, 'User', 'Column', 'Four');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 set @user_id_12 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_12, 'fourwn.col', 'eb0b450eff79a33027a41a05051f5609a83667e8', FALSE, FALSE, TRUE,'fourwn.col@example.com', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_12, 'fourwn.col', 'eb0b450eff79a33027a41a05051f5609a83667e8', FALSE, FALSE, TRUE,'fourwn.col@example.com', @three_col_id, 'User', 'ColumnWide', 'Four');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 -- duplicate user id!!
 set @user_id_13 = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @user_seq);
-insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype)
-values (@user_id_13, 'http://rave2011.myopenid.com/', 'cdf15c184b7d2539b0cfc29ee9f10bad62793d50', FALSE, FALSE, TRUE,'rave2011_openid@example.org', @three_col_id, 'User');
+insert into person (entity_id, username, password, expired, locked, enabled, email, default_page_layout_id, dtype, family_name, given_name)
+values (@user_id_13, 'http://rave2011.myopenid.com/', 'cdf15c184b7d2539b0cfc29ee9f10bad62793d50', FALSE, FALSE, TRUE,'rave2011_openid@example.org', @three_col_id, 'User', 'OpenId', 'Rave');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @user_seq;
 
 --- end user data ---

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/store.jsp Wed Dec 21 20:49:00 2011
@@ -143,7 +143,9 @@
             <ul class="storeItems">
                     <%--@elvariable id="widget" type="org.apache.rave.portal.model.Widget"--%>
                 <c:forEach var="widget"
-                           items="${widgets.resultSet}"><%--@elvariable id="widgetsStatistics" type="org.apache.rave.portal.model.util.WidgetStatistics"--%>
+                           items="${widgets.resultSet}">
+                    <%--@elvariable id="widgetsStatistics" type="org.apache.rave.portal.model.util.WidgetStatistics"--%>
+                    <c:set var="widgetStatistics" value="${widgetsStatistics[widget.entityId]}" />
                     <li class="storeItem">
 
                         <div class="storeItemLeft">
@@ -165,7 +167,8 @@
 
                         <div class="storeItemCenter">
 
-                            <a class="secondaryPageItemTitle"
+                            <a id="widget-${widget.entityId}-title"
+                               class="secondaryPageItemTitle"
                                href="<spring:url value="/app/store/widget/${widget.entityId}" />?referringPageId=${referringPageId}">
                                 <c:out value="${widget.title}"/>
                             </a>
@@ -180,18 +183,24 @@
                             </c:if>
                             <div class="widgetRating">
                                 <fmt:message key="page.widget.rate"/>
-                                <c:set var="totalLikes" value="${widgetsStatistics[widget.entityId].totalLike}"/>
-                                <c:set var="totalDislikes" value="${widgetsStatistics[widget.entityId].totalDislike}"/>
+                                <c:set var="totalLikes" value="${widgetStatistics.totalLike}"/>
+                                <c:set var="totalDislikes" value="${widgetStatistics.totalDislike}"/>
 
                                 <div id="rating-${widget.entityId}" class="ratingButtons">
                                     <input type="radio" id="like-${widget.entityId}" class="widgetLikeButton"
-                                           name="rating-${widget.entityId}"${widgetsStatistics[widget.entityId].userRating==10?" checked='true'":""}>
-                                    <label for="like-${widget.entityId}">${widgetsStatistics[widget.entityId]!=null?widgetsStatistics[widget.entityId].totalLike:"0"}</label>
+                                           name="rating-${widget.entityId}"${widgetStatistics.userRating==10?" checked='true'":""}>
+                                    <label for="like-${widget.entityId}">${widgetStatistics!=null?widgetStatistics.totalLike:"0"}</label>
                                     <input type="radio" id="dislike-${widget.entityId}" class="widgetDislikeButton"
-                                           name="rating-${widget.entityId}"${widgetsStatistics[widget.entityId].userRating==0?" checked='true'":""}>
-                                    <label for="dislike-${widget.entityId}">${widgetsStatistics[widget.entityId]!=null?widgetsStatistics[widget.entityId].totalDislike:"0"}</label>
+                                           name="rating-${widget.entityId}"${widgetStatistics.userRating==0?" checked='true'":""}>
+                                    <label for="dislike-${widget.entityId}">${widgetStatistics!=null?widgetStatistics.totalDislike:"0"}</label>
                                 </div>
                             </div>
+                            <div class="widgetUserCount">
+                                <c:set var="widgetUserCountGreaterThanZero" value="${widgetStatistics != null && widgetStatistics.totalUserCount > 0}" />
+                                <c:if test="${widgetUserCountGreaterThanZero}"><a href="javascript:void(0);" onclick="rave.displayUsersOfWidget(${widget.entityId});"></c:if>
+                                    <fmt:formatNumber groupingUsed="true" value="${widgetStatistics!=null?widgetStatistics.totalUserCount:0}" />&nbsp;<fmt:message key="page.widget.usercount"/>
+                                <c:if test="${widgetUserCountGreaterThanZero}"></a></c:if>
+                            </div>
                         </div>
 
                         <div class="clear-float"></div>

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/widget.jsp Wed Dec 21 20:49:00 2011
@@ -62,18 +62,12 @@
     <div class="widget-content">
 
         <h2>
-            <c:choose>
-                <c:when test="${not empty widget.titleUrl}">
-                    <a href="<c:out value="${widget.titleUrl}"/>" rel="external"><c:out
-                            value="${widget.title}"/></a>
-                </c:when>
-                <c:otherwise>
-                    <c:out value="${widget.title}"/>
-                </c:otherwise>
-            </c:choose>
+            <c:set var="widgetHasTitleUrl" value="${not empty widget.titleUrl}" />
+            <c:if test="${widgetHasTitleUrl}"><a href="<c:out value="${widget.titleUrl}"/>"rel="external"></c:if>
+            <span id="widget-${widget.entityId}-title"><c:out value="${widget.title}"/></span>
+            <c:if test="${widgetHasTitleUrl}"></a></c:if>
         </h2>
 
-
         <div class="detailWidgetPreview">
             <c:if test="${not empty widget.screenshotUrl}">
                 <div class="detailWidgetScreenshot">
@@ -141,7 +135,12 @@
                     <label for="dislike-${widget.entityId}">${widgetStatistics.totalDislike}</label>
                 </div>
             </div>
-
+            <div class="widgetUserCount">
+                <c:set var="widgetUserCountGreaterThanZero" value="${widgetStatistics != null && widgetStatistics.totalUserCount > 0}" />
+                <c:if test="${widgetUserCountGreaterThanZero}"><a href="javascript:void(0);" onclick="rave.displayUsersOfWidget(${widget.entityId});"></c:if>
+                <fmt:formatNumber groupingUsed="true" value="${widgetStatistics.totalUserCount}" />&nbsp;<fmt:message key="page.widget.usercount"/>
+                <c:if test="${widgetUserCountGreaterThanZero}"></a></c:if>
+            </div>
         </div>
 
         <div class="widgetComments">

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=1221873&r1=1221872&r2=1221873&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 Wed Dec 21 20:49:00 2011
@@ -445,6 +445,18 @@ header h1 {
     box-shadow: 2px 2px 2px black;
 }
 
+.widget-users-dialog {
+    height: 200px;
+}
+
+.widget-users {
+    list-style-type: none;
+}
+
+.widget-user {
+
+}
+
 .widget-content {
     width: 80%;
     margin: 0 auto;

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave.js Wed Dec 21 20:49:00 2011
@@ -537,6 +537,25 @@ var rave = rave || (function() {
             $("#emptyPageMessageWrapper").removeClass("hidden");
         }
 
+        function displayUsersOfWidget(widgetId) {
+            rave.api.rest.getUsersForWidget({widgetId: widgetId, successCallback: function(data){
+                var html = "<ul class='widget-users'>";
+                for (var i=0; i < data.length; i++) {
+                    var person = data[i];
+                    var name = (person.displayName) ? person.displayName :
+                                                      ((person.preferredName) ? person.preferredName : person.givenName) + " " + person.familyName;
+
+                    html += "<li class='widget-user'>" + name + "</li>";
+                }
+                html+="</ul>";
+
+                $("<div class='dialog widget-users-dialog' title='" + $("#widget-" + widgetId + "-title").text().trim() + " has been added by...'>" + html + "</div>").dialog({
+                    modal: true,
+                    buttons: [{text: "Close", click: function(){$(this).dialog("close");}}]
+                });
+            }});
+        }
+
         return {
           init : init,       
           initMobile: initMobileWidgetUI,
@@ -548,7 +567,8 @@ var rave = rave || (function() {
           getMobileState: getMobileState,
           doWidgetUiCollapse: doWidgetUiCollapse,
           toggleMobileWidget: toggleMobileWidget,
-          displayEmptyPageMessage: displayEmptyPageMessage
+          displayEmptyPageMessage: displayEmptyPageMessage,
+          displayUsersOfWidget: displayUsersOfWidget
         };
 
     })();
@@ -851,6 +871,11 @@ var rave = rave || (function() {
         /**
          * Displays the "empty page" message on the page
          */        
-        displayEmptyPageMessage: ui.displayEmptyPageMessage
+        displayEmptyPageMessage: ui.displayEmptyPageMessage,
+
+        /**
+         * Displays the users of a supplied widgetId in a dialog box
+         */
+        displayUsersOfWidget: ui.displayUsersOfWidget
     }
 })();

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_api.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_api.js?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_api.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_api.js Wed Dec 21 20:49:00 2011
@@ -161,6 +161,19 @@ rave.api = rave.api || (function() {
             })
         }
 
+        function getUsersForWidget(args) {
+            $.ajax({
+                type: 'GET',
+                url: rave.getContext() + path + "widgets/" + args.widgetId + "/users",
+                success: function(result) {
+                    if (typeof args.successCallback == 'function') {
+                        args.successCallback(result);
+                    }
+                },
+                error: handleError
+            })
+        }
+
         return {
             updateWidgetRating: updateWidgetRating,
             deleteWidgetRating: deleteWidgetRating,
@@ -170,7 +183,8 @@ rave.api = rave.api || (function() {
             createWidgetComment : createWidgetComment,
             updateWidgetComment : updateWidgetComment,
             deleteWidgetComment : deleteWidgetComment,
-            deletePage : deletePage
+            deletePage : deletePage,
+            getUsersForWidget: getUsersForWidget
         };
     })();
 

Modified: incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveApiSpec.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveApiSpec.js?rev=1221873&r1=1221872&r2=1221873&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveApiSpec.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/test/javascript/raveApiSpec.js Wed Dec 21 20:49:00 2011
@@ -135,7 +135,29 @@ describe("Rave API", function() {
                 rave.api.rest.deletePage({pageId: 9, successCallback: callback});
                 expect(callbackCalled).toBeTruthy();
             });
-        });                
+        });
+
+        describe("getUsersForWidget", function() {
+            it("GETs the widget users using the REST service", function() {
+                $.ajax = function(args) {
+                    expect(args.url).toEqual("api/rest/widgets/23/users");
+                    expect(typeof(callback)).toEqual("function");
+                    callback({error:false});
+                    return {
+                        error: function(a, b, c) {
+                        }
+                    }
+                };
+
+                var callbackCalled = false;
+                var callback = function() {
+                    callbackCalled = true
+                };
+
+                rave.api.rest.getUsersForWidget({widgetId: 23, successCallback: callback});
+                expect(callbackCalled).toBeTruthy();
+            });
+        });
     });
 
     describe("rpc", function() {