]> source.dussan.org Git - archiva.git/commitdiff
remove dependency on repository-layer from audit module
authorBrett Porter <brett@apache.org>
Thu, 11 Mar 2010 11:05:46 +0000 (11:05 +0000)
committerBrett Porter <brett@apache.org>
Thu, 11 Mar 2010 11:05:46 +0000 (11:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@921799 13f79535-47bb-0310-9956-ffa450edef68

35 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AuditEventArgumentsMatcher.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
archiva-modules/archiva-web/archiva-webdav/pom.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
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/archiva/repository/audit/TestAuditListener.java
archiva-modules/plugins/audit/pom.xml
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java [new file with mode: 0644]
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java [new file with mode: 0644]
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java [new file with mode: 0644]
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditManager.java
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java [new file with mode: 0644]
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java
archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java

index c3c302f937574aebbcb5516e1b39b8fd7cb3b89f..a0edd975f9a19dcb977327f572b2e16388fa5161 100644 (file)
   <name>Archiva Consumers :: Core Consumers</name>
 
   <dependencies>
+    <!-- TODO: remove this hard dependency by using an event mechanism -->
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>audit</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-configuration</artifactId>
index 9ec6c8e5a44a321fee485ca7e3930f69b019c3d1..1bd3f95f11513e72095da9dec8a187754906895a 100644 (file)
@@ -19,10 +19,10 @@ package org.apache.maven.archiva.consumers.core.repository;
  * under the License.
  */
 
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.repository.events.RepositoryListener;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index aae9ac6924213f4297ab8a94e508913e1102ffa9..c91dae1f721684e28e7795666d3e10534dd97b45 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.maven.archiva.web.action;
 
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.checksum.ChecksummedFile;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
@@ -37,8 +39,6 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
index 682e788082ff7b309485282dff68786f8177d150..aadc0bd34fc22d0ccb0162e46c2593b8e55b84a6 100644 (file)
@@ -19,22 +19,22 @@ package org.apache.maven.archiva.web.action;
  * under the License.\r
  */\r
 \r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
 import com.opensymphony.xwork2.ActionContext;\r
 import com.opensymphony.xwork2.ActionSupport;\r
-import org.apache.maven.archiva.repository.audit.AuditEvent;\r
-import org.apache.maven.archiva.repository.audit.AuditListener;\r
-import org.apache.maven.archiva.repository.audit.Auditable;\r
+import org.apache.archiva.audit.AuditEvent;\r
+import org.apache.archiva.audit.AuditListener;\r
+import org.apache.archiva.audit.Auditable;\r
 import org.apache.maven.archiva.security.ArchivaXworkUser;\r
 import org.apache.struts2.ServletActionContext;\r
 import org.apache.struts2.interceptor.SessionAware;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
 /**\r
  * LogEnabled and SessionAware ActionSupport\r
  */\r
@@ -47,7 +47,7 @@ public abstract class PlexusActionSupport
     protected Logger log = LoggerFactory.getLogger( getClass() );\r
 \r
     /**\r
-     * @plexus.requirement role="org.apache.maven.archiva.repository.audit.AuditListener"\r
+     * @plexus.requirement role="org.apache.archiva.audit.AuditListener"\r
      */\r
     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
 \r
index 1106d94262681971aee50c588d641efc1e8d36d8..2846384f574baf85456f13eb76b14a4ac2e68f30 100644 (file)
@@ -19,22 +19,10 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.checksum.ChecksummedFile;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
@@ -53,8 +41,6 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
@@ -68,6 +54,20 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.util.IOUtil;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
 /**
  * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
  * will also be updated if one exists, otherwise it would be created.
index 144bbaa00d63c6b9d4e3828ba4a8fd9eab5618d4..aad944204b84da415443fe919493a215271119f6 100644 (file)
@@ -19,16 +19,12 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  * under the License.
  */
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.apache.archiva.audit.Auditable;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
 import org.apache.maven.archiva.configuration.InvalidConfigurationException;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.web.action.PlexusActionSupport;
 import org.codehaus.plexus.redback.rbac.Resource;
@@ -37,6 +33,10 @@ import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Abstract AdminRepositories Action base.
  * 
index 97151c8163fbbb7f33bd7d9804933930bf482258..156e084bd58c61c045941b5ad770d5e5ed2b4efb 100644 (file)
@@ -21,12 +21,12 @@ package org.apache.maven.archiva.web.action.admin.repositories;
 
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 import org.codehaus.plexus.scheduler.CronExpressionValidator;
+
 import java.io.File;
 import java.io.IOException;
 
index 3b3d7b1d68c2e87fbdd84e3c1ab5c8850e36c0e6..b2f7182946783a213babc32a78f428e3af23d491 100644 (file)
@@ -21,10 +21,9 @@ package org.apache.maven.archiva.web.action.admin.repositories;
 
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 
 import java.io.IOException;
index 237a1936b5d360a972ed87ed7f4024f923257cb0..5107e7c9a37d9097c9bf9e04a809cc0b602ec816 100644 (file)
@@ -19,20 +19,20 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  * under the License.
  */
 
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
 import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
 /**
  * DeleteManagedRepositoryAction
  * 
index 9d9fef04be346957e317ea3ed960187048575530..8d0dc5afbbd8a9f40b8ba79fa73b170ca8d5c21a 100644 (file)
@@ -20,12 +20,11 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  */
 
 import com.opensymphony.xwork2.Preparable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 
 import java.util.List;
 
index 0c3aad84a1bbc6d7198d160fecaef6bb9fcf2cb7..98230a9ba05853fd085b0df4e4d9eeb65e4e7cee 100644 (file)
@@ -20,11 +20,10 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  */
 
 import com.opensymphony.xwork2.Preparable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 
 /**
  * DeleteRepositoryGroupAction
index 70ad2b241743a38c6f04361f3d9ba7067c1ceceb..d27eea503cced2919dccfc625bd1e096cc5ffa95 100644 (file)
@@ -19,19 +19,19 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 import org.codehaus.plexus.scheduler.CronExpressionValidator;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
  * AddManagedRepositoryAction
  *
index 61dd3f6a4b4455334f9a31d854ce613aaec88faf..771789a024056c84889b4e10844efb31b51da765 100644 (file)
@@ -20,11 +20,10 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  */
 
 import com.opensymphony.xwork2.Preparable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 
 import java.io.IOException;
index fd5acb8b028452ab00f5669dad5fbea310d7bad0..2cb4094afb1b87dc74c0a3cf4796277551220da1 100644 (file)
@@ -19,22 +19,20 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  * under the License.
  */
 
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts2.interceptor.ServletRequestAware;
 import com.opensymphony.xwork2.Preparable;
-
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.apache.maven.archiva.web.util.ContextUtils;
+import org.apache.struts2.interceptor.ServletRequestAware;
+
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * RepositoryGroupsAction
index 3f465c90af48b1dd8830f7959db5c7b8d7e416d2..6916d6529aba7e40249d1279df50ffb51cf36a45 100644 (file)
@@ -19,13 +19,10 @@ package org.apache.maven.archiva.web.action.admin.scanning;
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
@@ -36,8 +33,6 @@ import org.apache.maven.archiva.configuration.IndeterminateConfigurationExceptio
 import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
 import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate;
 import org.apache.maven.archiva.configuration.functors.FiletypeToMapClosure;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.web.action.PlexusActionSupport;
 import org.codehaus.plexus.redback.rbac.Resource;
@@ -46,6 +41,11 @@ import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 /**
  * RepositoryScanningAction
  *
index 92d598aa84570010366d30eeb85ff18e4aa4114b..0030d1050d6cff8af55c49e0b4186cf8663815c7 100644 (file)
@@ -19,19 +19,11 @@ package org.apache.maven.archiva.web.action.reports;
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-
 import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.audit.AuditManager;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.apache.maven.archiva.security.AccessDeniedException;
 import org.apache.maven.archiva.security.ArchivaSecurityException;
 import org.apache.maven.archiva.security.PrincipalNotFoundException;
@@ -42,6 +34,14 @@ import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="viewAuditLogReport"
  * instantiation-strategy="per-lookup"
index 81bed6f71a51a48a7acfa58667cb524bc3b00912..fcb92f32cb6a9602e183f7e78f7d41054d1a10ec 100644 (file)
@@ -19,11 +19,11 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
-import java.util.Arrays;
-
-import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.archiva.audit.AuditEvent;
 import org.easymock.ArgumentsMatcher;
 
+import java.util.Arrays;
+
 public class AuditEventArgumentsMatcher
     implements ArgumentsMatcher
 {
index 7f052b6bee8f8d7a80168f08a183513ed4ac5a84..4aa2a766e0bfa4f977332d00862c41aee926cdbc 100644 (file)
@@ -19,17 +19,9 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.checksum.ChecksummedFile;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
@@ -42,14 +34,22 @@ import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.easymock.MockControl;
 import org.easymock.classextension.MockClassControl;
 
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
 /**
  * UploadActionTest
  */
index 94f7b674e98b9da1676b22cffc7c059a87b00616..d730cf5cee5788ba5df8b2185ea040558c2333af 100644 (file)
@@ -19,13 +19,9 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  * under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@@ -35,8 +31,6 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.web.action.AuditEventArgumentsMatcher;
 import org.codehaus.plexus.redback.role.RoleManager;
@@ -47,6 +41,12 @@ import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 import org.easymock.MockControl;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * DeleteManagedRepositoryActionTest 
  *
index d85241ceeb618ecf27ce8a770b83155a4f24851d..f6b0e25610c874fbab4197d0369704a5f99e479d 100644 (file)
   <name>Archiva Web :: WebDAV</name>
 
   <dependencies>
+    <!-- TODO: remove this hardcoding through a better event mechanism -->
     <dependency>
       <groupId>org.apache.archiva</groupId>                          
+      <artifactId>audit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-configuration</artifactId>
     </dependency>
     <dependency>
index ee155adc1064b481578d7fd23c9b9bf9d2a2fea6..0f248e989c5facb9be86f154abf42fad16183009 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.maven.archiva.webdav;
  * under the License.
  */
 
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
 import org.apache.archiva.scheduler.repository.RepositoryTask;
@@ -48,8 +50,6 @@ import org.apache.jackrabbit.webdav.property.DavPropertySet;
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
 import org.apache.jackrabbit.webdav.property.ResourceType;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
 import org.apache.maven.archiva.webdav.util.IndexWriter;
 import org.apache.maven.archiva.webdav.util.MimeTypes;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
index 39542e622c0e3958973040a901285fc008e5ef81..5d28c531640abe47fd2b8d4fdae3fff70309e8be 100644 (file)
@@ -19,6 +19,9 @@ package org.apache.maven.archiva.webdav;
  * under the License.
  */
 
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
+import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -43,9 +46,6 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
-import org.apache.maven.archiva.repository.audit.Auditable;
 import org.apache.maven.archiva.repository.content.RepositoryRequest;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
@@ -99,7 +99,7 @@ public class ArchivaDavResourceFactory
     private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
 
     /**
-     * @plexus.requirement role="org.apache.maven.archiva.repository.audit.AuditListener"
+     * @plexus.requirement role="org.apache.archiva.audit.AuditListener"
      */
     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
 
index 8e22e72de89a70778c2a7b35612268555bdd548c..079201a8785134b78d22e9b18fa43aae3ab91cfb 100644 (file)
@@ -19,9 +19,7 @@ package org.apache.maven.archiva.webdav;
  * under the License.
  */
 
-import java.io.File;
-import java.util.Collections;
-
+import org.apache.archiva.audit.AuditListener;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
@@ -37,11 +35,13 @@ import org.apache.jackrabbit.webdav.lock.Scope;
 import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
 import org.apache.jackrabbit.webdav.lock.Type;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.audit.AuditListener;
 import org.apache.maven.archiva.webdav.util.MimeTypes;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.spring.PlexusToSpringUtils;
 
+import java.io.File;
+import java.util.Collections;
+
 public class DavResourceTest
     extends PlexusInSpringTestCase
 {
index 6c265b225065e84b7674bbca4084d689c911d39d..3091c50ee7cbe69abf07507be14ca58a64088c9c 100644 (file)
@@ -19,22 +19,21 @@ package org.apache.maven.archiva.webdav;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.servlet.http.HttpServletResponse;
-
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.PutMethodWebRequest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.InvocationContext;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.ServletUnitClient;
 import net.sf.ehcache.CacheManager;
-
 import org.apache.archiva.repository.audit.TestAuditListener;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.webdav.DavSessionProvider;
 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.repository.audit.AuditListener;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.security.ServletAuthenticator;
 import org.codehaus.plexus.redback.authentication.AuthenticationException;
@@ -50,14 +49,10 @@ import org.codehaus.redback.integration.filter.authentication.basic.HttpBasicAut
 import org.easymock.MockControl;
 import org.easymock.classextension.MockClassControl;
 
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.httpunit.PutMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.InvocationContext;
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.ServletUnitClient;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * RepositoryServletSecurityTest Test the flow of the authentication and authorization checks. This does not necessarily
index 52a6a14d55eba5a217fef166fa71ce52f4f900e2..af0daf0b8e63905825108c4e1b26cc59e64cc4e2 100644 (file)
@@ -19,8 +19,8 @@ package org.apache.archiva.repository.audit;
  * under the License.
  */
 
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
+import org.apache.archiva.audit.AuditEvent;
+import org.apache.archiva.audit.AuditListener;
 
 import java.util.ArrayList;
 import java.util.List;
index 2769057866ad1e26669a7c30dfa3e0d5bfb11054..fd204538d254efafd22158d60abf6e0eeea7d8f8 100644 (file)
@@ -30,7 +30,7 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.archiva</groupId>
-      <artifactId>archiva-repository-layer</artifactId>
+      <artifactId>archiva-configuration</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java
new file mode 100644 (file)
index 0000000..4712520
--- /dev/null
@@ -0,0 +1,330 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.MetadataFacet;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+/**
+ * AuditEvent
+ *
+ * @version $Id$
+ */
+public class AuditEvent
+    implements MetadataFacet
+{
+    public static final String TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS";
+
+    public static final String CREATE_DIR = "Created Directory";
+
+    public static final String CREATE_FILE = "Created File";
+
+    public static final String REMOVE_DIR = "Removed Directory";
+
+    public static final String REMOVE_FILE = "Removed File";
+
+    public static final String MODIFY_FILE = "Modified File";
+
+    public static final String MOVE_FILE = "Moved File";
+
+    public static final String MOVE_DIRECTORY = "Moved Directory";
+
+    public static final String COPY_DIRECTORY = "Copied Directory";
+
+    public static final String COPY_FILE = "Copied File";
+
+    public static final String UPLOAD_FILE = "Uploaded File";
+
+    public static final String ADD_LEGACY_PATH = "Added Legacy Artifact Path";
+
+    public static final String REMOVE_LEGACY_PATH = "Removed Legacy Artifact Path";
+
+    public static final String PURGE_ARTIFACT = "Purged Artifact";
+
+    public static final String PURGE_FILE = "Purged Support File";
+
+    public static final String REMOVE_SCANNED = "Removed in Filesystem";
+
+    // configuration events
+
+    public static final String ADD_MANAGED_REPO = "Added Managed Repository";
+
+    public static final String MODIFY_MANAGED_REPO = "Updated Managed Repository";
+
+    public static final String DELETE_MANAGED_REPO = "Deleted Managed Repository";
+
+    public static final String ADD_REMOTE_REPO = "Added Remote Repository";
+
+    public static final String MODIFY_REMOTE_REPO = "Updated Remote Repository";
+
+    public static final String DELETE_REMOTE_REPO = "Deleted Remote Repository";
+
+    public static final String ADD_REPO_GROUP = "Added Repository Group";
+
+    public static final String DELETE_REPO_GROUP = "Deleted Repository Group";
+
+    public static final String ADD_REPO_TO_GROUP = "Added Repository to Group";
+
+    public static final String DELETE_REPO_FROM_GROUP = "Deleted Repository from Group";
+
+    public static final String ENABLE_REPO_CONSUMER = "Enabled Content Consumer";
+
+    public static final String DISABLE_REPO_CONSUMER = "Disabled Content Consumer";
+
+    public static final String ADD_PATTERN = "Added File Type Pattern";
+
+    public static final String REMOVE_PATTERN = "Removed File Type Pattern";
+
+    private String repositoryId;
+
+    private String userId;
+
+    private String remoteIP;
+
+    // TODO: change to artifact reference? does it ever refer to just a path?
+
+    private String resource;
+
+    private String action;
+
+    private Date timestamp;
+
+    public static final String FACET_ID = "org.apache.archiva.audit";
+
+    private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
+
+    private static final int TS_LENGTH = TIMESTAMP_FORMAT.length();
+
+    public AuditEvent()
+    {
+        /* do nothing */
+    }
+
+    public AuditEvent( String name, String repositoryId )
+    {
+        String ts = name.substring( 0, TS_LENGTH );
+        try
+        {
+            timestamp = createNameFormat().parse( ts );
+        }
+        catch ( ParseException e )
+        {
+            throw new IllegalArgumentException( "Improperly formatted timestamp for audit log event: " + ts );
+        }
+
+        if ( name.length() > TS_LENGTH )
+        {
+            if ( name.charAt( TS_LENGTH ) != '/' )
+            {
+                throw new IllegalArgumentException(
+                    "Improperly formatted name for audit log event, no / separator between timestamp and resource: " +
+                        name );
+            }
+        }
+
+        this.repositoryId = repositoryId;
+    }
+
+    public AuditEvent( String repoId, String user, String resource, String action )
+    {
+        this.repositoryId = repoId;
+        this.userId = user;
+        this.resource = resource;
+        this.action = action;
+        this.timestamp = Calendar.getInstance().getTime();
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public String getUserId()
+    {
+        return userId;
+    }
+
+    public void setUserId( String userId )
+    {
+        this.userId = userId;
+    }
+
+    public String getResource()
+    {
+        return resource;
+    }
+
+    public void setResource( String resource )
+    {
+        this.resource = resource;
+    }
+
+    public String getAction()
+    {
+        return action;
+    }
+
+    public void setAction( String action )
+    {
+        this.action = action;
+    }
+
+    public String getRemoteIP()
+    {
+        return remoteIP;
+    }
+
+    public void setRemoteIP( String remoteIP )
+    {
+        this.remoteIP = remoteIP;
+    }
+
+    public Date getTimestamp()
+    {
+        return timestamp;
+    }
+
+    public void setTimestamp( Date timestamp )
+    {
+        this.timestamp = timestamp;
+    }
+
+    public String getFacetId()
+    {
+        return FACET_ID;
+    }
+
+    public String getName()
+    {
+        // use the hashCode here to make it unique if multiple events occur at a certain timestamp. None of the other
+        // fields is unique on its own
+        return createNameFormat().format( timestamp ) + "/" + Integer.toHexString( hashCode() );
+        // TODO: a simple incremental counter might be better since it will retain ordering, but then we need to do a
+        //  bit of locking...
+    }
+
+    private static SimpleDateFormat createNameFormat()
+    {
+        SimpleDateFormat fmt = new SimpleDateFormat( TIMESTAMP_FORMAT );
+        fmt.setTimeZone( UTC_TIME_ZONE );
+        return fmt;
+    }
+
+    public Map<String, String> toProperties()
+    {
+        Map<String, String> properties = new HashMap<String, String>();
+        properties.put( "action", this.action );
+        if ( this.userId != null )
+        {
+            properties.put( "user", this.userId );
+        }
+        if ( this.remoteIP != null )
+        {
+            properties.put( "remoteIP", this.remoteIP );
+        }
+        if ( this.resource != null )
+        {
+            properties.put( "resource", this.resource );
+        }
+        return properties;
+    }
+
+    public void fromProperties( Map<String, String> properties )
+    {
+        this.action = properties.get( "action" );
+        this.remoteIP = properties.get( "remoteIP" );
+        this.userId = properties.get( "user" );
+        this.resource = properties.get( "resource" );
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        AuditEvent that = (AuditEvent) o;
+
+        if ( !action.equals( that.action ) )
+        {
+            return false;
+        }
+        if ( remoteIP != null ? !remoteIP.equals( that.remoteIP ) : that.remoteIP != null )
+        {
+            return false;
+        }
+        if ( repositoryId != null ? !repositoryId.equals( that.repositoryId ) : that.repositoryId != null )
+        {
+            return false;
+        }
+        if ( resource != null ? !resource.equals( that.resource ) : that.resource != null )
+        {
+            return false;
+        }
+        if ( !timestamp.equals( that.timestamp ) )
+        {
+            return false;
+        }
+        if ( userId != null ? !userId.equals( that.userId ) : that.userId != null )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int result = repositoryId != null ? repositoryId.hashCode() : 0;
+        result = 31 * result + ( userId != null ? userId.hashCode() : 0 );
+        result = 31 * result + ( remoteIP != null ? remoteIP.hashCode() : 0 );
+        result = 31 * result + ( resource != null ? resource.hashCode() : 0 );
+        result = 31 * result + action.hashCode();
+        result = 31 * result + timestamp.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "AuditEvent{" + "repositoryId='" + repositoryId + '\'' + ", userId='" + userId + '\'' + ", remoteIP='" +
+            remoteIP + '\'' + ", resource='" + resource + '\'' + ", action='" + action + '\'' + ", timestamp=" +
+            timestamp + '}';
+    }
+}
index 9573d550975f4502e6d7df9e8a12422d5041ae0b..f2572054f3d7865446301cc4836050d3c2672b2d 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.archiva.audit;
 
 import org.apache.archiva.metadata.model.MetadataFacet;
 import org.apache.archiva.metadata.model.MetadataFacetFactory;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
 
 /**
  * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.audit"
@@ -38,4 +37,4 @@ public class AuditEventFactory
     {
         return new AuditEvent( name, repositoryId );
     }
-}
\ No newline at end of file
+}
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java
new file mode 100644 (file)
index 0000000..204f7ae
--- /dev/null
@@ -0,0 +1,35 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * AuditListener 
+ *
+ * @version $Id$
+ */
+public interface AuditListener
+{
+    /**
+     * Notification that an audit event occured. 
+     * 
+     * @param event the event details.
+     */
+    public void auditEvent( AuditEvent event );
+}
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java
new file mode 100644 (file)
index 0000000..eda1d6c
--- /dev/null
@@ -0,0 +1,60 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AuditLog - Audit Log.
+ * 
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.archiva.repository.audit.AuditListener" role-hint="logging"
+ */
+public class AuditLog
+    implements AuditListener
+{
+    public static final Logger logger = LoggerFactory.getLogger( "org.apache.archiva.AuditLog" );
+
+    private static final String NONE = "-";
+
+    private static final char DELIM = ' ';
+
+    /**
+     * Creates a log message in the following format ...
+     * "{repository_id} {user_id} {remote_ip} \"{resource}\" \"{action}\""
+     */
+    public void auditEvent( AuditEvent event )
+    {
+        StringBuffer msg = new StringBuffer();
+        msg.append( checkNull( event.getRepositoryId() ) ).append( DELIM );
+        msg.append( event.getUserId() ).append( DELIM );
+        msg.append( checkNull( event.getRemoteIP() ) ).append( DELIM );
+        msg.append( '\"' ).append( checkNull( event.getResource() ) ).append( '\"' ).append( DELIM );
+        msg.append( '\"' ).append( event.getAction() ).append( '\"' );
+
+        logger.info( msg.toString() );
+    }
+
+    private String checkNull( String s )
+    {
+        return s != null ? s : NONE;
+    }
+}
index 3b3448efb360f6c8ac11c2933a2f3bd2851fc0e8..29665e5a6beb9f7484fbab3559cb025fabeaebdd 100644 (file)
@@ -23,8 +23,6 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-
 public interface AuditManager
 {
     List<AuditEvent> getMostRecentAuditEvents( List<String> repositoryIds );
@@ -54,4 +52,4 @@ public interface AuditManager
      */
     List<AuditEvent> getAuditEventsInRange( Collection<String> repositoryIds, String resourcePattern, Date startTime,
                                             Date endTime );
-}
\ No newline at end of file
+}
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java
new file mode 100644 (file)
index 0000000..b265524
--- /dev/null
@@ -0,0 +1,47 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Auditable 
+ *
+ * @version $Id$
+ */
+public interface Auditable
+{
+    /**
+     * Add an AuditListener.
+     * 
+     * @param the listener to add.
+     */
+    public void addAuditListener( AuditListener auditListener );
+
+    /**
+     * Remove an AuditListener.
+     * 
+     * @param the listener to remove.
+     */
+    public void removeAuditListener( AuditListener auditListener );
+
+    /**
+     * Remove all registered {@link AuditListener} objects.
+     */
+    public void clearAuditListeners();
+}
index 1a5b1ef189476b150935fb365af31cfb62fd7672..73c9094e4a602723fc9e3260d02859b6bf9b5479 100644 (file)
@@ -19,6 +19,10 @@ package org.apache.archiva.audit;
  * under the License.
  */
 
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -29,11 +33,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.TimeZone;
 
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * @plexus.component role="org.apache.archiva.audit.AuditManager"
  */
index 612eb51af602369c54cd1f58ca6a4af35d91d91a..0800131904f3a43d4318ceed37ad949b5cf73a48 100644 (file)
@@ -19,9 +19,6 @@ package org.apache.archiva.audit;
  * under the License.
  */
 
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.audit.AuditListener;
-
 /**
  * @plexus.component role="org.apache.maven.archiva.repository.audit.AuditListener" role-hint="metadata"
  */
index 26b16d74d145a15cdde270bbc70b54268f1914ba..a4e6012d34b30e9133c8a491884de0037690fd31 100644 (file)
@@ -19,6 +19,11 @@ package org.apache.archiva.audit;
  * under the License.
  */
 
+import junit.framework.TestCase;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.easymock.MockControl;
+
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -31,15 +36,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
 
-import junit.framework.TestCase;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.audit.AuditEvent;
-import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
 public class AuditManagerTest
     extends TestCase
 {
@@ -87,13 +83,6 @@ public class AuditManagerTest
         ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
         repository.setId( TEST_REPO_ID );
         repository.setLocation( "" );
-        ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( repository );
-        MockControl control = MockClassControl.createControl( RepositoryContentFactory.class );
-        RepositoryContentFactory contentFactory = (RepositoryContentFactory) control.getMock();
-        contentFactory.getManagedRepositoryContent( TEST_REPO_ID );
-        control.setDefaultReturnValue( content );
-        control.replay();
     }
 
     public void testGetMostRecentEvents()
@@ -602,4 +591,4 @@ public class AuditManagerTest
         }
         return names;
     }
-}
\ No newline at end of file
+}