Browse Source

* Expanding Proxy / Policy tests.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@529107 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.0-alpha-1
Joakim Erdfelt 17 years ago
parent
commit
46fefb7f3e

+ 22
- 20
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java View File

@@ -88,62 +88,64 @@ public abstract class AbstractUpdatePolicy
}

protected abstract boolean isSnapshotPolicy();
protected abstract String getUpdateMode();

public boolean applyPolicy( String policySetting, Properties request, File localFile )
{
String version = request.getProperty( "version", "" );
boolean isSnapshotVersion = false;
if( StringUtils.isNotBlank( version ) )
if ( StringUtils.isNotBlank( version ) )
{
isSnapshotVersion = VersionUtil.isSnapshot( version );
}

// Test for mismatches.
if ( !isSnapshotVersion && isSnapshotPolicy() )
if ( !validPolicyCodes.contains( policySetting ) )
{
getLogger().debug( "Non-snapshot version detected in during snapshot policy. ignoring policy.");
return true;
// No valid code? false it is then.
getLogger().error( "Unknown artifact-update policyCode [" + policySetting + "]" );
return false;
}
if ( isSnapshotVersion && !isSnapshotPolicy() )
if ( IGNORED.equals( policySetting ) )
{
getLogger().debug( "Snapshot version detected in during release policy. ignoring policy.");
// Ignored means ok to update.
getLogger().debug( "OK to update, " + getUpdateMode() + " policy set to IGNORED." );
return true;
}

if ( !validPolicyCodes.contains( policySetting ) )
// Test for mismatches.
if ( !isSnapshotVersion && isSnapshotPolicy() )
{
// No valid code? false it is then.
getLogger().error( "Unknown artifact-update policyCode [" + policySetting + "]" );
return false;
getLogger().debug( "OK to update, snapshot policy does not apply for non-snapshot versions." );
return true;
}
if ( IGNORED.equals( policySetting ) )
if ( isSnapshotVersion && !isSnapshotPolicy() )
{
// Disabled means no.
getLogger().debug( "OK to update, policy ignored." );
getLogger().debug( "OK to update, release policy does not apply for snapshot versions." );
return true;
}

if ( DISABLED.equals( policySetting ) )
{
// Disabled means no.
getLogger().debug( "NO to update, disabled." );
getLogger().debug( "NO to update, " + getUpdateMode() + " policy set to DISABLED." );
return false;
}

if ( !localFile.exists() )
{
// No file means it's ok.
getLogger().debug( "OK to update, local file does not exist." );
getLogger().debug( "OK to update " + getUpdateMode() + ", local file does not exist." );
return true;
}

if ( ONCE.equals( policySetting ) )
{
// File exists, but policy is once.
getLogger().debug( "NO to update, local file exist (and policy is ONCE)." );
getLogger().debug( "NO to update" + getUpdateMode() + ", local file exist (and policy is ONCE)." );
return false;
}


+ 4
- 0
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java View File

@@ -73,6 +73,7 @@ public class CachedFailuresPolicy
if ( IGNORED.equals( policySetting ) )
{
// Ignore.
getLogger().debug( "OK to fetch, check-failures policy set to IGNORED." );
return true;
}

@@ -82,9 +83,12 @@ public class CachedFailuresPolicy
{
if ( urlFailureCache.hasFailedBefore( url ) )
{
getLogger().debug( "NO to fetch, check-failures detected previous failure on url: " + url );
return false;
}
}
getLogger().debug( "OK to fetch, check-failures detected no issues." );

return true;
}

+ 5
- 0
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java View File

@@ -42,4 +42,9 @@ public class ReleasesPolicy
{
return false;
}
protected String getUpdateMode()
{
return "releases";
}
}

+ 5
- 0
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java View File

@@ -42,4 +42,9 @@ public class SnapshotsPolicy
{
return true;
}
protected String getUpdateMode()
{
return "snapshots";
}
}

Loading…
Cancel
Save