/** * Gets the artifacts matching the key prefix from the application properties * of the specified application. * @param app the application of interest * @param keyPrefix type of artifacts of interest (e.g., downloadable, generated) * @return */ public static Artifacts get( final Properties props, final String keyPrefix) { final Artifacts result = new Artifacts(keyPrefix); for (String propName : props.stringPropertyNames()) { final String propNamePrefix = propNamePrefix(keyPrefix); if (propName.startsWith(propNamePrefix)) { /* * The part URI is in the property name, after the keyPrefix and * the separating dot. */ final URI fullURI = URI.create(props.getProperty(propName)); result.addArtifact(fullURI, propName.substring(propNamePrefix.length())); } } return result; }
/** * Returns the downloadable artifacts object from the specified deployment * context, creating it there if it does not already exist. * @param dc the deployment context from which to fetch the downloadable Artifacts object * @return */ public static Artifacts downloadableArtifacts(final DeploymentContext dc) { return Artifacts.get(dc, DOWNLOADABLE_ARTIFACTS_KEY_PREFIX); }
private String transientAppMetadataKey() { return transientAppMetadataKey(keyPrefix); }
recordFileLocations(appProps); downloadableArtifacts.record(appProps); generatedArtifacts.record(appProps); retrieveArtifacts(context, downloadableArtifacts.getArtifacts(), retrieve, false, name);
/** * Places into the outgoing payload the downloadable artifacts for an application. * @param context the admin command context for the command currently running * @param app the application of interest * @param targetLocalDir the client-specified local directory to receive the downloaded files * @param reportErrorsInTopReport whether to include error indications in the report's top-level */ public static void retrieveArtifacts(final AdminCommandContext context, final Application app, final String targetLocalDir, final boolean reportErrorsInTopReport) { retrieveArtifacts(context, DeploymentUtils.downloadableArtifacts(app).getArtifacts(), targetLocalDir, reportErrorsInTopReport); }
/** * Returns the Artifacts object from the deployment context with the * sepcified key prefix, creating a new one and storing it in the DC if * no matching Artifacts object already exists. * @param dc the deployment context * @param keyPrefix key prefix by which to look up or store the artifacts * @return */ public static Artifacts get( final DeploymentContext dc, final String keyPrefix) { final String key = transientAppMetadataKey(keyPrefix); synchronized (dc) { Artifacts result = dc.getTransientAppMetaData( transientAppMetadataKey(keyPrefix), Artifacts.class); if (result == null) { result = new Artifacts(keyPrefix); dc.addTransientAppMetaData(key, result); } return result; } }
/** * Records the artifacts in the provided Properties object. * * @param props * @throws URISyntaxException */ public synchronized void record( final Properties props) throws URISyntaxException { for (Artifacts.FullAndPartURIs artifactInfo : artifacts) { props.setProperty( propName(artifactInfo.getPart()), propValue(artifactInfo.getFull())); } }
generatedArtifacts.record(deploymentContext);
private String propNamePrefix() { return propNamePrefix(keyPrefix); }
/** * Adds an artifact. * @param full the full URI to the file to be tracked * @param part the (typically) relative URI, expressed as a String, to be * associated with the part */ public synchronized void addArtifact(URI full, String part) { addArtifact(full, URI.create(part)); }
recordFileLocations(appProps); downloadableArtifacts.record(appProps); generatedArtifacts.record(appProps); retrieveArtifacts(context, downloadableArtifacts.getArtifacts(), retrieve, false);
/** * Places into the outgoing payload the downloadable artifacts for an application. * @param context the admin command context for the command currently running * @param app the application of interest * @param targetLocalDir the client-specified local directory to receive the downloaded files * @param reportErrorsInTopReport whether to include error indications in the report's top-level */ public static void retrieveArtifacts(final AdminCommandContext context, final Application app, final String targetLocalDir, final boolean reportErrorsInTopReport) { retrieveArtifacts(context, DeploymentUtils.downloadableArtifacts(app).getArtifacts(), targetLocalDir, reportErrorsInTopReport, app.getName()); }
private String propName(final URI partURI) { return propNamePrefix() + partURI.toASCIIString(); }
/** * Returns the generated artifacts object from the specified deployment * context, creating it there if it does not already exist. * @param app * @return */ public static Artifacts generatedArtifacts(final DeploymentContext dc) { return Artifacts.get(dc, GENERATED_ARTIFACTS_KEY_PREFIX); }
/** * Records the Artifacts object into the specified deployment context. * @param dc the DeploymentContent in which to persist the Artifacts object */ public void record(final DeploymentContext dc) { synchronized (dc) { /* * Note that "addTransientAppMetaData" actually "puts" into a map, * so it's more like a "set" operation. */ dc.addTransientAppMetaData(transientAppMetadataKey(), this); } }
/** * Returns the generated artifacts object derived from the properties * saved with the specified Application * @param app the Application config object with (possibly) properties describing generated artifacts * @return */ public static Artifacts generatedArtifacts(final Application app) { return Artifacts.get(app.getDeployProperties(), GENERATED_ARTIFACTS_KEY_PREFIX); }
/** * Returns the downloadable artifacts object derived from the properties * saved with the specified Application * @param app the Application config object with (possibly) properties describing downloadable artifacts * @return */ public static Artifacts downloadableArtifacts(final Application app) { return Artifacts.get(app.getDeployProperties(), DOWNLOADABLE_ARTIFACTS_KEY_PREFIX); }