[pal-cvs 2362] [96] supported paging on pal portal.

svnno****@sourc***** svnno****@sourc*****
2007年 5月 7日 (月) 18:06:38 JST


Revision: 96
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=96
Author:   shinsuke
Date:     2007-05-07 18:06:37 +0900 (Mon, 07 May 2007)

Log Message:
-----------
supported paging on pal portal.

Modified Paths:
--------------
    pal-admin/trunk/.classpath
    pal-admin/trunk/pom.xml
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/pager/UserPager.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserListPage.java
    pal-admin/trunk/src/main/resources/appMessages.properties


-------------- next part --------------
Modified: pal-admin/trunk/.classpath
===================================================================
--- pal-admin/trunk/.classpath	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/.classpath	2007-05-07 09:06:37 UTC (rev 96)
@@ -3,6 +3,7 @@
     <classpathentry kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
     <classpathentry kind="src" path="src/main/webapp/view"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+
   <classpathentry kind="var" path="M2_REPO/org/apache/pluto/pluto/1.0.1/pluto-1.0.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/teeda/teeda-core/1.0.7-SNAPSHOT/teeda-core-1.0.7-SNAPSHOT.jar" sourcepath="M2_REPO/org/seasar/teeda/teeda-core/1.0.7-SNAPSHOT/teeda-core-1.0.7-SNAPSHOT-sources.jar"/>
@@ -10,9 +11,9 @@
   <classpathentry kind="var" path="M2_REPO/portlet-api/portlet-api/1.0/portlet-api-1.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/poi/poi/2.5.1-final-20040804/poi-2.5.1-final-20040804.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/teeda/teeda-ajax/1.0.7-SNAPSHOT/teeda-ajax-1.0.7-SNAPSHOT.jar" sourcepath="M2_REPO/org/seasar/teeda/teeda-ajax/1.0.7-SNAPSHOT/teeda-ajax-1.0.7-SNAPSHOT-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar" sourcepath="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar" sourcepath="M2_REPO/javax/servlet/jstl/1.1.2/jstl-1.1.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar" sourcepath="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/container/s2-tiger/2.4.11/s2-tiger-2.4.11.jar"/>
@@ -21,23 +22,23 @@
   <classpathentry kind="var" path="M2_REPO/oro/oro/2.0.8/oro-2.0.8.jar" sourcepath="M2_REPO/oro/oro/2.0.8/oro-2.0.8-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/jp/sf/pal/portlet-output-optimizer/0.2/portlet-output-optimizer-0.2.jar" sourcepath="M2_REPO/jp/sf/pal/portlet-output-optimizer/0.2/portlet-output-optimizer-0.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jp/sf/pal/faces-response-filter/0.2/faces-response-filter-0.2.jar" sourcepath="M2_REPO/jp/sf/pal/faces-response-filter/0.2/faces-response-filter-0.2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar" sourcepath="M2_REPO/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/myfaces/tomahawk/tomahawk/1.1.3/tomahawk-1.1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jp/sf/pal/faces-response-filter/0.2/faces-response-filter-0.2.jar" sourcepath="M2_REPO/jp/sf/pal/faces-response-filter/0.2/faces-response-filter-0.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.1/commons-io-1.1.jar" sourcepath="M2_REPO/commons-io/commons-io/1.1/commons-io-1.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jp/sf/pal/tomahawk-bridge/0.9.1/tomahawk-bridge-0.9.1.jar" sourcepath="M2_REPO/jp/sf/pal/tomahawk-bridge/0.9.1/tomahawk-bridge-0.9.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/javassist/3.4.ga/javassist-3.4.ga.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jp/sf/pal/tomahawk-bridge/0.9.1/tomahawk-bridge-0.9.1.jar" sourcepath="M2_REPO/jp/sf/pal/tomahawk-bridge/0.9.1/tomahawk-bridge-0.9.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/container/s2-framework/2.4.11/s2-framework-2.4.11.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.3.1/commons-io-1.3.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/portlet/s2-portlet/1.0.7-SNAPSHOT/s2-portlet-1.0.7-SNAPSHOT.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/container/s2-extension/2.4.11/s2-extension-2.4.11.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/seasar/teeda/teeda-extension/1.0.7-SNAPSHOT/teeda-extension-1.0.7-SNAPSHOT.jar" sourcepath="M2_REPO/org/seasar/teeda/teeda-extension/1.0.7-SNAPSHOT/teeda-extension-1.0.7-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.1.1/commons-fileupload-1.1.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/portals/bridges/portals-bridges-portletfilter/1.0.2-dev/portals-bridges-portletfilter-1.0.2-dev.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/ognl/ognl/2.6.7/ognl-2.6.7.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/portals/jetspeed-2/jetspeed-api/2.2-dev_pal-1.0-beta5-dev/jetspeed-api-2.2-dev_pal-1.0-beta5-dev.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-ejb_2.1_spec/1.0/geronimo-ejb_2.1_spec-1.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-ejb_2.1_spec/1.0/geronimo-ejb_2.1_spec-1.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0.jar" sourcepath="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/portals/jetspeed-2/jetspeed-api/2.2-dev/jetspeed-api-2.2-dev.jar"/>
 </classpath>

