From: Maria Odea B. Ching Date: Wed, 29 Jul 2009 09:55:18 +0000 (+0000) Subject: [MRM-1163] Add some decent logs in webdav for debugging purposes X-Git-Tag: archiva-1.2.2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f62c635bdeea0d83c2d5386c787914958d12ae1e;p=archiva.git [MRM-1163] Add some decent logs in webdav for debugging purposes 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 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/log4j.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/log4j.xml index cc0aa6a40..a89a9cafb 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/log4j.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/log4j.xml @@ -86,6 +86,15 @@ --> + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java index 524de1be6..c0b5ec496 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java @@ -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 ) { diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index 1e9f117a3..a7e853224 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -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 )