]> source.dussan.org Git - archiva.git/commitdiff
* Expanding Proxy / Policy tests.
authorJoakim Erdfelt <joakime@apache.org>
Mon, 16 Apr 2007 00:49:33 +0000 (00:49 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Mon, 16 Apr 2007 00:49:33 +0000 (00:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@529107 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java
archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java

index c9960e186b0dc0b8062e7ad4a61fbc9e0b5d57d3..44c224679fd4bfd97354c378deb0ed66d41acd0d 100644 (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;
         }
 
index 5bd7e78a8299ad02f50dc3b8460a332b0133feda..ff48204567ed4fa71e212e42bd3ebe0928181982 100644 (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;
     }
index 4d08d1a689016ed26c943483ea9219eee693f25d..4e3fb2e5373154eca3c8c4108429e6ec7c2cdf52 100644 (file)
@@ -42,4 +42,9 @@ public class ReleasesPolicy
     {
         return false;
     }
+    
+    protected String getUpdateMode()
+    {
+        return "releases";
+    }
 }
index d78847a80e00e598c856610ef0d1f8895efb70e9..7298c2a0623b75d2c077bd6d68f38c194dbe5e9d 100644 (file)
@@ -42,4 +42,9 @@ public class SnapshotsPolicy
     {
         return true;
     }
+    
+    protected String getUpdateMode()
+    {
+        return "snapshots";
+    }
 }