]> source.dussan.org Git - archiva.git/commitdiff
MRM-1311: Added Loggers to core consumers 5/head
authorJonathan Sharp <forjsharp@gmail.com>
Mon, 29 Sep 2014 21:46:01 +0000 (14:46 -0700)
committerJonathan Sharp <forjsharp@gmail.com>
Mon, 29 Sep 2014 21:46:01 +0000 (14:46 -0700)
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java

index 50efbd93695ddd79e1197c5dfd2e5a4c46ddf49c..e04d744220eb09f8d98205bc1c4f50e88558e3ab 100644 (file)
@@ -32,6 +32,8 @@ import org.apache.archiva.redback.components.registry.Registry;
 import org.apache.archiva.redback.components.registry.RegistryListener;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
@@ -54,6 +56,9 @@ public class ArtifactMissingChecksumsConsumer
     // it's prototype bean so we assume configuration won't change during a run
     //, RegistryListener
 {
+
+    private Logger log = LoggerFactory.getLogger( ArtifactMissingChecksumsConsumer.class );
+
     private String id = "create-missing-checksums";
 
     private String description = "Create Missing and/or Fix Invalid Checksums (.sha1, .md5)";
@@ -169,11 +174,13 @@ public class ArtifactMissingChecksumsConsumer
                 if ( !checksum.isValidChecksum( checksumAlgorithm[0] ) )
                 {
                     checksum.fixChecksums( checksumAlgorithm );
+                    log.info( "Fixed checksum file {}", checksumFile.getAbsolutePath() );
                     triggerConsumerInfo( "Fixed checksum file " + checksumFile.getAbsolutePath() );
                 }
             }
             catch ( IOException e )
             {
+                log.error( "Cannot calculate checksum for file {} :", checksumFile, e );
                 triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC, "Cannot calculate checksum for file " + checksumFile +
                     ": " + e.getMessage() );
             }
@@ -184,16 +191,19 @@ public class ArtifactMissingChecksumsConsumer
             try
             {
                 checksum.createChecksum( checksumAlgorithm[0] );
+                log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath() ); 
                 triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() );
             }
             catch ( IOException e )
             {
+                log.error( "Cannot create checksum for file {} :", checksumFile, e );
                 triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE, "Cannot create checksum for file " + checksumFile +
                     ": " + e.getMessage() );
             }
         }
         else
         {
+            log.warn( "Checksum file {} is not a file. ", checksumFile.getAbsolutePath() );
             triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE,
                                     "Checksum file " + checksumFile.getAbsolutePath() + " is not a file." );
         }
index d6e929779469e73749ca1919cd1b16d01ca8120f..3c9c7507c55f60beb506a518136ed0b3dd966456 100644 (file)
@@ -30,6 +30,8 @@ import org.apache.archiva.redback.components.registry.Registry;
 import org.apache.archiva.redback.components.registry.RegistryListener;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
@@ -49,6 +51,9 @@ public class AutoRemoveConsumer
     extends AbstractMonitoredConsumer
     implements KnownRepositoryContentConsumer, RegistryListener
 {
+
+    private Logger log = LoggerFactory.getLogger( AutoRemoveConsumer.class );
+
     /**
      * default-value="auto-remove"
      */
@@ -138,6 +143,7 @@ public class AutoRemoveConsumer
         File file = new File( this.repositoryDir, path );
         if ( file.exists() )
         {
+            log.info( "(Auto) Removing File: {}", file.getAbsolutePath() );
             triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath() );
             file.delete();
         }
index 554d0287bd092ceef017c58d13386f19fa568b82..d42cbcff7175b1708770f5a6c836d99a0ce3eb03 100644 (file)
@@ -26,6 +26,8 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.commons.io.FileUtils;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.IOException;
@@ -47,6 +49,8 @@ public class AutoRenameConsumer
     extends AbstractMonitoredConsumer
     implements KnownRepositoryContentConsumer
 {
+    private Logger log = LoggerFactory.getLogger( AutoRenameConsumer.class ); 
+
     private String id = "auto-rename";
 
     private String description = "Automatically rename common artifact mistakes.";
@@ -149,12 +153,14 @@ public class AutoRenameConsumer
                     }
                     catch ( IOException e )
                     {
+                        log.warn( "Unable to rename {} to {} :", path, correctedPath, e );
                         triggerConsumerWarning( RENAME_FAILURE, "Unable to rename " + path + " to " + correctedPath +
                             ": " + e.getMessage() );
                     }
                 }
             }
 
