public ResourceTypeBundleConfiguration getResourceTypeBundleConfiguration() { if (this.bundleConfiguration == null) { return null; } else { return new ResourceTypeBundleConfiguration(bundleConfiguration); } }
public void setResourceTypeBundleConfiguration(ResourceTypeBundleConfiguration rtbc) { if (rtbc == null) { this.bundleConfiguration = null; } else { this.bundleConfiguration = rtbc.getBundleConfiguration(); } }
/** * Adds a destination base directory that can be used as a target for a bundle deployment. * * @param name the name of this bundle destination base directory (must not be <code>null</code>) * @param valueContext indicates where the value's name can be looked up and found. This * must be the string form of one of the enums found * in {@link BundleDestinationBaseDirectory.Context} * @param valueName the name of the property found in the given context where the value * of the base directory is * @param description optional explanation for what this destination location is * @param acceptedBundleTypes the list of accepted bundle types. Must not be null. */ public void addBundleDestinationBaseDirectory(String name, String valueContext, String valueName, String description, List<String> acceptedBundleTypes) { // we create this just to make sure the context and value are valid. An exception will be thrown if they are not. addBundleDestinationSpecification(new BundleDestinationBaseDirectory(name, valueContext, valueName, description, acceptedBundleTypes)); }
if (destDefs != null && destDefs.size() > 0) { Configuration c = new Configuration(); ResourceTypeBundleConfiguration bundleConfiguration = new ResourceTypeBundleConfiguration(c); for (BundleDestination destDef : destDefs) { if (destDef instanceof BundleDestinationBaseDir) { accepts.add(accept.getBundleType()); bundleConfiguration.addBundleDestinationBaseDirectory(name, valueContext, valueName, description, accepts); } else if (destDef instanceof BundleDestinationDefinition) { .createDestinationDefinitionBuilder(def.getName()); bld.withDescription(def.getDescription()).withConnectionString(def.getConnection());
Set<BundleDestinationSpecification> orig = getBundleDestinationSpecifications();
} else { if (!existingBundleConfiguration.equals(newBundleConfiguration)) { entityMgr.remove(existingBundleConfiguration.getBundleConfiguration()); entityMgr.persist(newBundleConfiguration.getBundleConfiguration()); existingType.setResourceTypeBundleConfiguration(newBundleConfiguration); log.debug("Removing bundle configuration"); entityMgr.remove(existingBundleConfiguration.getBundleConfiguration()); existingType.setResourceTypeBundleConfiguration(null);
boolean found = false; for (ResourceTypeBundleConfiguration.BundleDestinationSpecification spec : bundleConfig .getAcceptableBundleDestinationSpecifications(bundleType)) {
throw new IllegalArgumentException("The resource type doesn't support bundle deployments: " + resource); for (BundleDestinationBaseDirectory bdbd : rtbc.getBundleDestinationBaseDirectories()) { if (bdbd.getName().equals(destBaseDirName)) { bundleDestBaseDir = bdbd;
private String getConnectionString(BundleResourceDeployment resourceDeployment) { ResourceContainer rc = inventoryManager.getResourceContainer(resourceDeployment.getResource()); BundleDestination dest = resourceDeployment.getBundleDeployment().getDestination(); ResourceType type = rc.getResource().getResourceType(); String specName = dest.getDestinationSpecificationName(); String relativeDeployDir = dest.getDeployDir(); Configuration config = new Configuration(); config.put(new PropertySimple("deployDir", relativeDeployDir)); ConnectionStringAvailableProperties props = new ConnectionStringAvailableProperties(rc, measurementManager, config); for (ResourceTypeBundleConfiguration.BundleDestinationSpecification spec : type .getResourceTypeBundleConfiguration().getBundleDestinationSpecifications()) { if (specName.equals(spec.getName())) { ResourceTypeBundleConfiguration.BundleDestinationDefinition def = (ResourceTypeBundleConfiguration.BundleDestinationDefinition) spec; String rawConnectionString = def.getConnectionString(); if (rawConnectionString == null) { return null; } TokenReplacingReader trr = new TokenReplacingReader(new StringReader(rawConnectionString), props); try { return StreamUtil.slurp(trr); } finally { StreamUtil.safeClose(trr); } } } return null; }
@Override public ResourceTypeBundleConfiguration getResourceTypeBundleConfiguration(Subject subject, int compatGroupId) throws Exception { // Even though its harmless to return metadata (bundle config) about a resource type, we are getting that through // a relationship from a resource group. To prevent someone from probing the inventory to see which groups // are types that support bundles, we only allow someone to traverse the relationship from group to type // if that someone has access to the group. if (authorizationManager.canViewGroup(subject, compatGroupId)) { Query q = entityManager.createNamedQuery(ResourceType.QUERY_GET_BUNDLE_CONFIG_BY_GROUP_ID); q.setParameter("groupId", compatGroupId); ResourceTypeBundleConfiguration bundleConfig = null; try { Configuration config = (Configuration) q.getSingleResult(); if (config != null) { bundleConfig = new ResourceTypeBundleConfiguration(config); } } catch (EntityNotFoundException enfe) { // ignore this - this is just a group that isn't a compatible group // or it is, but its type cannot be a target for bundle deployments } return bundleConfig; } else { throw new Exception("[" + subject.getName() + "] is not authorized to access the group"); } }
.getResourceTypeBundleConfiguration().getBundleDestinationSpecifications();
/** * Adds a destination base directory that can be used as a target for a bundle deployment. * * @param name the name of this bundle destination base directory (must not be <code>null</code>) * @param valueContext indicates where the value's name can be looked up and found. This * must be the string form of one of the enums found * in {@link BundleDestinationBaseDirectory.Context} * @param valueName the name of the property found in the given context where the value * of the base directory is * @param description optional explanation for what this destination location is * * @deprecated since 4.13, use {@link #addBundleDestinationBaseDirectory(String, String, String, String, java.util.List)} */ public void addBundleDestinationBaseDirectory(String name, String valueContext, String valueName, String description) { // we create this just to make sure the context and value are valid. An exception will be thrown if they are not. addBundleDestinationSpecification(new BundleDestinationBaseDirectory(name, valueContext, valueName, description, Collections.<String>emptyList())); }