@Override @RequiredPermission(Permission.CREATE_BUNDLES) public BundleType createBundleType(Subject subject, String name, int resourceTypeId) throws Exception { if (null == name || "".equals(name.trim())) { throw new IllegalArgumentException("Invalid bundleTypeName: " + name); } ResourceType resourceType = entityManager.find(ResourceType.class, resourceTypeId); if (null == resourceType) { throw new IllegalArgumentException("Invalid resourceeTypeId: " + resourceTypeId); } BundleType bundleType = new BundleType(name, resourceType); entityManager.persist(bundleType); return bundleType; }
public void addTargetedResourceType(ResourceType resourceType) { getExplicitlyTargetedResourceTypes().add(resourceType); resourceType.getExplicitlyTargetingBundleTypes().add(this); }
public BundleType(String name, ResourceType resourceType) { setName(name); setResourceType(resourceType); }
newBundleType.getExplicitlyTargetedResourceTypes().size()); if (!newBundleType.getExplicitlyTargetedResourceTypes().isEmpty()) { for (ResourceType targetType : newBundleType.getExplicitlyTargetedResourceTypes()) { ResourceType existingTargetType = resourceTypeMgr .getResourceTypeByNameAndPlugin(targetType.getName(), targetType.getPlugin()); newBundleType.setId(existingBundleType.getId()); newBundleType.setResourceType(existingType); newBundleType.getExplicitlyTargetedResourceTypes().clear(); newBundleType.getExplicitlyTargetedResourceTypes().addAll(targetedResourceTypes);
rtc.addFilterBundleTypeId(liveDeployment.getBundleVersion().getBundle().getBundleType().getId()); PageList<ResourceType> rts = resourceTypeManager.findResourceTypesByCriteria(subject, rtc); liveDeployment.getBundleVersion().getBundle().getBundleType().setResourceType(rts.get(0));
ResourceType resourceType = entityManager.find(ResourceType.class, bundleType.getResourceType().getId()); PackageType packageType = new PackageType(name, resourceType); packageType.setDescription("Package type for content of bundle " + name);
Set<ResourceType> targetedResourceTypes = bundle.getBundleType().getExplicitlyTargetedResourceTypes(); throw new IllegalArgumentException("Bundle of type [" + bundle.getBundleType().getName() + "] is incompatible with resource type " + group.getResourceType()); String bundleType = bundle.getBundleType().getName(); ResourceType rt = group.getResourceType(); ResourceTypeBundleConfiguration bundleConfig = rt.getResourceTypeBundleConfiguration();
/** * @deprecated since 4.13, see * {@link BundleManagerLocal#createBundleVersion(org.rhq.core.domain.auth.Subject, int, String, String, String, String)} */ @Override @SuppressWarnings("unchecked") @Deprecated public BundleVersion createBundleVersion(Subject subject, int bundleId, String name, String description, String version, String recipe) throws Exception { if (null == name || "".equals(name.trim())) { throw new IllegalArgumentException("Invalid bundleVersionName: " + name); } Bundle bundle = entityManager.find(Bundle.class, bundleId); if (null == bundle) { throw new IllegalArgumentException("Invalid bundleId: " + bundleId); } checkCreateBundleVersionAuthz(subject, bundleId); // parse the recipe (validation occurs here) and get the config def and list of files BundleType bundleType = bundle.getBundleType(); RecipeParseResults results; try { results = BundleManagerHelper.getPluginContainer().getBundleServerPluginManager() .parseRecipe(bundleType.getName(), recipe); } catch (Exception e) { // ensure that we throw a runtime exception to force a rollback throw new RuntimeException("Failed to parse recipe", e); } return createBundleVersionInternal(bundle, name, version, description, recipe, results.getConfigurationDefinition()); }
private void deleteBundles(final Subject subject, ResourceType resourceType) throws Exception { BundleType bundleType = resourceType.getBundleType(); if (bundleType == null) { return; } BundleCriteria criteria = new BundleCriteria(); criteria.addFilterBundleTypeId(bundleType.getId()); //Use CriteriaQuery to automatically chunk/page through criteria query results CriteriaQueryExecutor<Bundle, BundleCriteria> queryExecutor = new CriteriaQueryExecutor<Bundle, BundleCriteria>() { @Override public PageList<Bundle> execute(BundleCriteria criteria) { return bundleMgr.findBundlesByCriteria(subject, criteria); } }; CriteriaQuery<Bundle, BundleCriteria> bundles = new CriteriaQuery<Bundle, BundleCriteria>(criteria, queryExecutor); for (Bundle bundle : bundles) { bundleMgr.deleteBundle(subject, bundle.getId()); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((name == null) ? 0 : name.hashCode()); result = (prime * result) + ((bundleType == null) ? 0 : bundleType.hashCode()); return result; }
return false; } else if (!bundleType.equals(other.bundleType)) { return false;
private void parseBundleTypeTarget(BundleType bundleType, Bundle.Targets target) { if (target == null) { return; } for (Bundle.Targets.ResourceType ref : target.getResourceType()) { ResourceType rt = getResourceTypeFromPlugin(ref.getName(), ref.getPlugin()); bundleType.addTargetedResourceType(rt); } }
rtc.addFilterBundleTypeId(bundle.getBundleType().getId()); ResourceType resourceType = resourceTypeManager.findResourceTypesByCriteria(subject, rtc).get(0); bundle.getBundleType().setResourceType(resourceType);
ResourceType resourceType = bundleType.getResourceType(); Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType); if (resources.isEmpty()) {
.parseRecipe(bundleType.getName(), bundleVersion.getRecipe());
BundleCriteria criteria = new BundleCriteria(); criteria.setStrict(true); criteria.addFilterBundleTypeId(bundleType.getId()); criteria.addFilterName(bundleName); bundle = bundleManager.createBundle(subject, bundleName, bundleDescription, bundleType.getId(), initialBundleGroupIds); createdBundle = true;
public void removeTargetedResourceType(ResourceType resourceType) { getExplicitlyTargetedResourceTypes().remove(resourceType); resourceType.getExplicitlyTargetingBundleTypes().remove(this); }
ResourceType resourceType = bundleType.getResourceType(); Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType); if (resources.isEmpty()) {
if (bundle != null) { String typeName = bundle.getType(); resourceType.setBundleType(new BundleType(typeName, resourceType));
BundleType bundleType = bundleVersion.getBundle().getBundleType(); RecipeParseResults parseResults = BundleManagerHelper.getPluginContainer().getBundleServerPluginManager() .parseRecipe(bundleType.getName(), bundleVersion.getRecipe());