+            log.info( "(Auto) Removing File: {} ", file.getAbsolutePath() );
             triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath() );
             file.delete();
         }
index 8e234839ef6a1186eeb06020d922e83f582410f9..2f2ca6d296571cdd54d8f336faf60636f83810dd 100644 (file)
@@ -219,22 +219,26 @@ public class MetadataUpdaterConsumer
         }
         catch ( LayoutException e )
         {
+            log.warn( "Unable to convert path [{}] to an internal project reference: ", path, e );
             triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
                                     "Unable to convert path [" + path + "] to an internal project reference: "
                                         + e.getMessage() );
         }
         catch ( RepositoryMetadataException e )
         {
+            log.error( "Unable to write project metadat for artifact [{}]:", path, e );
             triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
                                   "Unable to write project metadata for artifact [" + path + "]: " + e.getMessage() );
         }
         catch ( IOException e )
         {
+            log.warn( "Project metadata not written due to IO warning: ", e );
             triggerConsumerWarning( TYPE_METADATA_IO,
                                     "Project metadata not written due to IO warning: " + e.getMessage() );
         }
         catch ( ContentNotFoundException e )
         {
+            log.warn( "Project metadata not written because no versions were found to update: ", e );
             triggerConsumerWarning( TYPE_METADATA_IO,
                                     "Project metadata not written because no versions were found to update: "
                                         + e.getMessage() );
@@ -266,22 +270,26 @@ public class MetadataUpdaterConsumer
         }
         catch ( LayoutException e )
         {
+            log.warn( "Unable to convert path [{}] to an internal version reference: ", path, e );
             triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
                                     "Unable to convert path [" + path + "] to an internal version reference: "
                                         + e.getMessage() );
         }
         catch ( RepositoryMetadataException e )
         {
+            log.error( "Unable to write version metadata for artifact [{}]: ", path, e ); 
             triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
                                   "Unable to write version metadata for artifact [" + path + "]: " + e.getMessage() );
         }
         catch ( IOException e )
         {
+            log.warn( "Version metadata not written due to IO warning: ", e );
             triggerConsumerWarning( TYPE_METADATA_IO,
                                     "Version metadata not written due to IO warning: " + e.getMessage() );
         }
         catch ( ContentNotFoundException e )
         {
+            log.warn( "Version metadata not written because no versions were found to update: ", e ); 
             triggerConsumerWarning( TYPE_METADATA_IO,
                                     "Version metadata not written because no versions were found to update: "
                                         + e.getMessage() );
index 07f108c3007efbdd589c49a62cdc14ac1bb33d9d..35e8bd5f960d36e66778f69a59d099b2475333a6 100644 (file)
@@ -31,6 +31,8 @@ import org.codehaus.plexus.digest.Digester;
 import org.codehaus.plexus.digest.DigesterException;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
@@ -52,6 +54,8 @@ public class ValidateChecksumConsumer
     extends AbstractMonitoredConsumer
     implements KnownRepositoryContentConsumer
 {
+    private Logger log = LoggerFactory.getLogger( ValidateChecksumConsumer.class );
+
     private static final String NOT_VALID_CHECKSUM = "checksum-not-valid";
 
     private static final String CHECKSUM_NOT_FOUND = "checksum-not-found";
@@ -143,20 +147,24 @@ public class ValidateChecksumConsumer
         {
             if ( !checksum.isValidChecksum( checksumFile ) )
             {
+                log.warn( "The checksum for {} is invalid.", checksumFile );
                 triggerConsumerWarning( NOT_VALID_CHECKSUM, "The checksum for " + checksumFile + " is invalid." );
             }
         }
         catch ( FileNotFoundException e )
         {
+            log.error( "File not found during checksum validation: ", e );
             triggerConsumerError( CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage() );
         }
         catch ( DigesterException e )
         {
+            log.error( "Digester failure during checksum validation on {}", checksumFile );
             triggerConsumerError( CHECKSUM_DIGESTER_FAILURE,
                                   "Digester failure during checksum validation on " + checksumFile );
         }
         catch ( IOException e )
         {
+            log.error( "Checksum I/O error during validation on {}", checksumFile );
             triggerConsumerError( CHECKSUM_IO_ERROR, "Checksum I/O error during validation on " + checksumFile );
         }
     }