]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1163] Add some decent logs in webdav for debugging purposes
authorMaria Odea B. Ching <oching@apache.org>
Wed, 29 Jul 2009 09:55:18 +0000 (09:55 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Wed, 29 Jul 2009 09:55:18 +0000 (09:55 +0000)
Submitted by: Jevica Arianne Zurbano
o added debug logs in ArchivaDavResource and ArchivaDavResourceFactory with the filename, directory, repository, and/or current user included in logs

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@798827 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/resources/log4j.xml
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java

index cc0aa6a40fd78a95d83f1c09dae2444b741ae610..a89a9cafbe4f3719e97d1bf96b61ec0021d8c14e 100644 (file)
   </logger>
 -->
 
+  <!-- WebDav objects -->
+  <logger name="org.apache.maven.archiva.webdav.ArchivaDavResource">
+    <level value="info"/>
+  </logger>
+  
+  <logger name="org.apache.maven.archiva.webdav.ArchivaDavResourceFactory">
+    <level value="info"/>
+  </logger>
+
   <!-- squelch noisy objects (for now) -->
   <logger name="org.apache.commons">
     <level value="warn"/>
index 524de1be63ae4458689a14e1e5712d476f0dcc1f..c0b5ec49634f055ec751b3ebbab11d3b5554cafc 100644 (file)
@@ -313,12 +313,16 @@ public class ArchivaDavResource
             
             queueRepositoryTask( localFile );           
             
+            log.debug( "File '" + resource.getDisplayName() + ( exists ? "' modified " : "' created ") + "(current user '" + this.principal + "')" );
+            
             triggerAuditEvent( resource, exists ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE );
         }
         else if ( !inputContext.hasStream() && isCollection() ) // New directory
         {
             localFile.mkdir();
             
+            log.debug( "Directory '" + resource.getDisplayName() + "' (current user '" + this.principal + "')" );
+            
             triggerAuditEvent( resource, AuditEvent.CREATE_DIR );
         }
         else
@@ -343,10 +347,12 @@ public class ArchivaDavResource
                         DavResourceLocator resourceLocator =
                             locator.getFactory().createResourceLocator( locator.getPrefix(), path );
                         DavResource resource = factory.createResource( resourceLocator, session );
+                        
                         if ( resource != null )
                         {
                             list.add( resource );
                         }
+                        log.debug( "Resource '" + item + "' retrieved by '" + this.principal + "'" );
                     }
                 }
                 catch ( DavException e )
@@ -382,6 +388,7 @@ public class ArchivaDavResource
 
                     triggerAuditEvent( member, AuditEvent.REMOVE_FILE );
                 }
+                log.debug( ( resource.isDirectory() ? "Directory '" : "File '" ) + member.getDisplayName() + "' removed (current user '" + this.principal + "')" );
             }
             catch ( IOException e )
             {
@@ -425,6 +432,9 @@ public class ArchivaDavResource
 
                 triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_FILE );
             }
+            
+            log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' moved to '" +
+                          destination + "' (current user '" + this.principal + "')" );
         }
         catch ( IOException e )
         {
@@ -460,6 +470,8 @@ public class ArchivaDavResource
 
                 triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE );
             }
+            log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' copied to '" +
+                          destination + "' (current user '" + this.principal + "')" );
         }
         catch ( IOException e )
         {
index 1e9f117a3fcf3c52027b79bcf8ac290fea1eb59c..a7e85322419797fdd7f428f437980c66bb6c7e31 100644 (file)
@@ -190,6 +190,8 @@ public class ArchivaDavResourceFactory
                 throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
                                         "Write method not allowed for repository groups." );
             }
+            
+            log.debug( "Repository group '" + repoGroupConfig.getId() + "' accessed by '" + activePrincipal + "'" );
 
             // handle browse requests for virtual repos
             if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
@@ -221,6 +223,8 @@ public class ArchivaDavResourceFactory
                 throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
             }
 
+            log.debug( "Managed repository '" + managedRepository.getId() + "' accessed by '" + activePrincipal + "'" );
+
             resource = processRepository( request, archivaLocator, activePrincipal, managedRepository );
 
             String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
@@ -421,7 +425,7 @@ public class ArchivaDavResourceFactory
                     if ( !resource.isCollection() )
                     {
                         boolean previouslyExisted = resourceFile.exists();
-
+                        
                         // Attempt to fetch the resource from any defined proxy.
                         boolean fromProxy = fetchContentFromProxies( managedRepository, request, logicalResource );
 
@@ -453,6 +457,10 @@ public class ArchivaDavResourceFactory
                             String event =
                                 ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE )
                                     + PROXIED_SUFFIX;
+                            
+                            log.debug( "Proxied artifact '" + resourceFile.getName() + "' in repository '" +
+                                       managedRepository.getId() + "' (current user '" + activePrincipal + "')" );
+
                             triggerAuditEvent( request.getRemoteAddr(), archivaLocator.getRepositoryId(),
                                                logicalResource.getPath(), event, activePrincipal );
                         }
@@ -481,6 +489,9 @@ public class ArchivaDavResourceFactory
                 {
                     destDir.mkdirs();
                     String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
+                    
+                    log.debug( "Creating destination directory '" + destDir.getName() + "' (current user '" + activePrincipal + "')" );
+                    
                     triggerAuditEvent( request.getRemoteAddr(), logicalResource.getPath(), relPath,
                                        AuditEvent.CREATE_DIR, activePrincipal );
                 }
@@ -554,6 +565,8 @@ public class ArchivaDavResourceFactory
                 File proxiedFile = connectors.fetchFromProxies( managedRepository, artifact );
 
                 resource.setPath( managedRepository.toPath( artifact ) );
+                
+                log.debug( "Proxied artifact '" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "'" );
 
                 return ( proxiedFile != null );
             }
@@ -852,6 +865,7 @@ public class ArchivaDavResourceFactory
                             if ( isAuthorized( request, repository ) )
                             {
                                 mergedRepositoryContents.add( resourceFile );
+                                log.debug( "Repository '" + repository + "' accessed by '" + activePrincipal + "'" );
                             }
                         }
                         catch ( DavException e )
@@ -870,6 +884,7 @@ public class ArchivaDavResourceFactory
                                                            WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
                             {
                                 mergedRepositoryContents.add( resourceFile );
+                                log.debug( "Repository '" + repository + "' accessed by '" + activePrincipal + "'" );
                             }
                         }
                         catch ( UnauthorizedException e )