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
File diff suppressed because it is too large
Load Diff
|
@ -62,12 +62,12 @@ public class DefaultConfiguredRepositoryFactory
|
||||||
String updatePolicy =
|
String updatePolicy =
|
||||||
getUpdatePolicy( configuration.getSnapshotsPolicy(), configuration.getSnapshotsInterval() );
|
getUpdatePolicy( configuration.getSnapshotsPolicy(), configuration.getSnapshotsInterval() );
|
||||||
ArtifactRepositoryPolicy snapshotsPolicy =
|
ArtifactRepositoryPolicy snapshotsPolicy =
|
||||||
new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
new ArtifactRepositoryPolicy( enabled, updatePolicy, configuration.getChecksumPolicy() );
|
||||||
|
|
||||||
enabled = isEnabled( configuration.getReleasesPolicy() );
|
enabled = isEnabled( configuration.getReleasesPolicy() );
|
||||||
updatePolicy = getUpdatePolicy( configuration.getReleasesPolicy(), configuration.getReleasesInterval() );
|
updatePolicy = getUpdatePolicy( configuration.getReleasesPolicy(), configuration.getReleasesInterval() );
|
||||||
ArtifactRepositoryPolicy releasesPolicy =
|
ArtifactRepositoryPolicy releasesPolicy =
|
||||||
new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
new ArtifactRepositoryPolicy( enabled, updatePolicy, configuration.getChecksumPolicy() );
|
||||||
|
|
||||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() );
|
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() );
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,7 @@ public class DefaultProxyRequestHandler
|
||||||
|
|
||||||
if ( downloaded )
|
if ( downloaded )
|
||||||
{
|
{
|
||||||
success = checkChecksum( checksums, path, wagon, repositoryCachePath );
|
success = checkChecksum( checksums, path, wagon, repositoryCachePath, policy );
|
||||||
|
|
||||||
if ( tries > 1 && !success )
|
if ( tries > 1 && !success )
|
||||||
{
|
{
|
||||||
|
@ -671,11 +671,15 @@ public class DefaultProxyRequestHandler
|
||||||
return connected;
|
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
|
throws ProxyException
|
||||||
{
|
{
|
||||||
releaseChecksumListeners( wagon, checksumMap );
|
releaseChecksumListeners( wagon, checksumMap );
|
||||||
|
|
||||||
|
// Ignore checksum errors. Returns always true.
|
||||||
|
if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( policy.getChecksumPolicy() ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
boolean correctChecksum = false;
|
boolean correctChecksum = false;
|
||||||
|
|
||||||
boolean allNotFound = true;
|
boolean allNotFound = true;
|
||||||
|
@ -713,7 +717,8 @@ public class DefaultProxyRequestHandler
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
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 )
|
catch ( TransferFailedException e )
|
||||||
|
@ -759,7 +764,15 @@ public class DefaultProxyRequestHandler
|
||||||
tempChecksumFile.delete();
|
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,7 +100,8 @@ public class ProxyRequestHandlerTest
|
||||||
requestHandler = (ProxyRequestHandler) lookup( ProxyRequestHandler.ROLE );
|
requestHandler = (ProxyRequestHandler) lookup( ProxyRequestHandler.ROLE );
|
||||||
|
|
||||||
factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||||
|
factory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
||||||
|
|
||||||
File repoLocation = getTestFile( "target/test-repository/managed" );
|
File repoLocation = getTestFile( "target/test-repository/managed" );
|
||||||
// faster only to delete this one before copying, the others are done case by case
|
// 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" ) );
|
FileUtils.deleteDirectory( new File( repoLocation, "org/apache/maven/test/get-merged-metadata" ) );
|
||||||
|
|
|
@ -34,9 +34,10 @@
|
||||||
'daily' : 'Enabled, updated daily',
|
'daily' : 'Enabled, updated daily',
|
||||||
'hourly' : 'Enabled, updated hourly',
|
'hourly' : 'Enabled, updated hourly',
|
||||||
'never' : 'Enabled, never updated',
|
'never' : 'Enabled, never updated',
|
||||||
'interval' : 'Enabled, updated on given interval'}"/>
|
'interval' : 'Enabled, updated on given interval'}" />
|
||||||
<ww:textfield label="Release update interval" name="releasesInterval" size="4"/>
|
<ww:textfield label="Release update interval" name="releasesInterval" size="4" />
|
||||||
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through"/>
|
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through" />
|
||||||
<ww:checkbox name="useNetworkProxy" fieldValue="true" label="Use HTTP Proxy"/>
|
<ww:radio list="#@java.util.LinkedHashMap@{'fail' : 'Failure', 'warn' : 'Warning', 'ignore' : 'Ignore'}" name="checksumPolicy" label="Checksum Policy"/>
|
||||||
<ww:checkbox name="cacheFailures" fieldValue="true" label="Cache Failures"/>
|
<ww:checkbox name="useNetworkProxy" fieldValue="true" label="Use HTTP Proxy" />
|
||||||
<ww:checkbox name="hardFail" fieldValue="true" label="Fail Whole Group"/>
|
<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>)
|
(<code>${repositoriesMap[repository.managedRepository].id}</code>)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<th>Use HTTP Proxy</th>
|
<th>Use HTTP Proxy</th>
|
||||||
<td class="${repository.useNetworkProxy ? 'donemark' : 'errormark'} booleanIcon"></td>
|
<td class="${repository.useNetworkProxy ? 'donemark' : 'errormark'} booleanIcon"></td>
|
||||||
|
@ -124,4 +134,4 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue