You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2010/04/02 17:39:04 UTC

svn commit: r930298 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-security/src: main/java/org/apache/jetspeed/security/mapping/ main/java/org/apache/jetspeed/security/mapping/impl/ main/java/org/apache/jetspeed/security/mapping/ldap/ main/j...

Author: ate
Date: Fri Apr  2 15:39:03 2010
New Revision: 930298

URL: http://svn.apache.org/viewvc?rev=930298&view=rev
Log:
JS2-1171: Provide LDAP search paging and callback handling support
See: http://issues.apache.org/jira/browse/JS2-1171
- further improvements and more Generics based usage pattern support
- integrated now in all default LDAP DAOs and synchronizer replacing all previously full result collection returning solutions
- Default LDAP sychronizer still has some issues which needs to be fixed, runtime modifications from Jetspeed PrincipalManagers are all properly replicated though  

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java   (contents, props changed)
      - copied, changed from r929928, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/AbstractSearchResultHandler.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java   (with props)
Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/AbstractSearchResultHandler.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CountingSearchResultHandler.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SearchResultCallbackHandler.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingSearchResultHandler.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/EntityFactoryImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityRelationDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/PagedSearchExecutor.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/BasicTestCases.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java?rev=930298&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java Fri Apr  2 15:39:03 2010
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping;
+
+/**
+ * @version $Id$
+ *
+ */
+public interface EntitySearchResultHandler extends SearchResultCallbackHandler
+{
+    void setEntityFactory(EntityFactory factory);
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/EntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SearchResultCallbackHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SearchResultCallbackHandler.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SearchResultCallbackHandler.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SearchResultCallbackHandler.java Fri Apr  2 15:39:03 2010
@@ -22,5 +22,9 @@ package org.apache.jetspeed.security.map
  */
 public interface SearchResultCallbackHandler
 {
+    int getMaxCount();
+    int getSearchPageSize();
     boolean handleSearchResult(Object result, int pageSize, int pageIndex, int index);
+    void setFeedback(Object feedback);
+    Object getFeedback();
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java Fri Apr  2 15:39:03 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jetspeed.security.mapping;
 
-import java.util.Collection;
 import java.util.Set;
 
 import org.apache.jetspeed.security.SecurityException;
@@ -39,7 +38,7 @@ public interface SecurityEntityManager
     
     Entity getEntity(String entityType, String entityId) throws SecurityException;
 
-    Collection<Entity> getAllEntities(String entityType) throws SecurityException;
+    void getAllEntities(String entityType, EntitySearchResultHandler handler) throws SecurityException;
 
     void addEntity(Entity entity) throws SecurityException;
 
@@ -53,9 +52,9 @@ public interface SecurityEntityManager
     
     void removeRelation(String fromEntityId, String toEntityId, SecurityEntityRelationType relationType) throws SecurityException;
     
-    Collection<Entity> getRelatedEntitiesFrom(Entity fromEntity, SecurityEntityRelationType relationType) throws SecurityException;
+    void getRelatedEntitiesFrom(Entity fromEntity, SecurityEntityRelationType relationType, EntitySearchResultHandler handler) throws SecurityException;
 
-    Collection<Entity> getRelatedEntitiesTo(Entity toEntity, SecurityEntityRelationType relationType) throws SecurityException;
+    void getRelatedEntitiesTo(Entity toEntity, SecurityEntityRelationType relationType, EntitySearchResultHandler handler) throws SecurityException;
 
     EntityFactory getEntityFactory(String entityType);
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java?rev=930298&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java Fri Apr  2 15:39:03 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping.impl;
+
+import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
+import org.apache.jetspeed.security.mapping.model.Entity;
+
+/**
+ * @version $Id$
+ *
+ */
+public class BaseEntitySearchResultHandler extends BaseSearchResultHandler<Entity,Object> implements EntitySearchResultHandler
+{
+    private EntityFactory entityFactory;
+    
+    public BaseEntitySearchResultHandler()
+    {
+    }
+
+    public BaseEntitySearchResultHandler(int maxCount)
+    {
+        super(maxCount);
+    }
+    
+    public void setEntityFactory(EntityFactory entityFactory)
+    {
+        this.entityFactory = entityFactory;
+    }
+
+    protected Entity mapResult(Object result, int pageSize, int pageIndex, int index)
+    {
+        return entityFactory.loadEntity(result);
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java (from r929928, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/AbstractSearchResultHandler.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java?p2=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/AbstractSearchResultHandler.java&r1=929928&r2=930298&rev=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/AbstractSearchResultHandler.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java Fri Apr  2 15:39:03 2010
@@ -22,23 +22,51 @@ import org.apache.jetspeed.security.mapp
  * @author <a href="mailto:ate@douma.nu>Ate Douma</a>
  * @version $Id$
  */
-public abstract class AbstractSearchResultHandler implements SearchResultCallbackHandler
+public class BaseSearchResultHandler<T,R> implements SearchResultCallbackHandler
 {
     private final int maxCount;
+    private int searchPageSize = -1; // disabled
     private int count;
     private int size;
     private boolean aborted;
+    private Object feedback;
         
-    public AbstractSearchResultHandler()
+    public BaseSearchResultHandler()
     {
-        this(Integer.MAX_VALUE);
+        this(0);
     }
     
-    public AbstractSearchResultHandler(int maxCount)
+    public BaseSearchResultHandler(int maxCount)
     {
-        this.maxCount = maxCount < 1 ? Integer.MAX_VALUE : maxCount;
+        this.maxCount = maxCount < 1 ? 0 : maxCount;
+        if (maxCount == 1)
+        {
+            searchPageSize = 0;
+        }
     }
-
+    
+    public void setSearchPageSize(int searchPageSize)
+    {
+        if (searchPageSize < 0)
+        {
+            this.searchPageSize = 0;
+        }
+        else if (maxCount > 1 && searchPageSize > maxCount)
+        {
+            this.searchPageSize = maxCount+1;
+        }
+        else
+        {
+            this.searchPageSize = searchPageSize;
+        }
+    }
+    
+    public int getSearchPageSize()
+    {
+        return searchPageSize;
+    }
+    
+    @SuppressWarnings("unchecked")
     public final boolean handleSearchResult(Object result, int pageSize, int pageIndex, int index)
     {
         count++;
@@ -47,7 +75,15 @@ public abstract class AbstractSearchResu
             boolean noExceptions = false;
             try
             {
-                processSearchResult(result, pageSize, pageIndex, index);
+                T mappedResult = mapResult((R)result, pageSize, pageIndex, index);
+                if (mappedResult != null)
+                {
+                    aborted = !processSearchResult(mappedResult, pageSize, pageIndex, index);
+                    if (!aborted)
+                    {
+                        aborted = !postHandleSearchResult(mappedResult, pageSize, pageIndex, index);
+                    }
+                }
                 noExceptions = true;
             }
             finally
@@ -60,7 +96,7 @@ public abstract class AbstractSearchResu
             if (!aborted)
             {
                 size++;
-                if (count > maxCount)
+                if (maxCount > 0 && count > maxCount)
                 {
                     aborted = true;
                 }
@@ -69,14 +105,19 @@ public abstract class AbstractSearchResu
         return !aborted;
     }
     
-    public final boolean isAborted()
+    public void setFeedback(Object feedback)
     {
-        return aborted;
+        this.feedback = feedback;
+    }
+        
+    public Object getFeedback()
+    {
+        return feedback;
     }
     
-    protected final void setAborted()
+    public final boolean isAborted()
     {
-        aborted = true;
+        return aborted;
     }
     
     public final int getMaxCount()
@@ -94,5 +135,19 @@ public abstract class AbstractSearchResu
         return size;
     }
     
-    protected abstract void processSearchResult(Object result, int pageSize, int pageIndex, int index);
+    @SuppressWarnings("unchecked")
+    protected T mapResult(R result, int pageSize, int pageIndex, int index)
+    {
+        return (T)result;
+    }
+
+    protected boolean processSearchResult(T result, int pageSize, int pageIndex, int index)
+    {
+        return true;
+    }
+    
+    protected boolean postHandleSearchResult(T result, int pageSize, int pageIndex, int index)
+    {
+        return true;
+    }
 }

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/BaseSearchResultHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java?rev=930298&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java Fri Apr  2 15:39:03 2010
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.security.mapping.impl;
+
+import java.util.List;
+
+import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
+import org.apache.jetspeed.security.mapping.model.Entity;
+
+/**
+ * @version $Id$
+ *
+ */
+public class CollectingEntitySearchResultHandler extends CollectingSearchResultHandler<Entity,Object> implements EntitySearchResultHandler
+{
+    public CollectingEntitySearchResultHandler()
+    {
+    }
+
+    public CollectingEntitySearchResultHandler(int maxSize, List<Entity> results)
+    {
+        super(maxSize, results);
+    }
+
+    public CollectingEntitySearchResultHandler(int maxSize)
+    {
+        super(maxSize);
+    }
+
+    public CollectingEntitySearchResultHandler(List<Entity> results)
+    {
+        super(results);
+    }
+
+    private EntityFactory entityFactory;
+    
+    public void setEntityFactory(EntityFactory entityFactory)
+    {
+        this.entityFactory = entityFactory;
+    }
+
+    protected Entity mapResult(Object result, int pageSize, int pageIndex, int index)
+    {
+        return entityFactory.loadEntity(result);
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingEntitySearchResultHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingSearchResultHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingSearchResultHandler.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingSearchResultHandler.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/impl/CollectingSearchResultHandler.java Fri Apr  2 15:39:03 2010
@@ -24,7 +24,7 @@ import java.util.List;
  * @author <a href="mailto:ate@douma.nu>Ate Douma</a>
  * @version $Id$
  */
-public class CollectingSearchResultHandler<T,R> extends AbstractSearchResultHandler
+public class CollectingSearchResultHandler<T,R> extends BaseSearchResultHandler<T,R>
 {
     private T singleResult;
     private List<T> results;
@@ -64,24 +64,17 @@ public class CollectingSearchResultHandl
         }
         return results;
     }
-
-    @SuppressWarnings("unchecked")
-    protected void processSearchResult(Object result, int pageSize, int pageIndex, int index)
+    
+    protected boolean postHandleSearchResult(T mappedResult, int pageSize, int pageIndex, int index)
     {
-        T mappedResult = mapResult((R)result);
         if (getMaxCount() == 1)
         {
             singleResult = mappedResult;
         }
-        else if (getCount() <= getMaxCount())
+        else if (getMaxCount() == 0 || getCount() <= getMaxCount())
         {
             getResults().add(mappedResult);
         }
-    }
-    
-    @SuppressWarnings("unchecked")
-    protected T mapResult(R result)
-    {
-        return (T)result;
-    }
+        return true;
+    }    
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/EntityFactoryImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/EntityFactoryImpl.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/EntityFactoryImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/EntityFactoryImpl.java Fri Apr  2 15:39:03 2010
@@ -23,6 +23,7 @@ import java.util.Set;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchResult;
 
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.SecurityAttribute;
@@ -117,7 +118,7 @@ public class EntityFactoryImpl implement
     
     public Entity loadEntity(Object providerContext)
     {
-        DirContextOperations ctx = (DirContextOperations)providerContext;
+        DirContextOperations ctx = (DirContextOperations)((SearchResult)(providerContext)).getObject();
         String entityId = null;
         Entity entity = null;
         String dn = ctx.getNameInNamespace();

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java Fri Apr  2 15:39:03 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jetspeed.security.mapping.ldap.dao;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -25,6 +24,7 @@ import java.util.Set;
 
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.SecurityEntityManager;
 import org.apache.jetspeed.security.mapping.impl.SecurityEntityRelationTypeImpl;
 import org.apache.jetspeed.security.mapping.model.Entity;
@@ -124,10 +124,13 @@ public class DefaultLDAPEntityManager im
         }
     }
     
-    public Collection<Entity> getAllEntities(String entityType) throws SecurityException
+    public void getAllEntities(String entityType, EntitySearchResultHandler handler) throws SecurityException
     {
         EntityDAO dao = entityDAOs.get(entityType);
-        return dao != null ? dao.getAllEntities() : null;
+        if (dao != null)
+        {
+            dao.getAllEntities(handler);
+        }
     }
 
     public Entity getEntity(String entityType, String entityId) throws SecurityException
@@ -136,7 +139,7 @@ public class DefaultLDAPEntityManager im
         return dao != null ? dao.getEntity(entityId) : null;
     }
 
-    public Collection<Entity> getRelatedEntitiesTo(Entity toEntity, SecurityEntityRelationType relationType) throws SecurityException
+    public void getRelatedEntitiesTo(Entity toEntity, SecurityEntityRelationType relationType, EntitySearchResultHandler handler) throws SecurityException
     {
         EntityRelationDAO relationDAO = entityRelationDAOs.get(relationType instanceof SecurityEntityRelationTypeImpl ? relationType : new SecurityEntityRelationTypeImpl(relationType));
         if (relationDAO != null)
@@ -145,14 +148,14 @@ public class DefaultLDAPEntityManager im
             EntityDAO toDAO = entityDAOs.get(relationType.getToEntityType());
             if (fromDAO != null && toDAO != null && toDAO.getEntityType().equals(toEntity.getType()))
             {
-                return relationDAO.getRelatedEntitiesTo(fromDAO, toDAO, toEntity);
+                relationDAO.getRelatedEntitiesTo(fromDAO, toDAO, toEntity, handler);
+                return;
             }
         }
-        return null; // todo : throw exception, since combination of entity
-        // types and relation type is not configured.
+        // todo : throw exception, since combination of entity types and relation type is not configured.
     }
 
-    public Collection<Entity> getRelatedEntitiesFrom(Entity fromEntity, SecurityEntityRelationType relationType) throws SecurityException
+    public void getRelatedEntitiesFrom(Entity fromEntity, SecurityEntityRelationType relationType, EntitySearchResultHandler handler) throws SecurityException
     {
         EntityRelationDAO relationDAO = entityRelationDAOs.get(relationType instanceof SecurityEntityRelationTypeImpl ? relationType : new SecurityEntityRelationTypeImpl(relationType));
         if (relationDAO != null)
@@ -161,11 +164,11 @@ public class DefaultLDAPEntityManager im
             EntityDAO toDAO = entityDAOs.get(relationType.getToEntityType());
             if (fromDAO != null && toDAO != null && fromDAO.getEntityType().equals(fromEntity.getType()))
             {
-                return relationDAO.getRelatedEntitiesFrom(fromDAO, toDAO, fromEntity);
+                relationDAO.getRelatedEntitiesFrom(fromDAO, toDAO, fromEntity, handler);
+                return;
             }
         }
-        return null; // todo : throw exception, since combination of entity
-        // types and relation type is not configured.
+        // todo : throw exception, since combination of entity types and relation type is not configured.
     }
 
     public void updateEntity(Entity entity) throws SecurityException

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityDAO.java Fri Apr  2 15:39:03 2010
@@ -20,6 +20,7 @@ import java.util.Collection;
 
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.springframework.ldap.filter.Filter;
 
@@ -37,47 +38,43 @@ public interface EntityDAO
     /**
      * Fetch entities by providing a list of specific entity IDs.
      * 
-     * @param entity
-     *            IDs
-     * @return found entities
+     * @param entityIds entity IDs
+     * @param handler the Entity callback handler called for each entity retrieved
      */
-    Collection<Entity> getEntitiesById(Collection<String> entityIds) throws SecurityException;
+    void getEntitiesById(Collection<String> entityIds, EntitySearchResultHandler handler) throws SecurityException;
 
     /**
      * Fetch entity by providing an *internal* entity ID.
      * 
-     * @param internalId
+     * @param internalId internal entity ID
      * @return found entity
      */
     Entity getEntityByInternalId(String internalId) throws SecurityException;
 
     /**
-     * Fetch entities by providing a list of specific *internal* entity IDs.
+     * Fetch entities by providing a list of *internal* entity IDs.
      * 
-     * @param internal
-     *            entity IDs
-     * @return found entities
+     * @param entityIds internal entity IDs
+     * @param handler the Entity callback handler called for each entity retrieved
      */
-    Collection<Entity> getEntitiesByInternalId(Collection<String> entityIds) throws SecurityException;
+    void getEntitiesByInternalId(Collection<String> entityIds, EntitySearchResultHandler handler) throws SecurityException;
 
     /**
-     * Method for applying a specific filter on the complete entity set returned by the DAO. The result would be the same as applying the specific filter to the
-     * result of getAllEntities().
+     * Method for applying a specific filter on the complete entity set retrievable by the DAO.
      * 
-     * @param filter
-     *            a specific filter to narrow the returned entity set
-     * @return found entities
+     * @param filter a specific filter to narrow the returned entity set
+     * @param handler the Entity callback handler called for each entity retrieved
      */
-    Collection<Entity> getEntities(Filter filter) throws SecurityException;
+    void getEntities(Filter filter, EntitySearchResultHandler handler) throws SecurityException;
 
     /**
      * Same as getEntities(Filter filter), except that this method only returns entities which are children of the given parent entity.
      * 
      * @param parentEntity
      * @param filter
-     * @return
+     * @param handler the Entity callback handler called for each entity retrieved
      */
-    Collection<Entity> getEntities(Entity parentEntity, Filter filter) throws SecurityException;
+    void getEntities(Entity parentEntity, Filter filter, EntitySearchResultHandler handler) throws SecurityException;
 
     /**
      * Fetch a single entity by ID.
@@ -99,19 +96,13 @@ public interface EntityDAO
     /**
      * Returns the parent entity of the given entity, if there is any.
      * 
-     * @param filter
-     *            a specific filter to narrow the returned entity set
-     * @return found entities
+     * @param filter a specific filter to narrow the returned entity set
+     * @return parent entity
      */
     Entity getParentEntity(Entity childEntity) throws SecurityException;
 
-    /**
-     * Fetch all entities
-     * 
-     * @return found entities
-     */
-    Collection<Entity> getAllEntities() throws SecurityException;
-
+    void getAllEntities(EntitySearchResultHandler cbh) throws SecurityException;
+    
     void update(Entity entity) throws SecurityException;
 
     void add(Entity entity) throws SecurityException;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityRelationDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityRelationDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityRelationDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/EntityRelationDAO.java Fri Apr  2 15:39:03 2010
@@ -16,9 +16,8 @@
  */
 package org.apache.jetspeed.security.mapping.ldap.dao;
 
-import java.util.Collection;
-
 import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.apache.jetspeed.security.mapping.model.SecurityEntityRelationType;
 
@@ -30,9 +29,9 @@ public interface EntityRelationDAO
 {
     SecurityEntityRelationType getRelationType();
 
-    Collection<Entity> getRelatedEntitiesFrom(EntityDAO fromDao, EntityDAO toDao, Entity fromEntity) throws SecurityException;
+    void getRelatedEntitiesFrom(EntityDAO fromDao, EntityDAO toDao, Entity fromEntity, EntitySearchResultHandler handler) throws SecurityException;
 
-    Collection<Entity> getRelatedEntitiesTo(EntityDAO fromDao, EntityDAO toDao, Entity toEntity) throws SecurityException;
+    void getRelatedEntitiesTo(EntityDAO fromDao, EntityDAO toDao, Entity toEntity, EntitySearchResultHandler handler) throws SecurityException;
 
     void addRelation(EntityDAO sourceDao, EntityDAO targetDao, String sourceEntityId, String targetEntityId) throws SecurityException;
 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/LDAPEntityDAOConfiguration.java Fri Apr  2 15:39:03 2010
@@ -31,6 +31,8 @@ import org.springframework.ldap.filter.F
  */
 public class LDAPEntityDAOConfiguration
 {
+    private static final int          DEFAULT_SEARCH_PAGE_SIZE = 256;
+    
     private DistinguishedName         baseDN = new DistinguishedName().immutableDistinguishedName();
     private DistinguishedName         searchDN = new DistinguishedName().immutableDistinguishedName();
     private Filter                    baseFilter;
@@ -40,6 +42,7 @@ public class LDAPEntityDAOConfiguration
     private String                    entityType;
     private String[]                  objectClassesArr;
     private String[]                  entityAttributeNames;
+    private int                       searchPageSize = DEFAULT_SEARCH_PAGE_SIZE;
 
     public void initialize() throws JetspeedException
     {
@@ -81,6 +84,16 @@ public class LDAPEntityDAOConfiguration
             throw new JetspeedException(getClass().getName() + ": property '" + fieldName + "' cannot be null or empty.");
         }
     }
+    
+    public int getSearchPageSize()
+    {
+        return searchPageSize;
+    }
+
+    public void setSearchPageSize(int searchPageSize)
+    {
+        this.searchPageSize = searchPageSize;
+    }
 
     public DistinguishedName getBaseDN()
     {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java Fri Apr  2 15:39:03 2010
@@ -20,6 +20,7 @@ import java.util.Collection;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
 import org.apache.jetspeed.security.mapping.model.Attribute;
 import org.apache.jetspeed.security.mapping.model.AttributeDef;
@@ -45,17 +46,18 @@ public class AttributeBasedRelationDAO e
 
     // not used, then the attribute
     // contains the ID(s).
-    public Collection<Entity> getRelatedEntitiesFrom(EntityDAO fromDAO, EntityDAO toDAO, Entity fromEntity) throws SecurityException
+    public void getRelatedEntitiesFrom(EntityDAO fromDAO, EntityDAO toDAO, Entity fromEntity, EntitySearchResultHandler handler) throws SecurityException
     {
-        return internalGetRelatedEntities(fromDAO, toDAO, useFromEntityAttribute, fromEntity);
+        internalGetRelatedEntities(fromDAO, toDAO, useFromEntityAttribute, fromEntity, handler);
     }
 
-    public Collection<Entity> getRelatedEntitiesTo(EntityDAO fromDAO, EntityDAO toDAO, Entity toEntity) throws SecurityException
+    public void getRelatedEntitiesTo(EntityDAO fromDAO, EntityDAO toDAO, Entity toEntity, EntitySearchResultHandler handler) throws SecurityException
     {
-        return internalGetRelatedEntities(toDAO, fromDAO, !useFromEntityAttribute, toEntity);
+        internalGetRelatedEntities(toDAO, fromDAO, !useFromEntityAttribute, toEntity, handler);
     }
 
-    private Collection<Entity> internalGetRelatedEntities(EntityDAO fromDAO, EntityDAO toDAO, boolean useFromEntityAttribute, Entity entity) throws SecurityException
+    private void internalGetRelatedEntities(EntityDAO fromDAO, EntityDAO toDAO, boolean useFromEntityAttribute, Entity entity, 
+                                           EntitySearchResultHandler handler) throws SecurityException
     {
         if (useFromEntityAttribute)
         {
@@ -71,11 +73,11 @@ public class AttributeBasedRelationDAO e
                 }
                 if (attributeContainsInternalId)
                 {
-                    return toDAO.getEntitiesByInternalId(values);
+                    toDAO.getEntitiesByInternalId(values, handler);
                 }
                 else
                 {
-                    return toDAO.getEntitiesById(values);
+                    toDAO.getEntitiesById(values, handler);
                 }
             }
         }
@@ -90,10 +92,9 @@ public class AttributeBasedRelationDAO e
                 // fetch entities using target Entity DAO with a specific filter
                 // on the member attribute
                 Filter memberAttrFilter = new EqualsFilter(relationAttribute, fromEntityUsedIdValue);
-                return toDAO.getEntities(memberAttrFilter);
+                toDAO.getEntities(memberAttrFilter, handler);
             }
         }
