From 5e9c6bc3e28a490c023df533d0bb59c089463ba7 Mon Sep 17 00:00:00 2001 From: Arnaud Heritier Date: Thu, 10 May 2007 21:39:56 +0000 Subject: [PATCH] MRM-212 : configure checksum policy for proxied repository git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-0.9@537005 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/mdo/configuration.mdo | 1081 +++++++++-------- .../DefaultConfiguredRepositoryFactory.java | 4 +- .../proxy/DefaultProxyRequestHandler.java | 23 +- .../proxy/ProxyRequestHandlerTest.java | 3 +- .../admin/include/proxiedRepositoryForm.jspf | 13 +- .../WEB-INF/jsp/admin/proxiedRepositories.jsp | 12 +- 6 files changed, 586 insertions(+), 550 deletions(-) diff --git a/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-configuration/src/main/mdo/configuration.mdo index 2893e289c..204fb7b28 100644 --- a/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-configuration/src/main/mdo/configuration.mdo @@ -1,537 +1,548 @@ - - - - configuration - Configuration - - Configuration for the Maven Repository Manager. - - - - package - org.apache.maven.archiva.configuration - - - - - Configuration - 1.0.0 - - - repositories - 1.0.0 - - RepositoryConfiguration - * - - - - proxiedRepositories - 1.0.0 - - ProxiedRepositoryConfiguration - * - - - - syncedRepositories - 1.0.0 - - SyncedRepositoryConfiguration - * - - - - localRepository - 1.0.0 - String - - The location of the local repository. - - - - indexPath - 1.0.0 - String - - The location of the Lucene index to use for the repository. The default is the .index subdirectory of - the repository. - - - - minimalIndexPath - 1.0.0 - String - - The location of the reduced Lucene index to use for the repository. The default is the .small-index - subdirectory of the repository. - - - - dataRefreshCronExpression - 1.0.0 - String - When to run the data refresh task. Default is every 30 mins (translated as every 0 and 30 minute reading of every hour) - 0 0,30 * * * ? + + + + configuration + Configuration + + Configuration for the Maven Repository Manager. + + + + package + org.apache.maven.archiva.configuration + + + + + Configuration + 1.0.0 + + + repositories + 1.0.0 + + RepositoryConfiguration + * + + + + proxiedRepositories + 1.0.0 + + ProxiedRepositoryConfiguration + * + + + + syncedRepositories + 1.0.0 + + SyncedRepositoryConfiguration + * + + + + localRepository + 1.0.0 + String + + The location of the local repository. + + + + indexPath + 1.0.0 + String + + The location of the Lucene index to use for the repository. The default is the .index subdirectory of + the repository. + + + + minimalIndexPath + 1.0.0 + String + + The location of the reduced Lucene index to use for the repository. The default is the .small-index + subdirectory of the repository. + + + + dataRefreshCronExpression + 1.0.0 + String + When to run the data refresh task. Default is every 30 mins (translated as every 0 and 30 minute reading of every hour) + 0 0,30 * * * ? - - proxy - 1.0.0 - - Proxy - - The network proxy to use for outgoing requests. - - - - - 1.0.0 - - - - - - AbstractRepositoryConfiguration - true - 1.0.0 - - - id - 1.0.0 - String - true - - The repository identifier. - - - - name - 1.0.0 - String - true - - The descriptive name of the repository. - - - - layout - 1.0.0 - String - true - - The layout of the repository. Valid values are "default" and "legacy". - - - default - - - - - 1.0.0 - - - - - - AbstractRepositoryConfiguration - RepositoryConfiguration - 1.0.0 - - - urlName - 1.0.0 - String - true - - The URL name for this repository. - Used to create the WebDAV URL for the repository such like - http://hostname.com/repository/${urlName}/ - - - - directory - 1.0.0 - String - true - - The location of the repository to monitor. - - - - includeSnapshots - 1.0.0 - boolean - Whether to include snapshot versions in the discovery process - false - - - indexed - 1.0.0 - boolean - Whether to index the artifacts in this repository. - true - - - blackListPatterns - 1.0.0 - Blacklisted patterns in the discovery process - - String - * - - - - - - AbstractRepositoryConfiguration - ProxiedRepositoryConfiguration - 1.0.0 - - - url - 1.0.0 - String - true - - The URL of the remote repository to proxy. - - - - - managedRepository - 1.0.0 - true - String - - The ID of the managed repository to use as the local storage for proxied artifacts. - - - - snapshotsPolicy - 1.0.0 - String - disabled - - The policy for snapshots: one of disabled, daily, hourly, interval, never - (allow snapshots, but never update once retrieved). - - - - snapshotsInterval - 1.0.0 - int - - The interval in minutes before updating snapshots if the policy is set to 'interval'. - - - - releasesPolicy - 1.0.0 - String - daily - - The policy for releases: one of disabled, daily, hourly, interval, never - (allow releases, but never update once retrieved). - - - - releasesInterval - 1.0.0 - int - - The interval in minutes before updating releases if the policy is set to 'interval'. - - - - useNetworkProxy - 1.0.0 - boolean - false - - Whether to use the network proxy, if one is configured for the protocol of this repository. - - - - cacheFailures - 1.0.0 - boolean - false - - Whether to cache failures to avoid re-attempting them over the network. The cache will last for the duration - of the intervals specified above depending on whether it a release or snapshot. - - - - hardFail - 1.0.0 - boolean - false - - Whether to cause the entire request to fail if attempts to retrieve from this proxy fail. - - - - - - AbstractRepositoryConfiguration - SyncedRepositoryConfiguration - true - 1.0.0 - - - - managedRepository - 1.0.0 - true - String - - The ID of the managed repository to use as the local storage for proxied artifacts. - - - - cronExpression - 1.0.0 - String - When to run the sync mechanism. Default is every hour on the hour. - 0 0 * * * ? - - - method - 1.0.0 - String - The type of synchronization to use. - rsync - - - properties - 1.0.0 - Properties - Configuration for the repository synchronization. - - String - * - - - - - - Proxy - 1.0.0 - - - protocol - 1.0.0 - - String - http - - - username - 1.0.0 - - String - - - password - 1.0.0 - - String - - - port - 1.0.0 - - int - 8080 - - - host - 1.0.0 - - String - true - - - nonProxyHosts - 1.0.0 - - String - - - - - - - + + globalBlackListPatterns + 1.0.0 + Blacklisted patterns in the discovery process + + String + * + + + --> + + proxy + 1.0.0 + + Proxy + + The network proxy to use for outgoing requests. + + + + + 1.0.0 + + + + + + AbstractRepositoryConfiguration + true + 1.0.0 + + + id + 1.0.0 + String + true + + The repository identifier. + + + + name + 1.0.0 + String + true + + The descriptive name of the repository. + + + + layout + 1.0.0 + String + true + + The layout of the repository. Valid values are "default" and "legacy". + + + default + + + + + 1.0.0 + + + + + + AbstractRepositoryConfiguration + RepositoryConfiguration + 1.0.0 + + + urlName + 1.0.0 + String + true + + The URL name for this repository. + Used to create the WebDAV URL for the repository such like - http://hostname.com/repository/${urlName}/ + + + + directory + 1.0.0 + String + true + + The location of the repository to monitor. + + + + includeSnapshots + 1.0.0 + boolean + Whether to include snapshot versions in the discovery process + false + + + indexed + 1.0.0 + boolean + Whether to index the artifacts in this repository. + true + + + blackListPatterns + 1.0.0 + Blacklisted patterns in the discovery process + + String + * + + + + + + AbstractRepositoryConfiguration + ProxiedRepositoryConfiguration + 1.0.0 + + + url + 1.0.0 + String + true + + The URL of the remote repository to proxy. + + + + + managedRepository + 1.0.0 + true + String + + The ID of the managed repository to use as the local storage for proxied artifacts. + + + + snapshotsPolicy + 1.0.0 + String + disabled + + The policy for snapshots: one of disabled, daily, hourly, interval, never + (allow snapshots, but never update once retrieved). + + + + snapshotsInterval + 1.0.0 + int + + The interval in minutes before updating snapshots if the policy is set to 'interval'. + + + + releasesPolicy + 1.0.0 + String + daily + + The policy for releases: one of disabled, daily, hourly, interval, never + (allow releases, but never update once retrieved). + + + + checksumPolicy + 1.0.0 + String + fail + + The policy for checksum: one of fail, warn, ignore. + + + + releasesInterval + 1.0.0 + int + + The interval in minutes before updating releases if the policy is set to 'interval'. + + + + useNetworkProxy + 1.0.0 + boolean + false + + Whether to use the network proxy, if one is configured for the protocol of this repository. + + + + cacheFailures + 1.0.0 + boolean + false + + Whether to cache failures to avoid re-attempting them over the network. The cache will last for the duration + of the intervals specified above depending on whether it a release or snapshot. + + + + hardFail + 1.0.0 + boolean + false + + Whether to cause the entire request to fail if attempts to retrieve from this proxy fail. + + + + + + AbstractRepositoryConfiguration + SyncedRepositoryConfiguration + true + 1.0.0 + + + + managedRepository + 1.0.0 + true + String + + The ID of the managed repository to use as the local storage for proxied artifacts. + + + + cronExpression + 1.0.0 + String + When to run the sync mechanism. Default is every hour on the hour. + 0 0 * * * ? + + + method + 1.0.0 + String + The type of synchronization to use. + rsync + + + properties + 1.0.0 + Properties + Configuration for the repository synchronization. + + String + * + + + + + + Proxy + 1.0.0 + + + protocol + 1.0.0 + + String + http + + + username + 1.0.0 + + String + + + password + 1.0.0 + + String + + + port + 1.0.0 + + int + 8080 + + + host + 1.0.0 + + String + true + + + nonProxyHosts + 1.0.0 + + String + + + + + + + + + diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/configuration/DefaultConfiguredRepositoryFactory.java b/archiva-core/src/main/java/org/apache/maven/archiva/configuration/DefaultConfiguredRepositoryFactory.java index 4c7e05e5a..ce44f9e4e 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/configuration/DefaultConfiguredRepositoryFactory.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/configuration/DefaultConfiguredRepositoryFactory.java @@ -62,12 +62,12 @@ public class DefaultConfiguredRepositoryFactory String updatePolicy = getUpdatePolicy( configuration.getSnapshotsPolicy(), configuration.getSnapshotsInterval() ); ArtifactRepositoryPolicy snapshotsPolicy = - new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); + new ArtifactRepositoryPolicy( enabled, updatePolicy, configuration.getChecksumPolicy() ); enabled = isEnabled( configuration.getReleasesPolicy() ); updatePolicy = getUpdatePolicy( configuration.getReleasesPolicy(), configuration.getReleasesInterval() ); ArtifactRepositoryPolicy releasesPolicy = - new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); + new ArtifactRepositoryPolicy( enabled, updatePolicy, configuration.getChecksumPolicy() ); ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() ); diff --git a/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultProxyRequestHandler.java b/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultProxyRequestHandler.java index a22fdb872..9ebb457af 100644 --- a/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultProxyRequestHandler.java +++ b/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultProxyRequestHandler.java @@ -545,7 +545,7 @@ public class DefaultProxyRequestHandler if ( downloaded ) { - success = checkChecksum( checksums, path, wagon, repositoryCachePath ); + success = checkChecksum( checksums, path, wagon, repositoryCachePath, policy ); if ( tries > 1 && !success ) { @@ -671,11 +671,15 @@ public class DefaultProxyRequestHandler return connected; } - private boolean checkChecksum( Map checksumMap, String path, Wagon wagon, String repositoryCachePath ) + private boolean checkChecksum( Map checksumMap, String path, Wagon wagon, String repositoryCachePath, ArtifactRepositoryPolicy policy ) throws ProxyException { releaseChecksumListeners( wagon, checksumMap ); - + + // Ignore checksum errors. Returns always true. + if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( policy.getChecksumPolicy() ) ) + return true; + boolean correctChecksum = false; boolean allNotFound = true; @@ -713,7 +717,8 @@ public class DefaultProxyRequestHandler else { getLogger().warn( - "The checksum '" + actualChecksum + "' did not match the remote value: " + remoteChecksum ); + "The checksum '" + actualChecksum + "' did not match the remote value: " + + remoteChecksum ); } } catch ( TransferFailedException e ) @@ -759,7 +764,15 @@ public class DefaultProxyRequestHandler tempChecksumFile.delete(); } } - return correctChecksum || allNotFound; + if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN.equals( policy.getChecksumPolicy() ) ) + { + // We are only interested to the warnings. The result is always true. + return true; + } + else + { + return correctChecksum || allNotFound; + } } /** diff --git a/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java b/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java index 0bd15b1d7..d9eee6e40 100644 --- a/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java +++ b/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ProxyRequestHandlerTest.java @@ -100,7 +100,8 @@ public class ProxyRequestHandlerTest requestHandler = (ProxyRequestHandler) lookup( ProxyRequestHandler.ROLE ); factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - + factory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); + File repoLocation = getTestFile( "target/test-repository/managed" ); // faster only to delete this one before copying, the others are done case by case FileUtils.deleteDirectory( new File( repoLocation, "org/apache/maven/test/get-merged-metadata" ) ); diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf index ba6a76452..da18fe3e1 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf @@ -34,9 +34,10 @@ 'daily' : 'Enabled, updated daily', 'hourly' : 'Enabled, updated hourly', 'never' : 'Enabled, never updated', - 'interval' : 'Enabled, updated on given interval'}"/> - - - - - + 'interval' : 'Enabled, updated on given interval'}" /> + + + + + + diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp index de6479873..751881bc8 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp @@ -106,6 +106,16 @@ (${repositoriesMap[repository.managedRepository].id}) + + Checksum policy + + + Failure + Warning + Ignore + + + Use HTTP Proxy @@ -124,4 +134,4 @@ - \ No newline at end of file + -- 2.39.5