syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: Internal clean-up
Date Mon, 23 Nov 2015 12:22:38 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 175c5b22a -> 07451e4cc


Internal clean-up


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/c3e4c38d
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/c3e4c38d
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/c3e4c38d

Branch: refs/heads/master
Commit: c3e4c38dc0eede729ca7504e32e0291833f394ff
Parents: 175c5b2
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Mon Nov 23 12:18:26 2015 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Mon Nov 23 12:18:26 2015 +0100

----------------------------------------------------------------------
 .../core/logic/report/GroupReportlet.java       | 42 +++++------
 .../core/logic/report/UserReportlet.java        | 43 +++++------
 .../core/persistence/api/dao/AnyDAO.java        | 17 ++++-
 .../core/persistence/api/dao/AnySearchDAO.java  |  8 +-
 .../persistence/jpa/dao/AbstractAnyDAO.java     |  7 +-
 .../persistence/jpa/dao/JPAAnySearchDAO.java    | 12 ++-
 .../core/persistence/jpa/dao/JPAGroupDAO.java   | 15 ++--
 .../core/persistence/jpa/dao/JPARoleDAO.java    |  3 +-
 .../persistence/jpa/inner/AnyObjectTest.java    |  2 +-
 .../persistence/jpa/inner/AnySearchTest.java    | 57 ++++++--------
 .../core/persistence/jpa/inner/GroupTest.java   |  2 +-
 .../persistence/jpa/inner/MultitenancyTest.java |  2 +-
 .../core/persistence/jpa/inner/UserTest.java    | 13 ++--
 .../persistence/jpa/outer/AnySearchTest.java    |  8 +-
 .../notification/NotificationManagerImpl.java   |  2 +-
 .../provisioning/java/sync/PushJobDelegate.java | 78 ++++++++++++--------
 .../core/provisioning/java/sync/SyncUtils.java  | 19 ++---
 .../activiti/SyncopeGroupQueryImpl.java         | 25 +++----
 .../workflow/activiti/SyncopeUserQueryImpl.java | 37 ++++------
 19 files changed, 186 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/logic/src/main/java/org/apache/syncope/core/logic/report/GroupReportlet.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/report/GroupReportlet.java b/core/logic/src/main/java/org/apache/syncope/core/logic/report/GroupReportlet.java
index ec9a745..7460205 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/report/GroupReportlet.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/report/GroupReportlet.java
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.core.logic.report;
 