Modified: pal-admin/trunk/pom.xml
===================================================================
--- pal-admin/trunk/pom.xml	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/pom.xml	2007-05-07 09:06:37 UTC (rev 96)
@@ -122,6 +122,12 @@
       <url>http://www.marevol.com/maven2</url>
     </repository>
     <repository>
+      <id>maven1.marevol.com</id>
+      <name>Maven1 Repository on marevol.com</name>
+      <url>http://www.marevol.com/maven</url>
+      <layout>legacy</layout>
+    </repository>
+    <repository>
       <id>maven.seasar.org</id>
       <name>The Seasar Foundation Maven2 Repository</name>
       <url>http://maven.seasar.org/maven2</url>
@@ -234,7 +240,7 @@
     <dependency>
       <groupId>org.apache.portals.jetspeed-2</groupId>
       <artifactId>jetspeed-api</artifactId>
-      <version>2.2-dev</version>
+      <version>2.2-dev_pal-1.0-beta5-dev</version>
 <!-- PORTLET DEV: BEGIN -->
       <scope>provided</scope>
 <!-- PORTLET DEV: END -->

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java	2007-05-07 09:06:37 UTC (rev 96)
@@ -276,42 +276,66 @@
     // User
     //
 
-    public List<User> getUsers(UserPager pager)
+    public List<User> getUsers(UserPager pager) throws PALAdminException
     {
         //Debug
         if (PALAdminConstants.DEBUG)
         {
             List<User> list = new ArrayList<User>();
             User entity = new User();
-            entity.setName("GROUP");
+            entity.setName("USER");
             list.add(entity);
             return list;
         }
 
+        if (pager.getAuthenticationProviderName() == null)
+        {
+            pager
+                    .setAuthenticationProviderName(getAuthenticationProviderProxy()
+                            .getDefaultAuthenticationProvider());
+        }
+
+        StringBuffer fb = new StringBuffer("AdvanceFilter: ");
+        fb.append("username=").append(pager.getFilter());
+
         List<User> userList = new ArrayList<User>();
-        List<Principal> principals = getAuthenticationProviderProxy()
-                .getUserPrincipals(pager.getFilter());
 
-        // set count
-        pager.setCount(principals.size());
+        try
+        {
+            // set count
+            pager.setCount(getAuthenticationProviderProxy().getUserCount(
+                    fb.toString(), pager.getAuthenticationProviderName()));
 
-        // create list
-        int offset = pager.getOffset();
-        int limit = pager.getLimit();
-        int size = principals.size();
-        if (logger.isDebugEnabled())
-        {
-            logger.debug("getUsers(UserPager) - pager.getFilter()="
-                    + pager.getFilter());
-            logger.debug("getUsers(UserPager) - offset=" + offset + ", limit="
-                    + limit + ", size=" + size);
+            int startAtIndex = pager.getOffset() + 1;
+            int endAtIndex = startAtIndex + pager.getLimit();
+            fb.append(", startAtIndex=").append(startAtIndex).append(
+                    ", endAtIndex=").append(endAtIndex);
+
+            List<Principal> principals = getAuthenticationProviderProxy()
+                    .getUserPrincipals(fb.toString(),
+                            pager.getAuthenticationProviderName());
+
+            int size = principals.size();
+            if (logger.isDebugEnabled())
+            {
+                logger.debug("getUsers(UserPager) - pager.getFilter()="
+                        + pager.getFilter());
+                logger.debug("getUsers(UserPager) - size=" + size + ", filter="
+                        + fb.toString());
+            }
+
+            for (int i = 0; i < size; i++)
+            {
+                User entity = new User();
+                entity.setName(principals.get(i).getName());
+                // TODO Others
+                userList.add(entity);
+            }
         }
-        for (int i = offset; i < offset + limit && i < size; i++)
+        catch (SecurityException e)
         {
-            User entity = new User();
-            entity.setName(principals.get(i).getName());
-            // TODO Others
-            userList.add(entity);
+            logger.error("Could not get users.", e);
+            throw new PALAdminException(e);
         }
 
         return userList;

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/pager/UserPager.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/pager/UserPager.java	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/pager/UserPager.java	2007-05-07 09:06:37 UTC (rev 96)
@@ -27,10 +27,13 @@
 
     private String filter;
 
+    private String authenticationProviderName;
+
     public UserPager()
     {
         super();
         filter = "";
+        authenticationProviderName = null;
     }
 
     /**
@@ -48,4 +51,20 @@
     {
         this.filter = filter;
     }
+
+    /**
+     * @return the authenticationProviderName
+     */
+    public String getAuthenticationProviderName()
+    {
+        return authenticationProviderName;
+    }
+
+    /**
+     * @param authenticationProviderName the authenticationProviderName to set
+     */
+    public void setAuthenticationProviderName(String authenticationProviderName)
+    {
+        this.authenticationProviderName = authenticationProviderName;
+    }
 }

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java	2007-05-07 09:06:37 UTC (rev 96)
@@ -122,7 +122,7 @@
         this.labelHelper = labelHelper;
     }
 
