[rhq] modules/enterprise

Jay Shaughnessy jshaughn at fedoraproject.org
Mon Aug 20 18:59:28 UTC 2012


 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java |   13 ++++++----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 414ccdf3fd964dc6d64abe511ec02f4e9170aa40
Author: Jay Shaughnessy <jshaughn at redhat.com>
Date:   Mon Aug 20 14:59:13 2012 -0400

    [Bug 849751 - RFE: protect resource tree from direct navigation to a resource with many siblings]
    Apply the new ResourceManager.findResourcesByCriteriaBounded() method
    to getResourceLineageAndSiblings() in order to similarly bound the initial
    tree building fetch.  Currently getResourceLineageAndSiblings() will use
    the defaults applied to findResourcesByCriteriaBounded(), although we may
    find that providing separate overrides will be useful.

diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 0fe906a..a016f8e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -113,6 +113,7 @@ import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
 import org.rhq.core.domain.server.PersistenceUtility;
 import org.rhq.core.domain.util.PageControl;
 import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
 import org.rhq.core.util.IntExtractor;
 import org.rhq.core.util.collection.ArrayUtils;
 import org.rhq.enterprise.server.RHQConstants;
@@ -796,14 +797,16 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
 
             // If the ancestor is not locked, include viewable children.
             if (!ancestor.isLocked() || ancestor.getResource() == parent) {
-                // Get all viewable committed children.
-                PageList<Resource> children = findChildResourcesByCategoryAndInventoryStatus(subject,
-                    ancestor.getResource(), null, InventoryStatus.COMMITTED, PageControl.getUnlimitedInstance());
+                // Get viewable committed children, but bounded to ensure it's not an overwhelming return set
+                ResourceCriteria criteria = new ResourceCriteria();
+                criteria.addFilterParentResourceId(ancestor.getResource().getId());
+                criteria.addSortName(PageOrdering.ASC);
+                List<Resource> children = findResourcesByCriteriaBounded(subject, criteria, 0, 0);
                 // Remove any that are in the lineage to avoid repeated handling.
                 children.removeAll(rawResourceLineage);
                 for (Resource child : children) {
-                    // Ensure the parentResource field is fetched.
-                    //noinspection ConstantConditions
+                    // Ensure the parentResource field is fetched. (do this here and not via criteria.fetchParentResource
+                    // because that option would require inventory manager perm)
                     child.getParentResource().getId();
                     // The query only returned viewable children, so the composite should not be locked.
                     boolean isLocked = false;




More information about the rhq-commits mailing list