List<ResourceGroup> groups = resourceGroupManager.findResourceGroupsByCriteria(subject, c);
if (null == groups || groups.isEmpty()) {
throw new IllegalArgumentException("Invalid groupId [" + groupId
+ "]. It must be an existing compatible group whose members must be able to support bundle deployments");
}
ResourceGroup group = entityManager.find(ResourceGroup.class, groups.get(0).getId());
checkDeployBundleAuthz(subject, bundle.getId(), groupId);
// check that the resource group is compatible with the bundle type
Set<ResourceType> targetedResourceTypes = bundle.getBundleType().getExplicitlyTargetedResourceTypes();
if (!targetedResourceTypes.isEmpty() && !targetedResourceTypes.contains(group.getResourceType())) {
// the bundle type defines that it explicitly targets certain resource types but the current group
// is not of that resource type.
throw new IllegalArgumentException("Bundle of type [" + bundle.getBundleType().getName()
+ "] is incompatible with resource type " + group.getResourceType());
}
// check that the destination specification is compatible with the bundle type
String bundleType = bundle.getBundleType().getName();
ResourceType rt = group.getResourceType();
ResourceTypeBundleConfiguration bundleConfig = rt.getResourceTypeBundleConfiguration();
boolean found = false;
for (ResourceTypeBundleConfiguration.BundleDestinationSpecification spec : bundleConfig
.getAcceptableBundleDestinationSpecifications(bundleType)) {