-        return null;
     }
 
     private String getInternalId(Entity entity, EntityDAO entityDao) throws SecurityException

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/PagedSearchExecutor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/PagedSearchExecutor.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/PagedSearchExecutor.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/PagedSearchExecutor.java Fri Apr  2 15:39:03 2010
@@ -93,6 +93,11 @@ public class PagedSearchExecutor impleme
             PagedResultsCookie cookie = null;
             int index = 0;
             boolean doNext = true;
+            if (handler.getMaxCount() > 0 && controls.getCountLimit() <= 0 || handler.getMaxCount()+1 < controls.getCountLimit())
+            {
+                controls.setCountLimit(handler.getMaxCount()+1);
+            }
+            int pageSize = handler.getSearchPageSize() < 0 ? this.pageSize : handler.getSearchPageSize();
             if (pageSize > 0)
             {
                 do

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java Fri Apr  2 15:39:03 2010
@@ -19,7 +19,6 @@ package org.apache.jetspeed.security.map
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
 
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
@@ -30,8 +29,11 @@ import javax.naming.directory.SearchCont
 import javax.naming.directory.SearchResult;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.Validate;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
+import org.apache.jetspeed.security.mapping.impl.CollectingEntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.impl.CollectingSearchResultHandler;
 import org.apache.jetspeed.security.mapping.ldap.EntityFactoryImpl;
 import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
@@ -54,6 +56,7 @@ import org.springframework.ldap.filter.O
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @author <a href="mailto:ate@douma.nu>Ate Douma</a>
  * @version $Id$
  */
 public class SpringLDAPEntityDAO implements EntityDAO
@@ -62,12 +65,14 @@ public class SpringLDAPEntityDAO impleme
     private final EntityFactory              entityFactory;
     private LdapTemplate                     ldapTemplate;
     private String                           defaultSearchFilterStr;
+    private int                              searchPageSize;
 
     public SpringLDAPEntityDAO(LDAPEntityDAOConfiguration configuration)
     {
         this.configuration = configuration;
         this.entityFactory = new EntityFactoryImpl(configuration);
         this.defaultSearchFilterStr = createSearchFilter(null);
+        this.searchPageSize = configuration.getSearchPageSize();
     }
 
     public LDAPEntityDAOConfiguration getConfiguration()
@@ -90,25 +95,25 @@ public class SpringLDAPEntityDAO impleme
         this.ldapTemplate = ldapTemplate;
     }
 
