modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 19 +++++++--- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 8 +++- 2 files changed, 22 insertions(+), 5 deletions(-)
New commits: commit 7b5ccc130607114a539bae8a97e7b097e7edc1ba Author: Lukas Krejci lkrejci@redhat.com Date: Wed Feb 24 13:27:56 2010 +0100
BZ 567925 - a follow up to my previous commit should finally fix the issue.
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 54cebf6..b0db81c 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 @@ -2204,7 +2204,10 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage for (T r : results) { MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>(); value.original = r; - reportByResourceId.put(extractor.extract(r), value); + int resourceId = extractor.extract(r); + if (resourceId > 0) { + reportByResourceId.put(resourceId, value); + } }
//k, now let's construct the JPQL query to get the parents and type infos... @@ -2247,10 +2250,18 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
//now we have all the information to create the result. //first create the immutable reports. - List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(reportByResourceId.size()); + List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size());
- for (Map.Entry<Integer, MutableDisambiguationReport<T>> entry : reportByResourceId.entrySet()) { - resolution.add(entry.getValue().getReport()); + for(T result : results) { + int resourceId = extractor.extract(result); + if (resourceId > 0) { + MutableDisambiguationReport<T> report = reportByResourceId.get(resourceId); + resolution.add(report.getReport()); + } else { + //this result doesn't correspond to any resource, need to handle it specially + DisambiguationReport<T> report = new DisambiguationReport<T>(result, Collections.<ResourceParentFlyweight>emptyList(), null, null); + resolution.add(report); + } }
return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded, diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java index 2c99c9d..6db6155 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java @@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceErrorType; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite; import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary; import org.rhq.core.domain.resource.composite.ResourceComposite; @@ -449,7 +450,12 @@ public interface ResourceManagerLocal { * The disambiguation result contains information on what types of information are needed to make the resources * in the original result unambiguous and contains the decorated original data in the same order as the * supplied result list. - * + * <p> + * The objects in results do not necessarily need to correspond to a resource. In case of such objects, + * the resourceIdExtractor should return 0. In the resulting report such objects will still be wrapped + * in a {@link DisambiguationReport} but the parent list will be empty and resource type and plugin name will + * be null. + * * @see ResourceNamesDisambiguationResult * * @param <T> the type of the result elements
rhq-commits@lists.fedorahosted.org