import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
/**
*/
public class ArchivaDavResource
throws DavException
{
String path = logicalResource + "/" + member.getDisplayName();
-
- triggerAuditEvent( checkDavResourceIsArchivaDavResource( member ).remoteAddr, locator.getRepositoryId(), path,
+
+ ArchivaDavResource resource = checkDavResourceIsArchivaDavResource( member );
+ triggerAuditEvent( resource.remoteAddr, resource.principal, locator.getRepositoryId(), path,
event );
}
{
FileUtils.moveDirectory( getLocalResource(), resource.getLocalResource() );
- triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_DIRECTORY );
+ triggerAuditEvent( remoteAddr, principal, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_DIRECTORY );
}
else
{
FileUtils.moveFile( getLocalResource(), resource.getLocalResource() );
- triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_FILE );
+ triggerAuditEvent( remoteAddr, principal, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_FILE );
}
log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' moved to '" +
{
FileUtils.copyDirectory( getLocalResource(), resource.getLocalResource() );
- triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_DIRECTORY );
+ triggerAuditEvent( remoteAddr, principal, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_DIRECTORY );
}
else
{
FileUtils.copyFile( getLocalResource(), resource.getLocalResource() );
- triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE );
+ triggerAuditEvent( remoteAddr, principal, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE );
}
log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' copied to '" +
destination + "' (current user '" + this.principal + "')" );
return (ArchivaDavResource) resource;
}
- private void triggerAuditEvent( String remoteIP, String repositoryId, String resource, String action )
+ private void triggerAuditEvent( String remoteIP, String principal, String repositoryId, String resource,
+ String action )
{
AuditEvent event = new AuditEvent( repositoryId, principal, resource, action );
event.setRemoteIP( remoteIP );
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.database.constraints.MostRecentArchivaAuditLogsConstraint;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
+import org.apache.maven.archiva.repository.audit.AuditLog;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.apache.maven.archiva.security.ServletAuthenticator;
import org.codehaus.plexus.redback.authentication.AuthenticationException;
servletAuthControl.verify();
// assertEquals(HttpServletResponse.SC_CREATED, response.getResponseCode());
+
+ ArchivaAuditLogsDao auditLogsDao = archivaDavResourceFactory.getAuditLogsDao();
+ List<ArchivaAuditLogs> auditLogs = auditLogsDao.queryAuditLogs( new MostRecentArchivaAuditLogsConstraint() );
+ assertEquals( "admin", auditLogs.get( 0 ).getUsername() );
}
// test get with invalid user, and guest has read access to repo