mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
df01e22805
commit
5e9c6bc3e2
|
@ -404,6 +404,15 @@
|
|||
(allow releases, but never update once retrieved).
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<defaultValue>fail</defaultValue>
|
||||
<description>
|
||||
The policy for checksum: one of fail, warn, ignore.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>releasesInterval</name>
|
||||
<version>1.0.0</version>
|
||||
|
@ -535,3 +544,5 @@
|
|||
</model>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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() );
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -100,6 +100,7 @@ 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
|
||||
|
|
|
@ -34,9 +34,10 @@
|
|||
'daily' : 'Enabled, updated daily',
|
||||
'hourly' : 'Enabled, updated hourly',
|
||||
'never' : 'Enabled, never updated',
|
||||
'interval' : 'Enabled, updated on given interval'}"/>
|
||||
<ww:textfield label="Release update interval" name="releasesInterval" size="4"/>
|
||||
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through"/>
|
||||
<ww:checkbox name="useNetworkProxy" fieldValue="true" label="Use HTTP Proxy"/>
|
||||
<ww:checkbox name="cacheFailures" fieldValue="true" label="Cache Failures"/>
|
||||
<ww:checkbox name="hardFail" fieldValue="true" label="Fail Whole Group"/>
|
||||
'interval' : 'Enabled, updated on given interval'}" />
|
||||
<ww:textfield label="Release update interval" name="releasesInterval" size="4" />
|
||||
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through" />
|
||||
<ww:radio list="#@java.util.LinkedHashMap@{'fail' : 'Failure', 'warn' : 'Warning', 'ignore' : 'Ignore'}" name="checksumPolicy" label="Checksum Policy"/>
|
||||
<ww:checkbox name="useNetworkProxy" fieldValue="true" label="Use HTTP Proxy" />
|
||||
<ww:checkbox name="cacheFailures" fieldValue="true" label="Cache Failures" />
|
||||
<ww:checkbox name="hardFail" fieldValue="true" label="Fail Whole Group" />
|
||||
|
|
|
@ -106,6 +106,16 @@
|
|||
(<code>${repositoriesMap[repository.managedRepository].id}</code>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Checksum policy</th>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${repository.checksumPolicy == 'fail'}">Failure</c:when>
|
||||
<c:when test="${repository.checksumPolicy == 'warn'}">Warning</c:when>
|
||||
<c:otherwise>Ignore</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Use HTTP Proxy</th>
|
||||
<td class="${repository.useNetworkProxy ? 'donemark' : 'errormark'} booleanIcon"></td>
|
||||
|
|
Loading…
Reference in New Issue