From: Joakim Erdfelt Date: Mon, 16 Apr 2007 00:49:33 +0000 (+0000) Subject: * Expanding Proxy / Policy tests. X-Git-Tag: archiva-1.0-alpha-1~113^2~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=46fefb7f3eab2e5ef66148e262c3b259c9eb9c30;p=archiva.git * 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 --- diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java index c9960e186..44c224679 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java @@ -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; } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java index 5bd7e78a8..ff4820456 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java @@ -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; } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java index 4d08d1a68..4e3fb2e53 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java @@ -42,4 +42,9 @@ public class ReleasesPolicy { return false; } + + protected String getUpdateMode() + { + return "releases"; + } } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java index d78847a80..7298c2a06 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java @@ -42,4 +42,9 @@ public class SnapshotsPolicy { return true; } + + protected String getUpdateMode() + { + return "snapshots"; + } }