]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1102] clean up layout exceptions
authorBrett Porter <brett@apache.org>
Tue, 10 Mar 2009 01:35:35 +0000 (01:35 +0000)
committerBrett Porter <brett@apache.org>
Tue, 10 Mar 2009 01:35:35 +0000 (01:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@751940 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/MetadataUpdaterConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurge.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ManagedRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractDefaultRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContent.java

index 4f21ff1b5600c20e7901f70888ce47e5ec0a5961..e40bb8d27a9358cbb4f24504a7a3052bfd0d5f3e 100644 (file)
@@ -160,19 +160,19 @@ public class MetadataUpdaterConsumer
     public void processFile( String path )
         throws ConsumerException
     {
-        //Ignore paths like .indexer etc
-        if (path.startsWith("."))
-            return;
-
-        try
-        {
-            ArtifactReference artifact = repository.toArtifactReference( path );
-            updateVersionMetadata( artifact, path );
-            updateProjectMetadata( artifact, path );
-        }
-        catch ( LayoutException e )
+        // Ignore paths like .indexer etc
+        if ( !path.startsWith( "." ) )
         {
-            throw new ConsumerException( "Unable to convert to artifact reference: " + path, e );
+            try
+            {
+                ArtifactReference artifact = repository.toArtifactReference( path );
+                updateVersionMetadata( artifact, path );
+                updateProjectMetadata( artifact, path );
+            }
+            catch ( LayoutException e )
+            {
+                log.info( "Not processing path that is not an artifact: " + path + " (" + e.getMessage() + ")" );
+            }
         }
     }
 
index 545f62f8649aaf46dd6577af292dbcfe88d52ce3..46b0e9b121cfacc57f589a1335ca7fb92491fde5 100644 (file)
@@ -28,6 +28,8 @@ import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.events.RepositoryListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Base class for all repository purge tasks.
@@ -36,6 +38,8 @@ import org.apache.maven.archiva.repository.events.RepositoryListener;
 public abstract class AbstractRepositoryPurge
     implements RepositoryPurge
 {
+    protected Logger log = LoggerFactory.getLogger( AbstractRepositoryPurge.class );
+
     protected final ManagedRepositoryContent repository;
     
        protected final List<RepositoryListener> listeners;
index e5a7aef92fc953742709a8f2101278d108571440..bdca2646efe168ee06e1a33d7a2e73c5de91393f 100644 (file)
@@ -135,14 +135,14 @@ public class DaysOldRepositoryPurge
                 }
             }
         }
-        catch ( LayoutException le )
-        {
-            throw new RepositoryPurgeException( le.getMessage(), le );
-        }
         catch ( ContentNotFoundException e )
         {
             throw new RepositoryPurgeException( e.getMessage(), e );
         }
+        catch ( LayoutException e )
+        {
+            log.debug( "Not processing file that is not an artifact: " + e.getMessage() );
+        }
     }
 
     private Calendar uniqueSnapshotToCalendar( String version )
@@ -179,7 +179,6 @@ public class DaysOldRepositoryPurge
     }
 
     private void doPurgeAllRelated( ArtifactReference reference )
-        throws LayoutException
     {
         try
         {
@@ -188,8 +187,8 @@ public class DaysOldRepositoryPurge
         }
         catch ( ContentNotFoundException e )
         {
-            // Nothing to do here.
-            // TODO: Log this?
+            // Nothing to do here - it means the repository would have been constructed incorrectly
+            log.debug( e.getMessage(), e );
         }
     }
 }
index 5d5588b076459fc25f16b0c0bd75812ddb4f020c..1401133717fd29a91c42893bc9a9c7d4f3a393d2 100644 (file)
@@ -77,7 +77,7 @@ public interface ManagedRepositoryContent
      * @throws LayoutException 
      */
     public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
-        throws ContentNotFoundException, LayoutException;
+        throws ContentNotFoundException;
 
     /**
      * <p>
@@ -128,7 +128,7 @@ public interface ManagedRepositoryContent
      * @throws LayoutException 
      */
     public Set<String> getVersions( VersionedReference reference )