-import org.apache.syncope.core.persistence.api.dao.ReportletConfClass;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -37,6 +36,7 @@ import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.misc.search.SearchCondConverter;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
+import org.apache.syncope.core.persistence.api.dao.ReportletConfClass;
 import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,27 +60,6 @@ public class GroupReportlet extends AbstractReportlet {
 
     private GroupReportletConf conf;
 
-    private List<Group> getPagedGroups(final int page) {
-        List<Group> result;
-
-        if (StringUtils.isBlank(conf.getMatchingCond())) {
-            result = groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE);
-        } else {
-            result = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                    SearchCondConverter.convert(conf.getMatchingCond()),
-                    page, PAGE_SIZE, Collections.<OrderByClause>emptyList(), AnyTypeKind.GROUP);
-        }
-
-        return result;
-    }
-
-    private int count() {
-        return StringUtils.isBlank(conf.getMatchingCond())
-                ? groupDAO.count(SyncopeConstants.FULL_ADMIN_REALMS)
-                : searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
-                        SearchCondConverter.convert(conf.getMatchingCond()), AnyTypeKind.GROUP);
-    }
-
     private void doExtractResources(final ContentHandler handler, final AnyTO anyTO)
             throws SAXException {
 
@@ -299,6 +278,13 @@ public class GroupReportlet extends AbstractReportlet {
         handler.endElement("", "", "configurations");
     }
 
+    private int count() {
+        return StringUtils.isBlank(conf.getMatchingCond())
+                ? groupDAO.count(SyncopeConstants.FULL_ADMIN_REALMS)
+                : searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
+                        SearchCondConverter.convert(conf.getMatchingCond()), AnyTypeKind.GROUP);
+    }
+
     @Override
     protected void doExtract(final ReportletConf conf, final ContentHandler handler) throws SAXException {
         if (conf instanceof GroupReportletConf) {
@@ -308,8 +294,16 @@ public class GroupReportlet extends AbstractReportlet {
         }
 
         doExtractConf(handler);
-        for (int i = 1; i <= (count() / PAGE_SIZE) + 1; i++) {
-            doExtract(handler, getPagedGroups(i));
+
+        if (StringUtils.isBlank(this.conf.getMatchingCond())) {
+            doExtract(handler, groupDAO.findAll());
+        } else {
+            for (int page = 1; page <= (count() / PAGE_SIZE) + 1; page++) {
+                List<Group> groups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+                        SearchCondConverter.convert(this.conf.getMatchingCond()),
+                        page, PAGE_SIZE, Collections.<OrderByClause>emptyList(), AnyTypeKind.GROUP);
+                doExtract(handler, groups);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/logic/src/main/java/org/apache/syncope/core/logic/report/UserReportlet.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/report/UserReportlet.java b/core/logic/src/main/java/org/apache/syncope/core/logic/report/UserReportlet.java
index 2523e8f..9dbe8b8 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/report/UserReportlet.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/report/UserReportlet.java
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.core.logic.report;
 
-import org.apache.syncope.core.persistence.api.dao.ReportletConfClass;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -40,6 +39,7 @@ import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.misc.search.SearchCondConverter;
 import org.apache.syncope.core.misc.utils.FormatUtils;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
+import org.apache.syncope.core.persistence.api.dao.ReportletConfClass;
 import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 import org.apache.syncope.core.persistence.api.entity.user.URelationship;
 import org.apache.syncope.core.provisioning.api.data.AnyObjectDataBinder;
@@ -72,27 +72,6 @@ public class UserReportlet extends AbstractReportlet {
 
     private UserReportletConf conf;
 
-    private List<User> getPagedUsers(final int page) {
-        List<User> result;
-
-        if (StringUtils.isBlank(conf.getMatchingCond())) {
-            result = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE);
-        } else {
-            result = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                    SearchCondConverter.convert(conf.getMatchingCond()),
-                    page, PAGE_SIZE, Collections.<OrderByClause>emptyList(), AnyTypeKind.USER);
-        }
-
-        return result;
-    }
-
-    private int count() {
-        return StringUtils.isBlank(conf.getMatchingCond())
-                ? userDAO.count(SyncopeConstants.FULL_ADMIN_REALMS)
-                : searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
-                        SearchCondConverter.convert(conf.getMatchingCond()), AnyTypeKind.USER);
-    }
-
     private void doExtractResources(final ContentHandler handler, final AnyTO anyTO)
             throws SAXException {
 
@@ -369,6 +348,13 @@ public class UserReportlet extends AbstractReportlet {
         handler.endElement("", "", "configurations");
     }
 
+    private int count() {
+        return StringUtils.isBlank(conf.getMatchingCond())
+                ? userDAO.count(SyncopeConstants.FULL_ADMIN_REALMS)
+                : searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
+                        SearchCondConverter.convert(conf.getMatchingCond()), AnyTypeKind.USER);
+    }
+
     @Override
     protected void doExtract(final ReportletConf conf, final ContentHandler handler) throws SAXException {
         if (conf instanceof UserReportletConf) {
@@ -378,8 +364,17 @@ public class UserReportlet extends AbstractReportlet {
         }
 
         doExtractConf(handler);
-        for (int i = 1; i <= (count() / PAGE_SIZE) + 1; i++) {
-            doExtract(handler, getPagedUsers(i));
+
+        if (StringUtils.isBlank(this.conf.getMatchingCond())) {
+            doExtract(handler, userDAO.findAll());
+        } else {
+            for (int page = 1; page <= (count() / PAGE_SIZE) + 1; page++) {
+                List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+                        SearchCondConverter.convert(this.conf.getMatchingCond()),
+                        page, PAGE_SIZE, Collections.<OrderByClause>emptyList(), AnyTypeKind.USER);
+                doExtract(handler, users);
+            }
+
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
index 3d8162b..e957588 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnyDAO.java
@@ -53,8 +53,23 @@ public interface AnyDAO<A extends Any<?>> extends DAO<A, Long> {
 
     List<A> findByResource(ExternalResource resource);
 
-    List<A> findAll(Set<String> adminRealms, int page, int itemsPerPage);
+    /**
+     * Find any objects without any limitation.
+     *
+     * @return all any objects of type {@link A} available.
+     */
+    List<A> findAll();
 
+    /**
+     * Find any objects visible from the given admin realms, according to given page and items per page, sorted as
+     * required.
+     *
+     * @param adminRealms admin realms
+     * @param page search result page
+     * @param itemsPerPage items per search result page
+     * @param orderBy ordering clauses
+     * @return any objects of type {@link A} matching the provided conditions
+     */
     List<A> findAll(Set<String> adminRealms, int page, int itemsPerPage, List<OrderByClause> orderBy);
 
     <S extends Schema> Collection<S> findAllowedSchemas(A any, Class<S> reference);

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
index a442890..401d957 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AnySearchDAO.java
@@ -36,25 +36,21 @@ public interface AnySearchDAO extends DAO<Any<?>, Long> {
     int count(Set<String> adminRealms, SearchCond searchCondition, AnyTypeKind kind);
 
     /**
-     * @param adminRealms realms for which the caller owns the proper entitlement(s)
      * @param searchCondition the search condition
      * @param kind any object
      * @param <T> any
      * @return the list of any objects matching the given search condition
      */
-    <T extends Any<?>> List<T> search(
-            Set<String> adminRealms, SearchCond searchCondition, AnyTypeKind kind);
+    <T extends Any<?>> List<T> search(SearchCond searchCondition, AnyTypeKind kind);
 
     /**
-     * @param adminRealms the set of admin groups owned by the caller
      * @param searchCondition the search condition
      * @param orderBy list of ordering clauses
      * @param kind any object
      * @param <T> any
      * @return the list of any objects matching the given search condition
      */
-    <T extends Any<?>> List<T> search(
-            Set<String> adminRealms, SearchCond searchCondition, List<OrderByClause> orderBy, AnyTypeKind kind);
+    <T extends Any<?>> List<T> search(SearchCond searchCondition, List<OrderByClause> orderBy, AnyTypeKind kind);
 
     /**
      * @param adminRealms realms for which the caller owns the proper entitlement(s)

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index 30fcf2f..3db3f61 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -34,6 +34,7 @@ import org.apache.commons.jexl2.parser.Parser;
 import org.apache.commons.jexl2.parser.ParserConstants;
 import org.apache.commons.jexl2.parser.Token;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.core.persistence.api.dao.AnyDAO;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
@@ -396,10 +397,8 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A, Lo
     }
 
     @Override
-    public final List<A> findAll(final Set<String> adminRealms,
-            final int page, final int itemsPerPage) {
-
-        return findAll(adminRealms, page, itemsPerPage, Collections.<OrderByClause>emptyList());
+    public final List<A> findAll() {
+        return findAll(SyncopeConstants.FULL_ADMIN_REALMS, -1, -1, Collections.<OrderByClause>emptyList());
     }
 
     private SearchCond getAllMatchingCond() {

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index f5c3922..64c850b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -37,6 +37,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.AttrSchemaType;
 import org.apache.syncope.core.misc.utils.RealmUtils;
@@ -150,18 +151,15 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
     }
 
     @Override
-    public <T extends Any<?>> List<T> search(
-            final Set<String> adminRealms, final SearchCond searchCondition, final AnyTypeKind typeKind) {
-
-        return search(adminRealms, searchCondition, Collections.<OrderByClause>emptyList(), typeKind);
+    public <T extends Any<?>> List<T> search(final SearchCond searchCondition, final AnyTypeKind typeKind) {
+        return search(searchCondition, Collections.<OrderByClause>emptyList(), typeKind);
     }
 
     @Override
     public <T extends Any<?>> List<T> search(
-            final Set<String> adminRealms, final SearchCond searchCondition, final List<OrderByClause> orderBy,
-            final AnyTypeKind typeKind) {
+            final SearchCond searchCondition, final List<OrderByClause> orderBy, final AnyTypeKind typeKind) {
 
-        return search(adminRealms, searchCondition, -1, -1, orderBy, typeKind);
+        return search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, -1, -1, orderBy, typeKind);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index af77371..7e5667c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -27,7 +27,6 @@ import javax.persistence.NoResultException;
 import javax.persistence.TypedQuery;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ResourceOperation;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
@@ -133,10 +132,8 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
             return Collections.<Group>emptyList();
         }
 
-        StringBuilder queryString = new StringBuilder("SELECT e FROM ").append(JPAGroup.class.getSimpleName()).
-                append(" e WHERE e.groupOwner=:owner ");
-
-        TypedQuery<Group> query = entityManager().createQuery(queryString.toString(), Group.class);
+        TypedQuery<Group> query = entityManager().createQuery(
+                "SELECT e FROM " + JPAGroup.class.getSimpleName() + " e WHERE e.groupOwner=:owner", Group.class);
         query.setParameter("owner", owner);
 
         return query.getResultList();
@@ -166,7 +163,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     public Group save(final Group group) {
         // refresh dynaminc memberships
         if (group.getADynMembership() != null) {
-            List<AnyObject> matching = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+            List<AnyObject> matching = searchDAO.search(
                     SearchCondConverter.convert(group.getADynMembership().getFIQLCond()), AnyTypeKind.ANY_OBJECT);
 
             group.getADynMembership().getMembers().clear();
@@ -175,7 +172,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
             }
         }
         if (group.getUDynMembership() != null) {
-            List<User> matching = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+            List<User> matching = searchDAO.search(
                     SearchCondConverter.convert(group.getUDynMembership().getFIQLCond()), AnyTypeKind.USER);
 
             group.getUDynMembership().getMembers().clear();
@@ -261,7 +258,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
     @Override
     public void refreshDynMemberships(final AnyObject anyObject) {
-        for (Group role : findAll(SyncopeConstants.FULL_ADMIN_REALMS, -1, -1)) {
+        for (Group role : findAll()) {
             if (role.getADynMembership() != null && !searchDAO.matches(anyObject,
                     SearchCondConverter.convert(role.getADynMembership().getFIQLCond()), AnyTypeKind.ANY_OBJECT)) {
 
@@ -273,7 +270,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
     @Override
     public void refreshDynMemberships(final User user) {
-        for (Group role : findAll(SyncopeConstants.FULL_ADMIN_REALMS, -1, -1)) {
+        for (Group role : findAll()) {
             if (role.getUDynMembership() != null && !searchDAO.matches(user,
                     SearchCondConverter.convert(role.getUDynMembership().getFIQLCond()), AnyTypeKind.USER)) {
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
index 4dc1688..6ecf444 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persistence.jpa.dao;
 
 import java.util.List;
 import javax.persistence.TypedQuery;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.core.misc.search.SearchCondConverter;
 import org.apache.syncope.core.persistence.api.dao.RoleDAO;
@@ -65,7 +64,7 @@ public class JPARoleDAO extends AbstractDAO<Role, String> implements RoleDAO {
     public Role save(final Role role) {
         // refresh dynaminc memberships
         if (role.getDynMembership() != null) {
-            List<User> matchingUsers = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+            List<User> matchingUsers = searchDAO.search(
                     SearchCondConverter.convert(role.getDynMembership().getFIQLCond()), AnyTypeKind.USER);
 
             role.getDynMembership().getMembers().clear();

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java
index a695e85..6ab3e01 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java
@@ -47,7 +47,7 @@ public class AnyObjectTest extends AbstractTest {
 
     @Test
     public void findAll() {
-        List<AnyObject> list = anyObjectDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100);
+        List<AnyObject> list = anyObjectDAO.findAll();
         assertFalse(list.isEmpty());
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
index 5c8dde9..48c09d6 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
@@ -129,7 +129,7 @@ public class AnySearchTest extends AbstractTest {
 
         assertTrue(cond.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -143,7 +143,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
         assertTrue(cond.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(4, users.size());
 
@@ -164,7 +164,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
         assertTrue(cond.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
 
@@ -211,16 +211,14 @@ public class AnySearchTest extends AbstractTest {
         MembershipCond groupCond = new MembershipCond();
         groupCond.setGroupKey(1L);
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(groupCond), AnyTypeKind.USER);
+        List<User> users = searchDAO.search(SearchCond.getLeafCond(groupCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(2, users.size());
 
         groupCond = new MembershipCond();
         groupCond.setGroupKey(5L);
 
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getNotLeafCond(groupCond), AnyTypeKind.USER);
+        users = searchDAO.search(SearchCond.getNotLeafCond(groupCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(5, users.size());
     }
@@ -230,8 +228,7 @@ public class AnySearchTest extends AbstractTest {
         RoleCond roleCond = new RoleCond();
         roleCond.setRoleKey("Other");
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
+        List<User> users = searchDAO.search(SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -241,16 +238,14 @@ public class AnySearchTest extends AbstractTest {
         AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.ISNULL);
         coolLeafCond.setSchema("cool");
 
-        List<User> users = searchDAO.search(
-                SyncopeConstants.FULL_ADMIN_REALMS, SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
+        List<User> users = searchDAO.search(SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(4, users.size());
 
         coolLeafCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
         coolLeafCond.setSchema("cool");
 
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
+        users = searchDAO.search(SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -266,7 +261,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getLeafCond(ws1));
         assertTrue(searchCondition.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }
@@ -277,8 +272,7 @@ public class AnySearchTest extends AbstractTest {
         booleanCond.setSchema("show");
         booleanCond.setExpression("true");
 
-        List<Group> matchingGroups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(booleanCond), AnyTypeKind.GROUP);
+        List<Group> matchingGroups = searchDAO.search(SearchCond.getLeafCond(booleanCond), AnyTypeKind.GROUP);
         assertNotNull(matchingGroups);
         assertFalse(matchingGroups.isEmpty());
     }
@@ -297,9 +291,7 @@ public class AnySearchTest extends AbstractTest {
                 SearchCond.getLeafCond(usernameLeafCond),
                 SearchCond.getLeafCond(idRightCond));
 
-        List<User> matchingUsers = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, AnyTypeKind.USER);
-
+        List<User> matchingUsers = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(matchingUsers);
         assertEquals(1, matchingUsers.size());
         assertEquals("rossini", matchingUsers.iterator().next().getUsername());
@@ -322,9 +314,7 @@ public class AnySearchTest extends AbstractTest {
 
         assertTrue(searchCondition.isValid());
 
-        List<Group> matchingGroups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, AnyTypeKind.GROUP);
-
+        List<Group> matchingGroups = searchDAO.search(searchCondition, AnyTypeKind.GROUP);
         assertNotNull(matchingGroups);
         assertEquals(1, matchingGroups.size());
         assertEquals("root", matchingGroups.iterator().next().getName());
@@ -345,7 +335,7 @@ public class AnySearchTest extends AbstractTest {
                 SearchCond.getLeafCond(usernameLeafCond),
                 SearchCond.getLeafCond(idRightCond));
 
-        List<User> matchingUsers = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+        List<User> matchingUsers = searchDAO.search(
                 searchCondition, AnyTypeKind.USER);
         assertNotNull(matchingUsers);
         assertEquals(2, matchingUsers.size());
@@ -360,7 +350,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
         assertTrue(searchCondition.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
         assertEquals(1L, users.iterator().next().getKey(), 0);
@@ -372,7 +362,7 @@ public class AnySearchTest extends AbstractTest {
         searchCondition = SearchCond.getNotLeafCond(idLeafCond);
         assertTrue(searchCondition.isValid());
 
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(2, users.size());
         assertTrue(CollectionUtils.exists(users, new Predicate<User>() {
@@ -392,14 +382,12 @@ public class AnySearchTest extends AbstractTest {
         SearchCond searchCondition = SearchCond.getLeafCond(tcond);
         assertTrue(searchCondition.isValid());
 
-        List<AnyObject> printers = searchDAO.search(
-                SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.ANY_OBJECT);
+        List<AnyObject> printers = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
         assertNotNull(printers);
         assertEquals(2, printers.size());
 
         tcond.setAnyTypeName("UNEXISTING");
-        printers = searchDAO.search(
-                SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.ANY_OBJECT);
+        printers = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
         assertNotNull(printers);
         assertTrue(printers.isEmpty());
     }
@@ -425,8 +413,7 @@ public class AnySearchTest extends AbstractTest {
         orderByClause.setDirection(OrderByClause.Direction.ASC);
         orderByClauses.add(orderByClause);
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, orderByClauses, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, orderByClauses, AnyTypeKind.USER);
         assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER),
                 users.size());
     }
@@ -442,7 +429,7 @@ public class AnySearchTest extends AbstractTest {
         OrderByClause orderByClause = new OrderByClause();
         orderByClause.setField("name");
 
-        List<Group> groups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+        List<Group> groups = searchDAO.search(
                 searchCondition, Collections.singletonList(orderByClause), AnyTypeKind.GROUP);
         assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
                 searchCondition, AnyTypeKind.GROUP),
@@ -461,7 +448,7 @@ public class AnySearchTest extends AbstractTest {
                 SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getNotLeafCond(ws1));
         assertTrue(searchCondition.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(2, users.size());
         assertTrue(CollectionUtils.exists(users, new Predicate<User>() {
@@ -482,7 +469,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond searchCondition = SearchCond.getLeafCond(cond);
         assertTrue(searchCondition.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertTrue(users.isEmpty());
     }
@@ -496,7 +483,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond searchCondition = SearchCond.getLeafCond(cond);
         assertTrue(searchCondition.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/GroupTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/GroupTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/GroupTest.java
index 4d37425..9d449be 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/GroupTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/GroupTest.java
@@ -47,7 +47,7 @@ public class GroupTest extends AbstractTest {
 
     @Test
     public void findAll() {
-        List<Group> list = groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100);
+        List<Group> list = groupDAO.findAll();
         assertEquals("did not get expected number of groups ", 15, list.size());
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/MultitenancyTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/MultitenancyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/MultitenancyTest.java
index 073b661..9366705 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/MultitenancyTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/MultitenancyTest.java
@@ -95,7 +95,7 @@ public class MultitenancyTest extends AbstractTest {
     @Test
     public void createUser() {
         assertNull(realmDAO.getRoot().getPasswordPolicy());
-        assertTrue(userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 1000).isEmpty());
+        assertTrue(userDAO.findAll().isEmpty());
 
         User user = entityFactory.newEntity(User.class);
         user.setRealm(realmDAO.getRoot());

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/UserTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/UserTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/UserTest.java
index e1d12b1..44b888b 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/UserTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/UserTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import org.apache.syncope.common.lib.SyncopeConstants;
@@ -35,6 +36,7 @@ import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.apache.syncope.core.misc.policy.InvalidPasswordRuleConf;
 import org.apache.syncope.core.misc.security.PasswordGenerator;
 import org.apache.syncope.core.persistence.api.dao.RealmDAO;
+import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -53,7 +55,7 @@ public class UserTest extends AbstractTest {
 
     @Test
     public void findAll() {
-        List<User> list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100);
+        List<User> list = userDAO.findAll();
         assertEquals("did not get expected number of users", 5, list.size());
     }
 
@@ -67,19 +69,20 @@ public class UserTest extends AbstractTest {
     @Test
     public void findAllByPageAndSize() {
         // get first page
-        List<User> list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 2);
+        List<User> list = userDAO.findAll(
+                SyncopeConstants.FULL_ADMIN_REALMS, 1, 2, Collections.<OrderByClause>emptyList());
         assertEquals("did not get expected number of users", 2, list.size());
 
         // get second page
-        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 2, 2);
+        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 2, 2, Collections.<OrderByClause>emptyList());
         assertEquals("did not get expected number of users", 2, list.size());
 
         // get second page with uncomplete set
-        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 2, 3);
+        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 2, 3, Collections.<OrderByClause>emptyList());
         assertEquals("did not get expected number of users", 2, list.size());
 
         // get unexistent page
-        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 3, 2);
+        list = userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 3, 2, Collections.<OrderByClause>emptyList());
         assertEquals("did not get expected number of users", 1, list.size());
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
index 001a984..d000884 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
@@ -61,7 +60,7 @@ public class AnySearchTest extends AbstractTest {
 
     @Test
     public void issueSYNCOPE95() {
-        Set<Group> groups = new HashSet<>(groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100));
+        Set<Group> groups = new HashSet<>(groupDAO.findAll());
         for (Group group : groups) {
             groupDAO.delete(group.getKey());
         }
@@ -74,7 +73,7 @@ public class AnySearchTest extends AbstractTest {
         SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
         assertTrue(cond.isValid());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, AnyTypeKind.USER);
+        List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
 
@@ -106,8 +105,7 @@ public class AnySearchTest extends AbstractTest {
         RoleCond roleCond = new RoleCond();
         roleCond.setRoleKey(role.getKey());
 
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
+        List<User> users = searchDAO.search(SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
         assertNotNull(users);
         assertEquals(1, users.size());
         assertEquals(4L, users.get(0).getKey(), 0);

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
index 820c5f3..9aa507a 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/NotificationManagerImpl.java
@@ -189,7 +189,7 @@ public class NotificationManagerImpl implements NotificationManager {
         List<User> recipients = new ArrayList<>();
 
         if (notification.getRecipients() != null) {
-            recipients.addAll(searchDAO.<User>search(SyncopeConstants.FULL_ADMIN_REALMS,
+            recipients.addAll(searchDAO.<User>search(
                     SearchCondConverter.convert(notification.getRecipients()),
                     Collections.<OrderByClause>emptyList(), AnyTypeKind.USER));
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
index 65b0cf7..b045a63 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
@@ -33,6 +33,7 @@ import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
 import org.apache.syncope.core.provisioning.api.Connector;
@@ -90,6 +91,22 @@ public class PushJobDelegate extends AbstractProvisioningJobDelegate<PushTask> {
         return result;
     }
 
+    protected void handle(
+            final List<? extends Any<?>> anys,
+            final SyncopePushResultHandler handler,
+            final ExternalResource resource)
+            throws JobExecutionException {
+
+        for (Any<?> any : anys) {
+            try {
+                handler.handle(any.getKey());
+            } catch (Exception e) {
+                LOG.warn("Failure pushing '{}' on '{}'", any, resource, e);
+                throw new JobExecutionException("While pushing " + any + " on " + resource, e);
+            }
+        }
+    }
+
     @Override
     protected String doExecuteProvisioning(
             final PushTask pushTask,
@@ -139,41 +156,38 @@ public class PushJobDelegate extends AbstractProvisioningJobDelegate<PushTask> {
         for (Provision provision : pushTask.getResource().getProvisions()) {
             if (provision.getMapping() != null) {
                 AnyDAO<?> anyDAO = getAnyDAO(provision.getAnyType().getKind());
+
+                SyncopePushResultHandler handler;
+                switch (provision.getAnyType().getKind()) {
+                    case USER:
+                        handler = uhandler;
+                        break;
+
+                    case GROUP:
+                        handler = ghandler;
+                        break;
+
+                    case ANY_OBJECT:
+                    default:
+                        handler = ahandler;
+                }
+
                 String filter = pushTask.getFilter(provision.getAnyType()) == null
                         ? null
                         : pushTask.getFilter(provision.getAnyType()).get();
-
-                int count = anyDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
-                for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
-                    List<? extends Any<?>> localAnys = StringUtils.isBlank(filter)
-                            ? anyDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE)
-                            : searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                                    SearchCondConverter.convert(filter),
-                                    Collections.<OrderByClause>emptyList(), provision.getAnyType().getKind());
-
-                    for (Any<?> any : localAnys) {
-                        SyncopePushResultHandler handler;
-                        switch (provision.getAnyType().getKind()) {
-                            case USER:
-                                handler = uhandler;
-                                break;
-
-                            case GROUP:
-                                handler = ghandler;
-                                break;
-
-                            case ANY_OBJECT:
-                            default:
-                                handler = ahandler;
-                        }
-
-                        try {
-                            handler.handle(any.getKey());
-                        } catch (Exception e) {
-                            LOG.warn("Failure pushing '{}' on '{}'", any, pushTask.getResource(), e);
-                            throw new JobExecutionException(
-                                    "While pushing " + any + " on " + pushTask.getResource(), e);
-                        }
+                if (StringUtils.isBlank(filter)) {
+                    handle(anyDAO.findAll(), handler, pushTask.getResource());
+                } else {
+                    int count = anyDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
+                    for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
+                        List<? extends Any<?>> anys = searchDAO.search(
+                                SyncopeConstants.FULL_ADMIN_REALMS,
+                                SearchCondConverter.convert(filter),
+                                page,
+                                PAGE_SIZE,
+                                Collections.<OrderByClause>emptyList(),
+                                provision.getAnyType().getKind());
+                        handle(anys, handler, pushTask.getResource());
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
index 1c01497..17749d1 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.policy.SyncPolicySpec;
 import org.apache.syncope.core.misc.utils.MappingUtils;
@@ -34,7 +33,6 @@ import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.entity.Any;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
@@ -123,11 +121,11 @@ public class SyncUtils {
                 new EqualsFilter(new Name(name)),
                 new ResultsHandler() {
 
-                    @Override
-                    public boolean handle(final ConnectorObject obj) {
-                        return found.add(obj);
-                    }
-                },
+            @Override
+            public boolean handle(final ConnectorObject obj) {
+                return found.add(obj);
+            }
+        },
                 MappingUtils.buildOperationOptions(MappingUtils.getSyncMappingItems(provision).iterator()));
 
         if (found.isEmpty()) {
@@ -249,12 +247,7 @@ public class SyncUtils {
             final ConnectorObject connObj, final SyncCorrelationRule rule, final AnyTypeKind type) {
 
         List<Long> result = new ArrayList<>();
-        for (Any<?> any : searchDAO.search(
-                SyncopeConstants.FULL_ADMIN_REALMS,
-                rule.getSearchCond(connObj),
-                Collections.<OrderByClause>emptyList(),
-                type)) {
-
+        for (Any<?> any : searchDAO.search(rule.getSearchCond(connObj), type)) {
             result.add(any.getKey());
         }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeGroupQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeGroupQueryImpl.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeGroupQueryImpl.java
index 20059ce..4336cf6 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeGroupQueryImpl.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeGroupQueryImpl.java
@@ -28,12 +28,11 @@ import org.activiti.engine.identity.GroupQuery;
 import org.activiti.engine.impl.persistence.entity.GroupEntity;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 
 public class SyncopeGroupQueryImpl implements GroupQuery {
 
-    private GroupDAO groupDAO;
+    private final GroupDAO groupDAO;
 
     private Long groupId;
 
@@ -103,7 +102,7 @@ public class SyncopeGroupQueryImpl implements GroupQuery {
         return new GroupEntity(group.getKey().toString());
     }
 
-    private void execute(final int page, final int itemsPerPage) {
+    private void execute() {
         if (groupId != null) {
             org.apache.syncope.core.persistence.api.entity.group.Group syncopeGroup = groupDAO.find(groupId);
             if (syncopeGroup == null) {
@@ -113,24 +112,22 @@ public class SyncopeGroupQueryImpl implements GroupQuery {
             }
         }
         if (result == null) {
-            result = CollectionUtils.collect(
-                    groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, itemsPerPage),
+            result = CollectionUtils.collect(groupDAO.findAll(),
                     new Transformer<org.apache.syncope.core.persistence.api.entity.group.Group, Group>() {
 
-                        @Override
-                        public Group transform(final org.apache.syncope.core.persistence.api.entity.group.Group user) {
-                            return fromSyncopeGroup(user);
-                        }
+                @Override
+                public Group transform(final org.apache.syncope.core.persistence.api.entity.group.Group user) {
+                    return fromSyncopeGroup(user);
+                }
 
-                    },
-                    new ArrayList<Group>());
+            }, new ArrayList<Group>());
         }
     }
 
     @Override
     public long count() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         return result.size();
     }
@@ -138,7 +135,7 @@ public class SyncopeGroupQueryImpl implements GroupQuery {
     @Override
     public Group singleResult() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         if (result.isEmpty()) {
             throw new ActivitiException("Empty result");
@@ -150,7 +147,7 @@ public class SyncopeGroupQueryImpl implements GroupQuery {
     @Override
     public List<Group> list() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/c3e4c38d/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
index caa8a05..e213c6e 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
@@ -27,7 +27,6 @@ import org.activiti.engine.identity.UserQuery;
 import org.activiti.engine.impl.persistence.entity.UserEntity;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
@@ -35,9 +34,9 @@ import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 
 public class SyncopeUserQueryImpl implements UserQuery {
 
-    private UserDAO userDAO;
+    private final UserDAO userDAO;
 
-    private GroupDAO groupDAO;
+    private final GroupDAO groupDAO;
 
     private String username;
 
@@ -135,15 +134,13 @@ public class SyncopeUserQueryImpl implements UserQuery {
         return new UserEntity(user.getUsername());
     }
 
-    private void execute(final int page, final int itemsPerPage) {
+    private void execute() {
         if (username != null) {
             org.apache.syncope.core.persistence.api.entity.user.User user = userDAO.find(username);
             if (user == null) {
                 result = Collections.<User>emptyList();
-            } else {
-                if (memberOf == null || userDAO.findAllGroupKeys(user).contains(memberOf)) {
-                    result = Collections.singletonList(fromSyncopeUser(user));
-                }
+            } else if (memberOf == null || userDAO.findAllGroupKeys(user).contains(memberOf)) {
+                result = Collections.singletonList(fromSyncopeUser(user));
             }
         }
         if (memberOf != null) {
@@ -163,24 +160,22 @@ public class SyncopeUserQueryImpl implements UserQuery {
         }
         // THIS CAN BE *VERY* DANGEROUS
         if (result == null) {
-            result = CollectionUtils.collect(
-                    userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, itemsPerPage),
+            result = CollectionUtils.collect(userDAO.findAll(),
                     new Transformer<org.apache.syncope.core.persistence.api.entity.user.User, User>() {
 
-                        @Override
-                        public User transform(final org.apache.syncope.core.persistence.api.entity.user.User user) {
-                            return fromSyncopeUser(user);
-                        }
+                @Override
+                public User transform(final org.apache.syncope.core.persistence.api.entity.user.User user) {
+                    return fromSyncopeUser(user);
+                }
 
-                    },
-                    new ArrayList<User>());
+            }, new ArrayList<User>());
         }
     }
 
     @Override
     public long count() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         return result.size();
     }
@@ -188,7 +183,7 @@ public class SyncopeUserQueryImpl implements UserQuery {
     @Override
     public User singleResult() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         if (result.isEmpty()) {
             throw new ActivitiException("Empty result");
@@ -200,7 +195,7 @@ public class SyncopeUserQueryImpl implements UserQuery {
     @Override
     public List<User> list() {
         if (result == null) {
-            execute(-1, -1);
+            execute();
         }
         return result;
     }
@@ -208,9 +203,9 @@ public class SyncopeUserQueryImpl implements UserQuery {
     @Override
     public List<User> listPage(final int firstResult, final int maxResults) {
         if (result == null) {
-            execute((firstResult / maxResults) + 1, maxResults);
+            execute();
         }
-        return result;
+        return result.subList(firstResult, firstResult + maxResults - 1);
     }
 
     @Override


Mime
View raw message