-    public void loadPage(UserListPage page)
+    public void loadPage(UserListPage page) throws PALAdminException
     {
         UserPager pager = getUserPager();
 

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserListPage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserListPage.java	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserListPage.java	2007-05-07 09:06:37 UTC (rev 96)
@@ -20,10 +20,14 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.faces.internal.FacesMessageUtil;
+
+import jp.sf.pal.admin.PALAdminException;
 import jp.sf.pal.admin.service.UserManagementService;
 import jp.sf.pal.admin.web.AbstractPagerPage;
 import jp.sf.pal.admin.web.CrudType;
 
+import org.seasar.framework.log.Logger;
 import org.seasar.teeda.extension.annotation.takeover.TakeOver;
 
 public class UserListPage extends AbstractPagerPage implements Serializable
@@ -34,6 +38,11 @@
      */
     private static final long serialVersionUID = 1803281059596051705L;
 
+    /**
+     * Logger for this class
+     */
+    private static final Logger logger = Logger.getLogger(UserListPage.class);
+
     private String name;
 
     private int userIndex;
@@ -96,7 +105,15 @@
 
     public String prerender()
     {
-        userManagementService.loadPage(this);
+        try
+        {
+            userManagementService.loadPage(this);
+        }
+        catch (PALAdminException e)
+        {
+            FacesMessageUtil.addErrorMessage("failed.to.get.users");
+            logger.error("Failed to add a new user: " + getName(), e);
+        }
 
         return null;
     }

Modified: pal-admin/trunk/src/main/resources/appMessages.properties
===================================================================
--- pal-admin/trunk/src/main/resources/appMessages.properties	2007-05-07 09:03:32 UTC (rev 95)
+++ pal-admin/trunk/src/main/resources/appMessages.properties	2007-05-07 09:06:37 UTC (rev 96)
@@ -63,4 +63,5 @@
 deleted.repository=Deleted the repository.
 failed.to.delete.repository=Failed to delete the repository.
 
+failed.to.get.users=Failed to load users.
 


pal-cvs メーリングリストの案内