summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
index c75246f..e329d46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
@@ -93,6 +93,7 @@ import org.rhq.core.domain.criteria.PackageCriteria;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCreationDataType;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.MessageDigestGenerator;
@@ -107,6 +108,7 @@ import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.plugin.pc.content.PackageDetailsValidationException;
import org.rhq.enterprise.server.plugin.pc.content.PackageTypeBehavior;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
@@ -145,6 +147,9 @@ public class ContentManagerBean implements ContentManagerLocal, ContentManagerRe
private ContentManagerLocal contentManager;
@EJB
+ private ResourceManagerLocal resourceManager;
+
+ @EJB
private ResourceTypeManagerLocal resourceTypeManager;
@EJB
@@ -1609,6 +1614,13 @@ public class ContentManagerBean implements ContentManagerLocal, ContentManagerRe
public InstalledPackage getBackingPackageForResource(Subject subject, int resourceId) {
InstalledPackage result = null;
+ // check if the resource is content backed
+ Resource res = resourceManager.getResourceById(subject, resourceId);
+ ResourceType type = res.getResourceType();
+ if (!ResourceCreationDataType.CONTENT.equals(type.getCreationDataType())) {
+ throw new UnsupportedOperationException("Resource [" + resourceId + "] is not content backed.");
+ }
+
InstalledPackageCriteria criteria = new InstalledPackageCriteria();
criteria.addFilterResourceId(resourceId);
PageList<InstalledPackage> ips = findInstalledPackagesByCriteria(subject, criteria);