-    public Collection<Entity> getEntities(Filter filter) throws SecurityException
+    public void getAllEntities(EntitySearchResultHandler handler) throws SecurityException
     {
+        getEntities(null, handler);
+    }
+
+    public void getEntities(Filter filter, EntitySearchResultHandler handler) throws SecurityException
+    {
+        Validate.notNull(handler, "EntitySearchResultHandler parameter must not be null");
         String sf = createSearchFilter(filter);
         SearchControls sc = getSearchControls(SearchControls.SUBTREE_SCOPE, true, configuration.getEntityAttributeNames());
-        CollectingSearchResultHandler<Entity,SearchResult> cbh = new CollectingSearchResultHandler<Entity,SearchResult>()
-        {
-            protected Entity mapResult(SearchResult result)
-            {
-                return getEntityFactory().loadEntity(result.getObject());
-            }
-        };
-        PagedSearchExecutor pse = new PagedSearchExecutor(configuration.getSearchDN(), sf, sc, cbh);
+        
+        handler.setEntityFactory(getEntityFactory());
+        PagedSearchExecutor pse = new PagedSearchExecutor(configuration.getSearchDN(), sf, sc, handler, searchPageSize);
         
         ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
             Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-            ldapTemplate.search(pse,pse); 
-            return cbh.getResults();
+            ldapTemplate.search(pse,pse);            
         }
         catch (NamingException e)
         {
@@ -117,26 +122,20 @@ public class SpringLDAPEntityDAO impleme
         finally
         {
             Thread.currentThread().setContextClassLoader(currentClassLoader);
+            handler.setEntityFactory(null);
         }
     }
 
