use of org.apache.archiva.policies.DownloadPolicy in project archiva by apache.
the class DefaultRepositoryProxyConnectors method validatePolicies.
/**
* Apply the policies.
*
* @param policies the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
* @param settings the map of settings for the policies to execute. (Map of String policy keys, to String policy
* setting)
* @param request the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, Path)}
* )
* @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, Path)})
* @throws PolicyViolationException
*/
private void validatePolicies(Map<String, ? extends DownloadPolicy> policies, Map<String, String> settings, Properties request, Path localFile) throws PolicyViolationException {
for (Entry<String, ? extends DownloadPolicy> entry : policies.entrySet()) {
// olamy with spring rolehint is now downloadPolicy#hint
// so substring after last # to get the hint as with plexus
String key = StringUtils.substringAfterLast(entry.getKey(), "#");
DownloadPolicy policy = entry.getValue();
String defaultSetting = policy.getDefaultOption();
String setting = StringUtils.defaultString(settings.get(key), defaultSetting);
log.debug("Applying [{}] policy with [{}]", key, setting);
try {
policy.applyPolicy(setting, request, localFile);
} catch (PolicyConfigurationException e) {
log.error(e.getMessage(), e);
}
}
}
Aggregations