-        throws ContentNotFoundException, LayoutException;
+        throws ContentNotFoundException;
 
     /**
      * Determines if the artifact referenced exists in the repository.
index b0e91c3b0f0e37200c42d1a2c2d671530fb3ddab..3428070355c5a4e895d8e11e845b942fd445c1cd 100644 (file)
@@ -26,6 +26,8 @@ import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
 import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
@@ -34,6 +36,8 @@ import org.apache.maven.archiva.repository.layout.LayoutException;
  */
 public abstract class AbstractDefaultRepositoryContent
 {
+    protected Logger log = LoggerFactory.getLogger( AbstractDefaultRepositoryContent.class );
+
     public static final String MAVEN_METADATA = "maven-metadata.xml";
 
     protected static final char PATH_SEPARATOR = '/';
index a19cfa76303fb7d5dd607bc6a7125ebf5ab55505..242d1413a4836d7e0e6f176dd67a581e8c605bbe 100644 (file)
@@ -19,6 +19,11 @@ package org.apache.maven.archiva.repository.content;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.configuration.FileTypes;
@@ -31,11 +36,6 @@ import org.apache.maven.archiva.repository.ContentNotFoundException;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * ManagedDefaultRepositoryContent 
  *
@@ -89,7 +89,7 @@ public class ManagedDefaultRepositoryContent
     }
 
     public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
-        throws ContentNotFoundException, LayoutException
+        throws ContentNotFoundException
     {
         File artifactFile = toFile( reference );
         File repoDir = artifactFile.getParentFile();
@@ -122,14 +122,21 @@ public class ManagedDefaultRepositoryContent
 
             if ( filetypes.matchesArtifactPattern( relativePath ) )
             {
-                ArtifactReference artifact = toArtifactReference( relativePath );
-                
-                // Test for related, groupId / artifactId / version must match.
-                if ( artifact.getGroupId().equals( reference.getGroupId() )
-                    && artifact.getArtifactId().equals( reference.getArtifactId() )
-                    && artifact.getVersion().equals( reference.getVersion() ) )
+                try
+                {
+                    ArtifactReference artifact = toArtifactReference( relativePath );
+                    
+                    // Test for related, groupId / artifactId / version must match.
+                    if ( artifact.getGroupId().equals( reference.getGroupId() )
+                        && artifact.getArtifactId().equals( reference.getArtifactId() )
+                        && artifact.getVersion().equals( reference.getVersion() ) )
+                    {
+                        foundArtifacts.add( artifact );
+                    }
+                }
+                catch ( LayoutException e )
                 {
-                    foundArtifacts.add( artifact );
+                    log.debug( "Not processing file that is not an artifact: " + e.getMessage() );
                 }
             }
         }
@@ -209,7 +216,7 @@ public class ManagedDefaultRepositoryContent
     }
 
     public Set<String> getVersions( VersionedReference reference )
-        throws ContentNotFoundException, LayoutException
+        throws ContentNotFoundException
     {
         String path = toMetadataPath( reference );
 
@@ -255,9 +262,16 @@ public class ManagedDefaultRepositoryContent
 
             if ( filetypes.matchesArtifactPattern( relativePath ) )
             {
-                ArtifactReference artifact = toArtifactReference( relativePath );
-
-                foundVersions.add( artifact.getVersion() );
+                try
+                {
+                    ArtifactReference artifact = toArtifactReference( relativePath );
+    
+                    foundVersions.add( artifact.getVersion() );
+                }
+                catch ( LayoutException e )
+                {
+                    log.debug( "Not processing file that is not an artifact: " + e.getMessage() );
+                }
             }
         }
 
index c6237bb0feb69481191bd60dbe2ca40f4a746a3e..ba98e445e2e957e1bee060fb66dfc0b96bac9f1b 100644 (file)
@@ -151,7 +151,7 @@ public class ManagedLegacyRepositoryContent
     }
 
     public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
-        throws ContentNotFoundException, LayoutException
+        throws ContentNotFoundException
     {
         File artifactFile = toFile( reference );
         File repoDir = artifactFile.getParentFile();