-    public Collection<Entity> getEntities(Entity parent, Filter filter) throws SecurityException
+    public void getEntities(Entity parent, Filter filter, EntitySearchResultHandler handler) throws SecurityException
     {
-        List<Entity> results = new ArrayList<Entity>();
         ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
         DistinguishedName parentDN = getRelativeDN(parent.getInternalId());
         if (configuration.getSearchDN().size() == 0 || parentDN.endsWith(configuration.getSearchDN()))
         {
             String sf = createSearchFilter(filter);
             SearchControls sc = getSearchControls(SearchControls.ONELEVEL_SCOPE, true, configuration.getEntityAttributeNames());
-            CollectingSearchResultHandler<Entity,SearchResult> cbh = new CollectingSearchResultHandler<Entity,SearchResult>(results)
-            {
-                protected Entity mapResult(SearchResult result)
-                {
-                    return getEntityFactory().loadEntity(result.getObject());
-                }
-            };
-            PagedSearchExecutor pse = new PagedSearchExecutor(parentDN, sf, sc, cbh);
+            handler.setEntityFactory(getEntityFactory());
+            PagedSearchExecutor pse = new PagedSearchExecutor(parentDN, sf, sc, handler, searchPageSize);
             
             try
             {
@@ -151,27 +150,19 @@ public class SpringLDAPEntityDAO impleme
             finally
             {
                 Thread.currentThread().setContextClassLoader(currentClassLoader);
+                handler.setEntityFactory(null);
             }
         }
-        return results;
-    }
-
-    public Collection<Entity> getAllEntities() throws SecurityException
-    {
-        return getEntities(null);
     }
 
     public Entity getEntity(String entityId) throws SecurityException
     {
-        Collection<Entity> entities = getEntities(new EqualsFilter(configuration.getLdapIdAttribute(), entityId));
-        if (entities != null && entities.size() == 1)
-        {
-            return entities.iterator().next();
-        }
-        return null;
+        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler(1);
+        getEntities(new EqualsFilter(configuration.getLdapIdAttribute(), entityId), handler);
+        return handler.getCount() == 1 ? handler.getSingleResult() : null;
     }
 
-    public Collection<Entity> getEntitiesById(Collection<String> entityIds) throws SecurityException
+    public void getEntitiesById(Collection<String> entityIds, EntitySearchResultHandler handler) throws SecurityException
     {
         OrFilter filter = new OrFilter();
         String idAttr = configuration.getLdapIdAttribute();
@@ -179,23 +170,24 @@ public class SpringLDAPEntityDAO impleme
         {
             filter.or(new EqualsFilter(idAttr, id));
         }
-        return getEntities(filter);
+        getEntities(filter, handler);
     }
 
     public Entity getEntityByInternalId(String internalId) throws SecurityException
     {
+        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler(1);
+        getEntityByInternalId(internalId, handler);
+        return handler.getSingleResult(); 
+    }
+
+    protected void getEntityByInternalId(String internalId, EntitySearchResultHandler handler) throws SecurityException
+    {
         DistinguishedName principalDN = getRelativeDN(internalId);
         if (configuration.getSearchDN().size() == 0 || principalDN.endsWith(configuration.getSearchDN()))
         {
             SearchControls sc = getSearchControls(SearchControls.OBJECT_SCOPE, true, configuration.getEntityAttributeNames());
-            CollectingSearchResultHandler<Entity,SearchResult> cbh = new CollectingSearchResultHandler<Entity,SearchResult>(1)
-            {
-                protected Entity mapResult(SearchResult result)
-                {
-                    return getEntityFactory().loadEntity(result.getObject());
-                }
-            };
-            PagedSearchExecutor pse = new PagedSearchExecutor(principalDN, defaultSearchFilterStr, sc, cbh);
+            PagedSearchExecutor pse = new PagedSearchExecutor(principalDN, defaultSearchFilterStr, sc, handler);
+            handler.setEntityFactory(getEntityFactory());
             
             ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
             try
@@ -203,10 +195,6 @@ public class SpringLDAPEntityDAO impleme
                 Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                 
                 ldapTemplate.search(pse,pse);
-                if (cbh.getCount() == 1)
-                {
-                    return cbh.getSingleResult();
-                }
             }
             catch (NamingException e)
             {
@@ -215,23 +203,38 @@ public class SpringLDAPEntityDAO impleme
             finally
             {
                 Thread.currentThread().setContextClassLoader(currentClassLoader);
+                handler.setEntityFactory(null);
             }
         }
-        return null;
     }
     
-    public Collection<Entity> getEntitiesByInternalId(Collection<String> internalIds) throws SecurityException
+    public void getEntitiesByInternalId(Collection<String> internalIds, final EntitySearchResultHandler handler) throws SecurityException
     {
-        final Collection<Entity> resultSet = new ArrayList<Entity>();
-        for (Iterator<String> iterator = internalIds.iterator(); iterator.hasNext();)
+        EntitySearchResultHandler delegatingHandler = new EntitySearchResultHandler()
+        {
+            public int getMaxCount() { return handler.getMaxCount(); }
+            public int getSearchPageSize() { return handler.getSearchPageSize(); }
+            public void setFeedback(Object feedback) {}
+            public Object getFeedback() {return null; }
+            public void setEntityFactory(EntityFactory factory) {}
+            public boolean handleSearchResult(Object result, int pageSize, int pageIndex, int index)
+            {
+                return handler.handleSearchResult(result, pageSize, pageIndex, index);
+            }
+        };
+        try
         {
-            Entity resultEntity = getEntityByInternalId(iterator.next());
-            if (resultEntity != null)
+            handler.setEntityFactory(getEntityFactory());
+            
+            for (Iterator<String> iterator = internalIds.iterator(); iterator.hasNext();)
             {
-                resultSet.add(resultEntity);
+                getEntityByInternalId(iterator.next(), delegatingHandler);
             }
         }
-        return resultSet;
+        finally
+        {
+            handler.setEntityFactory(null);
+        }
     }
 
     public Entity getParentEntity(Entity childEntity) throws SecurityException
@@ -257,7 +260,7 @@ public class SpringLDAPEntityDAO impleme
         CollectingSearchResultHandler<String,SearchResult> cbh = 
             new CollectingSearchResultHandler<String,SearchResult>(1)
         {
-            protected String mapResult(SearchResult result)
+            protected String mapResult(SearchResult result, int pageSize, int pageIndex, int index)
             {
                 return result.getNameInNamespace();
             }
@@ -311,7 +314,7 @@ public class SpringLDAPEntityDAO impleme
         CollectingSearchResultHandler<DirContextOperations,SearchResult> cbh = 
             new CollectingSearchResultHandler<DirContextOperations,SearchResult>(1)
         {
-            protected DirContextOperations mapResult(SearchResult result)
+            protected DirContextOperations mapResult(SearchResult result, int pageSize, int pageIndex, int index)
             {
                 return (DirContextOperations)result.getObject();
             }
@@ -351,7 +354,7 @@ public class SpringLDAPEntityDAO impleme
             CollectingSearchResultHandler<DirContextOperations,SearchResult> cbh = 
                 new CollectingSearchResultHandler<DirContextOperations,SearchResult>(1)
             {
-                protected DirContextOperations mapResult(SearchResult result)
+                protected DirContextOperations mapResult(SearchResult result, int pageSize, int pageIndex, int index)
                 {
                     return (DirContextOperations)result.getObject();
                 }
@@ -364,10 +367,7 @@ public class SpringLDAPEntityDAO impleme
                 Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                 
                 ldapTemplate.search(pse,pse);
-                if (cbh.getCount() == 1)
-                {
-                    return cbh.getSingleResult();
-                }
+                return cbh.getSingleResult();
             }
             catch (NamingException e)
             {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java Fri Apr  2 15:39:03 2010
@@ -38,6 +38,7 @@ import org.apache.jetspeed.security.Secu
 import org.apache.jetspeed.security.SecurityAttributeType;
 import org.apache.jetspeed.security.SecurityAttributes;
 import org.apache.jetspeed.security.mapping.SecurityEntityManager;
+import org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.model.Attribute;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.apache.jetspeed.security.mapping.model.SecurityEntityRelationType;
@@ -45,6 +46,7 @@ import org.apache.jetspeed.security.spi.
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @author <a href="mailto:ate@douma.nu>Ate Douma</a>
  * @version $Id$
  */
 public class DefaultJetspeedSecuritySynchronizer implements JetspeedSecuritySynchronizer
@@ -74,15 +76,33 @@ public class DefaultJetspeedSecuritySync
         {
             // don't skip any entity type when synchronizing all
             Collection<String> skipEntities = new ArrayList<String>();
-            InternalSynchronizationState synchronizationState = new InternalSynchronizationState(skipEntities);
+            final InternalSynchronizationState synchronizationState = new InternalSynchronizationState(skipEntities);
             for (String type : securityEntityManager.getSupportedEntityTypes())
             {
-                for (Entity entity : securityEntityManager.getAllEntities(type))
+                BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
                 {
-                	// recursive is false, because that will synchronize all associated entities which are
-                	// direct associations of the principal. Because all principal types are being processed, this ensures 
-                	// all associations are being processed.
-                    recursiveSynchronizeEntity(entity, synchronizationState, false);
+                    @Override
+                    protected boolean processSearchResult(Entity result, int pageSize, int pageIndex, int index)
+                    {
+                        // recursive is false, because that will synchronize all associated entities which are
+                        // direct associations of the principal. Because all principal types are being processed, this ensures 
+                        // all associations are being processed.
+                        try
+                        {
+                            recursiveSynchronizeEntity(result, synchronizationState, false);
+                        }
+                        catch (SecurityException e)
+                        {
+                            setFeedback(e);
+                            return false;
+                        }
+                        return true;
+                    }
+                };
+                securityEntityManager.getAllEntities(type,handler);
+                if (handler.getFeedback() != null)
+                {
+                    throw (SecurityException)handler.getFeedback();
                 }
             }
         }
@@ -92,22 +112,39 @@ public class DefaultJetspeedSecuritySync
         }
     }
 
-    public synchronized void synchronizePrincipalsByType(String type, boolean recursive) throws SecurityException
+    public synchronized void synchronizePrincipalsByType(String type, final boolean recursive) throws SecurityException
     {
         setSynchronizing(true);
         try
         {
-            Collection<Entity> entites = securityEntityManager.getAllEntities(type);
             Collection<String> skipEntities = new ArrayList<String>();
             if (!type.equals(JetspeedPrincipalType.USER))
             {
                 // skip synchronizing users when not synchronizing the USER type itself
                 skipEntities.add(JetspeedPrincipalType.USER);
             }
-            InternalSynchronizationState synchronizationState = new InternalSynchronizationState(skipEntities);
-            for (Entity entity : entites)
+            final InternalSynchronizationState synchronizationState = new InternalSynchronizationState(skipEntities);
+            BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
+            {
+                @Override
+                protected boolean processSearchResult(Entity entity, int pageSize, int pageIndex, int index)
+                {
+                    try
+                    {
+                        recursiveSynchronizeEntity(entity, synchronizationState, recursive);
+                    }
+                    catch (SecurityException e)
+                    {
+                        setFeedback(e);
+                        return false;
+                    }
+                    return true;
+                }
+            };
+            securityEntityManager.getAllEntities(type, handler);
+            if (handler.getFeedback() != null)
             {
-                recursiveSynchronizeEntity(entity, synchronizationState, recursive);
+                throw (SecurityException)handler.getFeedback();
             }
         }
         finally
@@ -195,48 +232,69 @@ public class DefaultJetspeedSecuritySync
      * @param recursive whether related entities should be recursively synchronized (true) or not (false).
      * @return
      */
-    protected Collection<Long> synchronizeAddedEntityRelations(SecurityEntityRelationType relationTypeForThisEntity, Entity entity, JetspeedPrincipal principal,
-                                                              boolean entityIsFromEntity, InternalSynchronizationState syncState, boolean recursive)
-                                                              throws SecurityException
-    {
-        Collection<Entity> relatedEntities = entityIsFromEntity ? securityEntityManager.getRelatedEntitiesFrom(entity, relationTypeForThisEntity)
-                                                               : securityEntityManager.getRelatedEntitiesTo(entity, relationTypeForThisEntity);
-        Collection<Long> externalRelatedEntityIds = new ArrayList<Long>();
-        if (relatedEntities != null){
-            for (Entity relatedEntity : relatedEntities)
-            {
-                Entity fromEntity = entityIsFromEntity ? entity : relatedEntity;
-                Entity toEntity = entityIsFromEntity ? relatedEntity : entity;
-                if (!syncState.isRelationProcessed(relationTypeForThisEntity, fromEntity, toEntity))
-                {
-                    // first flag the relation as processed to
-                    // prevent synchronizing the same relation from
-                    // the other side.
-                    syncState.setRelationProcessed(relationTypeForThisEntity, fromEntity, toEntity, entityIsFromEntity);
-                    // first create/update principal
-                    JetspeedPrincipal relatedPrincipal = null;
-                    if (recursive){
-                        relatedPrincipal = recursiveSynchronizeEntity(relatedEntity, syncState,recursive);
-                    } else {
-                        // don't recursively synchronize the related entity. Only add an association (if missing) when the related entity was previously synchronized.
-                        JetspeedPrincipalManager principalManager = principalManagerProvider.getManager(principalManagerProvider.getPrincipalType(relatedEntity.getType()));
-                        if (principalManager != null)
+    protected Collection<Long> synchronizeAddedEntityRelations(final SecurityEntityRelationType relationTypeForThisEntity, final Entity entity, final JetspeedPrincipal principal,
+                                                               final boolean entityIsFromEntity, final InternalSynchronizationState syncState, final boolean recursive)
+                                                               throws SecurityException
+    {
+        final Collection<Long> externalRelatedEntityIds = new ArrayList<Long>();
+        
+        BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
+        {
+            @Override
+            protected boolean processSearchResult(Entity relatedEntity, int pageSize, int pageIndex, int index)
+            {
+                try
+                {
+                    Entity fromEntity = entityIsFromEntity ? entity : relatedEntity;
+                    Entity toEntity = entityIsFromEntity ? relatedEntity : entity;
+                    if (!syncState.isRelationProcessed(relationTypeForThisEntity, fromEntity, toEntity))
+                    {
+                        // first flag the relation as processed to
+                        // prevent synchronizing the same relation from
+                        // the other side.
+                        syncState.setRelationProcessed(relationTypeForThisEntity, fromEntity, toEntity, entityIsFromEntity);
+                        // first create/update principal
+                        JetspeedPrincipal relatedPrincipal = null;
+                        if (recursive){
+                            relatedPrincipal = recursiveSynchronizeEntity(relatedEntity, syncState,recursive);
+                        } else {
+                            // don't recursively synchronize the related entity. Only add an association (if missing) when the related entity was previously synchronized.
+                            JetspeedPrincipalManager principalManager = principalManagerProvider.getManager(principalManagerProvider.getPrincipalType(relatedEntity.getType()));
+                            if (principalManager != null)
+                            {
+                                relatedPrincipal = principalManager.getPrincipal(relatedEntity.getId());
+                            }
+                        }
+                        // .. then update associations to / from it
+                        JetspeedPrincipal fromPrincipal = entityIsFromEntity ? principal : relatedPrincipal;
+                        JetspeedPrincipal toPrincipal = entityIsFromEntity ? relatedPrincipal : principal;
+                        // does association exist in DB ?
+                        if (relatedPrincipal != null && !associationExists(fromPrincipal, toPrincipal, relationTypeForThisEntity.getRelationType()))
                         {
-                            relatedPrincipal = principalManager.getPrincipal(relatedEntity.getId());
+                            synchronizeAddedPrincipalAssocation(fromPrincipal, toPrincipal, relationTypeForThisEntity.getRelationType());
+                            externalRelatedEntityIds.add(relatedPrincipal.getId());
                         }
                     }
-                    // .. then update associations to / from it
-                    JetspeedPrincipal fromPrincipal = entityIsFromEntity ? principal : relatedPrincipal;
-                    JetspeedPrincipal toPrincipal = entityIsFromEntity ? relatedPrincipal : principal;
-                    // does association exist in DB ?
-                    if (relatedPrincipal != null && !associationExists(fromPrincipal, toPrincipal, relationTypeForThisEntity.getRelationType()))
-                    {
-                        synchronizeAddedPrincipalAssocation(fromPrincipal, toPrincipal, relationTypeForThisEntity.getRelationType());
-                        externalRelatedEntityIds.add(relatedPrincipal.getId());
-                    }
-                    
                 }
+                catch (SecurityException e)
+                {
+                    setFeedback(e);
+                    return false;
+                }
+                return true;
             }
+        };
+        if (entityIsFromEntity)
+        {
+            securityEntityManager.getRelatedEntitiesFrom(entity, relationTypeForThisEntity, handler);
+        }
+        else
+        {
+            securityEntityManager.getRelatedEntitiesTo(entity, relationTypeForThisEntity, handler);
+        }
+        if (handler.getFeedback() != null)
+        {
+            throw (SecurityException)handler.getFeedback();
         }
         return externalRelatedEntityIds;
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/BasicTestCases.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/BasicTestCases.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/BasicTestCases.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/BasicTestCases.java Fri Apr  2 15:39:03 2010
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import junit.framework.TestCase;
 import org.apache.jetspeed.security.mapping.SecurityEntityManager;
+import org.apache.jetspeed.security.mapping.impl.CollectingEntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.impl.SecurityEntityRelationTypeImpl;
 import org.apache.jetspeed.security.mapping.model.Attribute;
 import org.apache.jetspeed.security.mapping.model.AttributeDef;
@@ -58,9 +59,10 @@ public class BasicTestCases
 
     public void testFetchAllEntities(int totalNrOfUsers) throws Exception
     {
-        Collection<Entity> entities = entityManager.getAllEntities("user");
-        TestCase.assertNotNull(entities);
-        TestCase.assertEquals(totalNrOfUsers, entities.size());
+        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler();
+        entityManager.getAllEntities("user", handler);
+        TestCase.assertNotNull(handler.getResults());
+        TestCase.assertEquals(totalNrOfUsers, handler.getSize());
     }
 
     public void testFetchRelatedEntitiesTo(String fromEntityType,
@@ -69,10 +71,9 @@ public class BasicTestCases
     {
         Entity randomEntity = entityManager.getEntity(toEntityType,toEntityId);
         TestCase.assertNotNull(randomEntity);
-        Collection<Entity> resultEntities = entityManager.getRelatedEntitiesTo(
-                randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType));
-
-        basicEntityResultSetChecks(expectedEntities, resultEntities);
+        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler();
+        entityManager.getRelatedEntitiesTo(randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType), handler);
+        basicEntityResultSetChecks(expectedEntities, handler.getResults());
     }
     
     public void testFetchRelatedEntitiesFrom(String fromEntityType,
@@ -81,10 +82,9 @@ public class BasicTestCases
     {
         Entity randomEntity = entityManager.getEntity(fromEntityType,fromEntityId);
         TestCase.assertNotNull(randomEntity);
-        Collection<Entity> resultEntities = entityManager.getRelatedEntitiesFrom(
-                randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType));
-
-        basicEntityResultSetChecks(expectedEntities, resultEntities);
+        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler();
+        entityManager.getRelatedEntitiesFrom(randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType), handler);
+        basicEntityResultSetChecks(expectedEntities, handler.getResults());
     }
 
     @SuppressWarnings("unchecked")

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityDAO.java Fri Apr  2 15:39:03 2010
@@ -20,8 +20,10 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.springframework.ldap.filter.Filter;
@@ -31,18 +33,35 @@ import org.springframework.ldap.filter.F
  */
 public class StubEntityDAO implements EntityDAO
 {
-
+    private static EntityFactory copyingEntityFactory = new EntityFactory()
+    {
+        public Entity createEntity(JetspeedPrincipal principal) {return null; }
+        public String getEntityType() { return null; }
+        public Entity loadEntity(Object entity) { return (Entity)entity; }
+    };
+    
     private Map<String,Entity> entities = new HashMap<String,Entity>();
     
+    private void copyEntities(EntitySearchResultHandler handler)
+    {
+        handler.setEntityFactory(copyingEntityFactory);
+        int index = 0;
+        for (Entity e : entities.values() )
+        {
+            handler.handleSearchResult(e, 0, index, index);
+            index++;
+        }
+        handler.setEntityFactory(null);
+    }
+    
     public String getEntityType()
     {
         return null;
     }
     
-    public Collection<Entity> getEntities(Entity parentEntity, Filter filter)
+    public void getEntities(Entity parentEntity, Filter filter, EntitySearchResultHandler handler)
     {
         // TODO Auto-generated method stub
-        return null;
     }
 
     public Entity getEntityByInternalId(String internalId)
@@ -62,26 +81,24 @@ public class StubEntityDAO implements En
         entities.put(entity.getId(),entity);
     }
 
-    public Collection<Entity> getAllEntities()
+    public void getAllEntities(EntitySearchResultHandler handler)
     {
-        return entities.values();
+        copyEntities(handler);
     }
 
-    public Collection<Entity> getEntities(Filter filter)
+    public void getEntities(Filter filter, EntitySearchResultHandler handler)
     {
-        return entities.values();
+        copyEntities(handler);
     }
 
-    public Collection<Entity> getEntitiesById(Collection<String> entityIds)
+    public void getEntitiesById(Collection<String> entityIds, EntitySearchResultHandler handler)
     {
         // TODO Auto-generated method stub
-        return null;
     }
 
-    public Collection<Entity> getEntitiesByInternalId(Collection<String> entityIds)
+    public void getEntitiesByInternalId(Collection<String> entityIds, EntitySearchResultHandler handler)
     {
         // TODO Auto-generated method stub
-        return null;
     }
 
     public Entity getEntity(String entityId)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java?rev=930298&r1=930297&r2=930298&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/stubs/StubEntityRelationDAO.java Fri Apr  2 15:39:03 2010
@@ -21,7 +21,10 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.EntitySearchResultHandler;
 import org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO;
 import org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO;
 import org.apache.jetspeed.security.mapping.model.Entity;
@@ -33,7 +36,13 @@ import org.apache.jetspeed.security.mapp
  */
 public class StubEntityRelationDAO implements EntityRelationDAO
 {
-
+    private static EntityFactory copyingEntityFactory = new EntityFactory()
+    {
+        public Entity createEntity(JetspeedPrincipal principal) {return null; }
+        public String getEntityType() { return null; }
+        public Entity loadEntity(Object entity) { return (Entity)entity; }
+    };
+    
     private Map<Entity,Collection<Entity>> fromTo = new HashMap<Entity,Collection<Entity>>();
     private Map<Entity,Collection<Entity>> toFrom = new HashMap<Entity,Collection<Entity>>();
     private SecurityEntityRelationType relationType;
@@ -45,20 +54,28 @@ public class StubEntityRelationDAO imple
         this.relationType = relationType;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO#getRelatedEntitiesFrom(org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.model.Entity)
-     */
-    public Collection<Entity> getRelatedEntitiesFrom(EntityDAO fromDao, EntityDAO toDao, Entity fromEntity)
+    public void getRelatedEntitiesFrom(EntityDAO fromDao, EntityDAO toDao, Entity fromEntity, EntitySearchResultHandler handler)
     {
-        return fromTo.get(fromEntity);
+        handler.setEntityFactory(copyingEntityFactory);
+        int index = 0;
+        for (Entity e : fromTo.get(fromEntity) )
+        {
+            handler.handleSearchResult(e, 0, index, index);
+            index++;
+        }
+        handler.setEntityFactory(null);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.mapping.ldap.dao.EntityRelationDAO#getRelatedEntitiesTo(org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.ldap.dao.EntityDAO, org.apache.jetspeed.security.mapping.model.Entity)
-     */
-    public Collection<Entity> getRelatedEntitiesTo(EntityDAO fromDao, EntityDAO toDao, Entity toEntity)
+    public void getRelatedEntitiesTo(EntityDAO fromDao, EntityDAO toDao, Entity toEntity, EntitySearchResultHandler handler)
     {
-        return toFrom.get(toEntity);
+        handler.setEntityFactory(copyingEntityFactory);
+        int index = 0;
+        for (Entity e : toFrom.get(toEntity) )
+        {
+            handler.handleSearchResult(e, 0, index, index);
+            index++;
+        }
+        handler.setEntityFactory(null);
     }
     
     public SecurityEntityRelationType getRelationType()



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org