]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1296] Audit logging report
authorMaria Odea B. Ching <oching@apache.org>
Mon, 11 Jan 2010 15:07:00 +0000 (15:07 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Mon, 11 Jan 2010 15:07:00 +0000 (15:07 +0000)
merged MRM-1296 branch to trunk

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

57 files changed:
archiva-docs/src/site/apt/userguide/auditlog-report.apt [new file with mode: 0644]
archiva-docs/src/site/apt/userguide/index.apt
archiva-docs/src/site/resources/images/latest-events.png [new file with mode: 0644]
archiva-docs/src/site/site.xml
archiva-modules/archiva-base/archiva-model/pom.xml
archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaAuditLogsDao.java [new file with mode: 0644]
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaAuditLogsConstraint.java [new file with mode: 0644]
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentArchivaAuditLogsConstraint.java [new file with mode: 0644]
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java
archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaAuditLogsDao.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java
archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java [new file with mode: 0644]
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/reports/ViewAuditLogReportAction.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
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/connectors/proxy/DisableProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaAuditLogsDaoStub.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/BrowseActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/ShowArtifactActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.xml
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/rss/RssFeedServletTest.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/ArchivaDavResourceFactoryTest.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/maven/archiva/webdav/RepositoryServletSecurityTest.xml
archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml

diff --git a/archiva-docs/src/site/apt/userguide/auditlog-report.apt b/archiva-docs/src/site/apt/userguide/auditlog-report.apt
new file mode 100644 (file)
index 0000000..c2eb93c
--- /dev/null
@@ -0,0 +1,38 @@
+ ------
+ Audit Log Report
+ ------
+
+Audit Log Report
+
+  Starting with Archiva 1.3, audit events can be viewed and queried from the web UI. In the current implementation, only artifact upload events are viewable 
+  but there are plans to include other events such as artifact delete, repository creation and deletion, configuration changes, etc.  
+  To view the audit events, click <<<Audit Log Report>>> from the navigation menu. Initially, the latest 10 artifact upload events are displayed.
+
+[../images/latest-events.png] Latest Events
+
+* Customizing the Audit Log Report
+
+  The following fields can be specified when querying for the audit events:
+  
+  [[1]] Repository - the repository where the events happened. Only those repositories which the logged in user has permission to access are listed in the drop-down
+  box.
+  
+  [[2]] Group ID - the <<<groupId>>> of the artifact whose audit events you want to view.
+  
+  [[3]] Artifact ID - the <<<artifactId>>> of the artifact whose audit events you want to view.
+  
+  [[4]] Start Date - the start date of the event(s) you want to view. This defaults to the current date if none is specified.
+  
+  [[5]] End Date - the end date of the event(s) you want to view. This defaults to the current date if none is specified.
+  
+  [[6]] Row Count - the number of rows you want displayed per page. This will be the basis for the pagination of the results. The default value is 30 rows.
+  
+  []
+  
+  Just specify values for either one or all of the above fields and then submit the form to perform the query. The results of the query will be displayed at the lower
+  section of the page, similar to that shown in the <<<Latest Events>>> except that the heading will be <<<Results>>> instead of <<<Latest Events>>>.
+
+
+
+
index d79e6eb3d665410168e84a4eae1315134dcbae11..4227e8f465fa465bb84ec4d301532ddf3561bb1f 100644 (file)
@@ -20,6 +20,8 @@ Users Guide
     * {{{virtual-repositories.html} Configuring Virtual Repositories}}
 
     * {{{rss.html}RSS Feeds in Archiva}}
+    
+    * {{{auditlog-report.html}Viewing the Audit Log Report}}
 
     []
 
diff --git a/archiva-docs/src/site/resources/images/latest-events.png b/archiva-docs/src/site/resources/images/latest-events.png
new file mode 100644 (file)
index 0000000..8232340
Binary files /dev/null and b/archiva-docs/src/site/resources/images/latest-events.png differ
index ca9eb0e0f2033386c79e722ac6bbc828fe91d2a4..9c6650c2aed3e1ee2bfa40447acdf20a5c53b674 100644 (file)
@@ -40,6 +40,7 @@
       <item name="Deploying to repository"   href="/userguide/deploy.html" />
       <item name="Configuring Virtual Repositories"   href="/userguide/virtual-repositories.html" />
       <item name="Rss Feeds in Archiva"      href="/userguide/rss.html"/>
+      <item name="Audit Log Report"      href="/userguide/auditlog-report.html"/>
     </menu>
 
     <menu name="Administrators Guide">
index f686016c916f6c97c09fde76c1951c87da23bdc0..f24fd37240c2881fd434469406dc38d3aac6058f 100755 (executable)
@@ -70,7 +70,7 @@
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
         <configuration>
-          <version>1.2.1</version>
+          <version>1.3.0</version>
           <packageWithVersion>false</packageWithVersion>
           <models>
             <model>src/main/mdo/archiva-base.xml</model>
index de08a8d7b8512323cb27cb8cd22822f183399585..93e4a295a143f131b63c6969d1712554b93e0fbb 100644 (file)
@@ -5,7 +5,7 @@
        xsd.target-namespace="http://archiva.apache.org/model/1.2.0">
   <id>archiva-base-model</id>
   <name>ArchivaBaseModel</name>
-  <version>1.2.1</version>
+  <version>1.3.0</version>
   <description>Archiva Model</description>
   <defaults>
     <default>
             <multiplicity>*</multiplicity>
           </association>
         </field>
+        <field>
+          <name>archivaAuditLogs</name>
+          <version>1.3.0+</version>
+          <association>
+            <type>ArchivaAuditLogs</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>
         </codeSegment>
       </codeSegments>
     </class>
+    <class stash.storable="true"
+           jpox.table="AUDIT_LOGS">
+      <name>ArchivaAuditLogs</name>
+      <version>1.3.0+</version>
+      <fields>
+        <field stash.maxSize="50">
+          <name>repositoryId</name>
+          <version>1.3.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>String</type>
+          <description>
+            The repository id where the operation was done.
+          </description>
+        </field>
+        <field>
+          <name>eventDate</name>
+          <version>1.3.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>Date</type>
+          <description>
+            The timestamp on when the event happened.
+          </description>
+        </field>
+        <field>
+          <name>artifact</name>
+          <version>1.3.0+</version>
+          <identifier>false</identifier>
+          <required>false</required>
+          <type>String</type>
+          <description>
+            The affected artifact, if there is one.
+          </description>
+        </field>
+        <field>
+          <name>event</name>
+          <version>1.3.0+</version>
+          <identifier>false</identifier>
+          <required>false</required>
+          <type>String</type>
+          <description>
+            The event that happened.
+          </description>
+        </field>
+        <field>
+          <name>username</name>
+          <version>1.3.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>String</type>
+          <description>
+            The user who executed the event.
+          </description>
+        </field>
+      </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.3.0+</version>
+          <code><![CDATA[
+    private static final long serialVersionUID = -7113629916828442780L;
+          ]]></code>
+        </codeSegment>
+      </codeSegments>
+    </class>
   </classes>
 </model>
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaAuditLogsDao.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaAuditLogsDao.java
new file mode 100644 (file)
index 0000000..639c5d6
--- /dev/null
@@ -0,0 +1,35 @@
+package org.apache.maven.archiva.database;
+
+/*
+ * 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 java.util.List;
+
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
+
+public interface ArchivaAuditLogsDao
+{
+    public List<ArchivaAuditLogs> queryAuditLogs( Constraint constraint )
+        throws ObjectNotFoundException, ArchivaDatabaseException;
+
+    public ArchivaAuditLogs saveAuditLogs( ArchivaAuditLogs logs );
+    
+    public void deleteAuditLogs( ArchivaAuditLogs logs )
+        throws ArchivaDatabaseException;
+}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaAuditLogsConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaAuditLogsConstraint.java
new file mode 100644 (file)
index 0000000..ed225ae
--- /dev/null
@@ -0,0 +1,106 @@
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ArchivaAuditLogsConstraint
+ */
+public class ArchivaAuditLogsConstraint
+    extends RangeConstraint
+{
+    private String whereClause;
+    
+    private void createWhereClause( String desiredArtifact, String desiredRepositoryId, String desiredEvent,
+                                    Date startDate, Date endDate )
+    {
+        whereClause = "eventDate >= desiredStartDate && eventDate <= desiredEndDate";        
+        declImports = new String[] { "import java.util.Date" };
+                
+        List<String> declParamsList = new ArrayList<String>();
+        declParamsList.add( "Date desiredStartDate" );
+        declParamsList.add( "Date desiredEndDate" );
+
+        List<Object> paramsList = new ArrayList<Object>();
+        paramsList.add( startDate );
+        paramsList.add( endDate );
+
+        if ( desiredArtifact != null && !"".equals( desiredArtifact ) )
+        {
+            whereClause = whereClause + " && artifact.like(desiredArtifact)";
+            declParamsList.add( "String desiredArtifact" );
+            paramsList.add( desiredArtifact );            
+        }
+
+        if ( desiredRepositoryId != null && !"".equals( desiredRepositoryId ) )
+        {
+            whereClause = whereClause + " && repositoryId == desiredRepositoryId";
+            declParamsList.add( "String desiredRepositoryId" );
+            paramsList.add( desiredRepositoryId );
+        }
+
+        if ( desiredEvent != null && !"".equals( desiredEvent ) )
+        {
+            whereClause = whereClause + " && event ==  desiredEvent";
+            declParamsList.add( "String desiredEvent" );
+            paramsList.add( desiredEvent );
+        }
+
+        int size = declParamsList.size();
+        int i = 0;
+        declParams = new String[size];       
+        
+        while( i < size )
+        {
+            declParams[i] = declParamsList.get( i );
+            i++;
+        }        
+        
+        params = paramsList.toArray();
+    }
+
+    public ArchivaAuditLogsConstraint( int[] range, String desiredArtifact, String desiredRepositoryId,
+                                       String desiredEvent, Date startDate, Date endDate )
+    {
+        super( range );
+        createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
+    }
+    
+    public ArchivaAuditLogsConstraint( String desiredArtifact, String desiredRepositoryId,
+                                       String desiredEvent, Date startDate, Date endDate )
+    {
+        super();
+        createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
+    }
+
+
+    public String getSortColumn()
+    {
+        return "eventDate";
+    }
+
+    public String getWhereCondition()
+    {
+        return whereClause;
+    }
+}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentArchivaAuditLogsConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/MostRecentArchivaAuditLogsConstraint.java
new file mode 100644 (file)
index 0000000..8e2d005
--- /dev/null
@@ -0,0 +1,49 @@
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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.maven.archiva.model.ArchivaAuditLogs;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+
+public class MostRecentArchivaAuditLogsConstraint
+    extends AbstractSimpleConstraint
+{
+    private String sql;
+
+    public MostRecentArchivaAuditLogsConstraint()
+    {
+        sql =
+            "SELECT FROM " + ArchivaAuditLogs.class.getName() +
+                " WHERE event == uploadArtifact PARAMETERS String uploadArtifact" +
+                " ORDER BY eventDate DESCENDING RANGE 0,10";
+
+        super.params = new Object[] { AuditEvent.UPLOAD_FILE };
+    }
+
+    public Class<?> getResultClass()
+    {
+        return ArchivaAuditLogs.class;
+    }
+
+    public String getSelectSql()
+    {
+        return sql;
+    }
+}
index 27c39bf52e3b82b9f89cab254e7b69e33cecfba0..dd38dfe52a8a000b7c71afc032f4da49d2af1870 100644 (file)
@@ -395,7 +395,7 @@ public class JdoAccess
             case 3:
                 return (List<?>) query.execute( parameters[0], parameters[1], parameters[2] );
             default:
-                throw new JDOException( "Unable to use more than 3 parameters." );
+                return (List<?>) query.executeWithArray( parameters );                
         }
     }
 
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaAuditLogsDao.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaAuditLogsDao.java
new file mode 100644 (file)
index 0000000..64aa620
--- /dev/null
@@ -0,0 +1,62 @@
+package org.apache.maven.archiva.database.jdo;
+
+/*
+ * 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 java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
+
+/**
+ * JdoArchivaAuditLogsDao
+ * 
+ * @version  
+ * 
+ * @plexus.component role-hint="jdo"
+ */
+public class JdoArchivaAuditLogsDao
+    implements ArchivaAuditLogsDao
+{
+    /**
+     * @plexus.requirement role-hint="archiva"
+     */
+    private JdoAccess jdo;
+
+    public void deleteAuditLogs( ArchivaAuditLogs logs )
+        throws ArchivaDatabaseException
+    {
+        jdo.removeObject( logs );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public List<ArchivaAuditLogs> queryAuditLogs( Constraint constraint )
+        throws ObjectNotFoundException, ArchivaDatabaseException
+    {
+        return (List<ArchivaAuditLogs>) jdo.queryObjects( ArchivaAuditLogs.class, constraint );
+    }
+
+    public ArchivaAuditLogs saveAuditLogs( ArchivaAuditLogs logs )
+    {
+        return (ArchivaAuditLogs) jdo.saveObject( logs );
+    }
+}
index 7c6f7b76d8e1a2fb2087a53944d9fe7b6a871657..396f9250a02d2d30e92735f74bcc3534c08b1614 100644 (file)
@@ -65,6 +65,8 @@ public class ArchivaRoleConstants
     public static final String OPERATION_REPOSITORY_UPLOAD = "archiva-upload-repository";
 
     public static final String OPERATION_REPOSITORY_DELETE = "archiva-delete-artifact";
+    
+    public static final String OPERATION_VIEW_AUDIT_LOG = "archiva-view-audit-logs";
 
     // Role templates
     public static final String TEMPLATE_REPOSITORY_MANAGER = "archiva-repository-manager";
index 235537e059d8e315bb524a308fa5853f8ace54f1..55b30e09e4355ebe757a3fa80f6b070c74e0a7da 100644 (file)
           <name>archiva-access-repository</name>
           <description>Access Archiva Repository</description>
         </operation>
+        <operation>
+          <id>archiva-view-audit-logs</id>
+          <name>archiva-view-audit-logs</name>
+          <description>View Archiva Audit Logs</description>
+        </operation>
         <operation>
           <id>archiva-guest</id>
           <name>archiva-guest</name>
               <operation>archiva-upload-repository</operation>
               <resource>${resource}</resource>
             </permission>
+            <permission>
+              <id>archiva-view-audit-logs</id>
+              <name>Archiva View Audit Logs</name>
+              <operation>archiva-view-audit-logs</operation>
+              <resource>${resource}</resource>
+            </permission>
           </permissions>
           <childTemplates>
             <childTemplate>archiva-repository-observer</childTemplate>
index c107bda614665119ead7f94e9c4defb9c348a3f1..e8607fb3b654486e1579837ac43a44c038037637 100644 (file)
@@ -33,6 +33,7 @@ under the License.
                                <include name= "reposcan" />
                                <include name= "artifactmanagement" />
                                <include name= "search" />
+                               <include name= "auditlogsreport" />
                                <include name= "browse" />
                                <include name= "reports" />
                                <include name= "virtualrepository" />
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
new file mode 100644 (file)
index 0000000..bced431
--- /dev/null
@@ -0,0 +1,125 @@
+package org.apache.archiva.web.test;
+
+/*
+ * 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.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class AuditLogsReportTest
+    extends AbstractArchivaTest
+{
+    private void goToAuditLogReports()
+    {
+        clickLinkWithText( "Audit Log Report" );        
+    }
+    
+    private void assertAuditLogsReportPage()
+    {   
+        assertPage( "Apache Archiva \\ Audit Log Report" );
+        assertTextPresent( "Audit Log Report" );
+        
+        assertElementPresent( "repository" );
+        assertElementPresent( "groupId" );
+        assertElementPresent( "artifactId" );
+        assertElementPresent( "startDate" );
+        assertElementPresent( "endDate" );
+        assertElementPresent( "rowCount" );
+        assertButtonWithValuePresent( "View Audit Log" );
+    }
+    
+    @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+    public void testAuditLogsReport()
+    {
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        assertTextPresent( "Latest Events" );
+    }
+    
+    @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+    public void testViewAuditLogsNoDataFound()
+    {
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        
+        setFieldValue( "groupId", "non.existing" );
+        submit();
+        
+        assertPage( "Apache Archiva \\ Audit Log Report" );   
+        assertTextPresent( "Results" );
+        assertTextPresent( "No audit logs found." );
+    }    
+    
+    @Test (dependsOnMethods = { "testAddArtifactValidValues" } )
+    public void testViewAuditLogsDataFound()
+    {
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        
+        selectValue( "repository", "internal" );
+        setFieldValue( "groupId", "test" );
+        submit();
+                
+        assertAuditLogsReportPage();
+        assertTextPresent( "Results" );
+        assertTextNotPresent( "No audit logs found." );
+        assertTextPresent( "test-1.0.jar" );
+        assertTextPresent( "Uploaded File" );
+        assertTextPresent( "internal" );
+        assertTextPresent( "admin" );
+    }
+    
+    @Test (dependsOnMethods = { "testViewAuditLogsDataFound" } )
+    public void testViewAuditLogsOnlyArtifactIdIsSpecified()
+    {
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        
+        selectValue( "repository", "internal" );
+        setFieldValue( "artifactId", "test" );
+        submit();
+                
+        assertAuditLogsReportPage();
+        assertTextPresent( "Results" );
+        assertTextNotPresent( "No audit logs found." );
+        assertTextPresent( "test-1.0.jar" );
+        assertTextPresent( "Uploaded File" );
+        assertTextPresent( "internal" );
+        assertTextPresent( "admin" );
+    }
+    
+    @Test (dependsOnMethods = { "testViewAuditLogsOnlyArtifactIdIsSpecified" } )
+    public void testViewAuditLogsForAllRepositories()
+    {
+        goToAuditLogReports();        
+        assertAuditLogsReportPage();
+        
+        selectValue( "repository", "all" );
+        submit();
+        
+        assertAuditLogsReportPage();
+        assertTextPresent( "Results" );
+        assertTextNotPresent( "No audit logs found." );
+        assertTextPresent( "test-1.0.jar" );
+        assertTextPresent( "Uploaded File" );
+        assertTextPresent( "internal" );
+        assertTextPresent( "admin" );
+    }
+}
index 5a1d04da7fc84d6d00de20dcb049151bc1da1f09..ad1d38875579179274ac979602ae9205e19b5742 100644 (file)
@@ -20,11 +20,14 @@ package org.apache.maven.archiva.web.action;
  */\r
 \r
 import java.util.ArrayList;\r
+import java.util.Calendar;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
 import javax.servlet.http.HttpServletRequest;\r
 \r
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;\r
+import org.apache.maven.archiva.model.ArchivaAuditLogs;\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
@@ -53,6 +56,11 @@ public abstract class PlexusActionSupport
      */\r
     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();\r
 \r
+    /**\r
+     * @plexus.requirement role-hint="jdo"\r
+     */\r
+    private ArchivaAuditLogsDao auditLogsDao;    \r
+\r
     private String principal;\r
 \r
     @SuppressWarnings("unchecked")\r
@@ -85,6 +93,15 @@ public abstract class PlexusActionSupport
         {\r
             listener.auditEvent( event );\r
         }\r
+        \r
+        ArchivaAuditLogs auditLogs = new ArchivaAuditLogs();\r
+        auditLogs.setArtifact( resource );\r
+        auditLogs.setEvent( action );\r
+        auditLogs.setEventDate( Calendar.getInstance().getTime() );\r
+        auditLogs.setRepositoryId( repositoryId );\r
+        auditLogs.setUsername( getPrincipal() );\r
+        \r
+        auditLogsDao.saveAuditLogs( auditLogs );\r
     }\r
 \r
     protected void triggerAuditEvent( String resource, String action )\r
@@ -129,4 +146,9 @@ public abstract class PlexusActionSupport
     {\r
         this.principal = principal;\r
     }\r
+    \r
+    public void setAuditLogsDao( ArchivaAuditLogsDao auditLogsDao )\r
+    {\r
+        this.auditLogsDao = auditLogsDao;\r
+    }\r
 }\r
index c61ba16ffd10ca6d8561a0dbb0274c6288f77713..0796850c96d632d11095e3978e2dd95bcaf7b9ef 100644 (file)
@@ -149,7 +149,7 @@ public class UploadAction
      * @plexus.requirement
      */
     private ArchivaTaskScheduler scheduler;
-
+    
     private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5};
 
     private ProjectModelWriter pomWriter = new ProjectModel400Writer();
@@ -423,7 +423,7 @@ public class UploadAction
             String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version +
                 "\' was successfully deployed to repository \'" + repositoryId + "\'";
 
-            triggerAuditEvent( repositoryId, groupId + ":" + artifactId + ":" + version, AuditEvent.UPLOAD_FILE );
+            triggerAuditEvent( repositoryId, artifactPath, AuditEvent.UPLOAD_FILE );  
 
             addActionMessage( msg );
 
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
new file mode 100644 (file)
index 0000000..298a6d9
--- /dev/null
@@ -0,0 +1,433 @@
+package org.apache.maven.archiva.web.action.reports;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.SimpleConstraint;
+import org.apache.maven.archiva.database.constraints.ArchivaAuditLogsConstraint;
+import org.apache.maven.archiva.database.constraints.MostRecentArchivaAuditLogsConstraint;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
+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;
+import org.apache.maven.archiva.security.UserRepositories;
+import org.apache.maven.archiva.web.action.PlexusActionSupport;
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+
+import com.opensymphony.xwork2.Preparable;
+
+/**
+ * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="viewAuditLogReport"
+ *                   instantiation-strategy="per-lookup"
+ */
+public class ViewAuditLogReportAction
+    extends PlexusActionSupport
+    implements SecureAction, ServletRequestAware, Preparable
+{
+    protected HttpServletRequest request;
+
+    /**
+     * @plexus.requirement
+     */
+    private UserRepositories userRepositories;
+
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ArchivaDAO dao;
+
+    private String repository;
+
+    private List<String> repositories;
+
+    private String groupId;
+
+    private String artifactId;
+
+    private String startDate;
+
+    private String endDate;
+    
+    private int rowCount = 30;
+
+    private int page = 1;
+
+    private String prev;
+
+    private String next;
+
+    protected boolean isLastPage = true;
+
+    private List<ArchivaAuditLogs> auditLogs;
+
+    private static final String ALL_REPOSITORIES = "all";
+
+    protected int[] range = new int[2];
+    
+    private String initial = "true";
+    
+    private String headerName;
+    
+    private static final String HEADER_LATEST_EVENTS = "Latest Events";
+    
+    private static final String HEADER_RESULTS = "Results";
+    
+    private String[] datePatterns = new String[] { "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", 
+        "dd MMMMM yyyy", "dd/MM/yy", "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy",
+        "MM-dd-yy" };
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        return null;
+    }
+
+    public void setServletRequest( HttpServletRequest request )
+    {
+        this.request = request;
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void prepare()
+        throws Exception
+    {
+        repositories = new ArrayList<String>();
+        repositories.add( ALL_REPOSITORIES );
+        repositories.addAll( getObservableRepositories() );
+
+        auditLogs = null;
+        groupId = "";
+        artifactId = "";
+        repository = "";
+                
+        if( Boolean.parseBoolean( initial ) )
+        {
+            headerName = HEADER_LATEST_EVENTS;
+        }
+        else
+        {
+            headerName = HEADER_RESULTS;
+        }
+
+        SimpleConstraint constraint = new MostRecentArchivaAuditLogsConstraint();
+        auditLogs = (List<ArchivaAuditLogs>) dao.query( constraint );
+    }
+
+    public String execute()
+        throws Exception
+    {
+        auditLogs = null;
+        String artifact = "";
+        
+        if ( groupId != null && !"".equals( groupId.trim() ) )
+        {
+            artifact = groupId + ( ( artifactId != null  && !"".equals( artifactId.trim() ) ) ? ( "/" + artifactId + "/%" ) : "%" );
+        }
+        else
+        {               
+            artifact = ( artifactId != null  && !"".equals( artifactId.trim() ) ) ? ( "%" + artifactId + "%" ) : "";
+        }        
+                
+        Date startDateInDF = null;
+        Date endDateInDF = null;        
+        if ( startDate == null || "".equals( startDate ) )
+        {            
+            Calendar cal = Calendar.getInstance();
+            cal.set( Calendar.HOUR, 0 );
+            cal.set( Calendar.MINUTE, 0 );
+            cal.set( Calendar.SECOND, 0 );
+
+            startDateInDF = cal.getTime();
+        }
+        else
+        {
+            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
+        }
+
+        if ( endDate == null || "".equals( endDate ) )
+        {
+            endDateInDF = Calendar.getInstance().getTime();
+        } 
+        else
+        {
+            endDateInDF = DateUtils.parseDate( endDate, datePatterns );
+            Calendar cal = Calendar.getInstance();
+            cal.setTime( endDateInDF );
+            cal.set( Calendar.HOUR, 23 );
+            cal.set( Calendar.MINUTE, 59 );
+            cal.set( Calendar.SECOND, 59 );
+            
+            endDateInDF = cal.getTime();            
+        }
+
+        range[0] = ( page - 1 ) * rowCount;
+        range[1] = ( page * rowCount ) + 1;
+        
+        ArchivaAuditLogsConstraint constraint = null;
+        if ( !repository.equals( ALL_REPOSITORIES ) )
+        {
+            constraint =
+                new ArchivaAuditLogsConstraint( range, artifact, repository, AuditEvent.UPLOAD_FILE, startDateInDF, endDateInDF );
+        }
+        else
+        {
+            constraint =
+                new ArchivaAuditLogsConstraint( range, artifact, null, AuditEvent.UPLOAD_FILE, startDateInDF, endDateInDF );
+        }
+
+        try
+        {
+            auditLogs = auditLogsDao.queryAuditLogs( constraint );            
+            if( auditLogs.isEmpty() )
+            {
+                addActionError( "No audit logs found." );
+                initial = "true";                
+            }
+            else
+            {   
+                initial = "false";
+            }
+            
+            headerName = HEADER_RESULTS;         
+            paginate();
+        }
+        catch ( ObjectNotFoundException e )
+        {
+            addActionError( "No audit logs found." );
+            return ERROR;
+        }
+        catch ( ArchivaDatabaseException e )
+        {
+            addActionError( "Error occurred while querying audit logs." );
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+    
+    private void paginate()
+    {
+        if ( auditLogs.size() <= rowCount )
+        {
+            isLastPage = true;
+        }
+        else
+        {   
+            isLastPage = false;
+            auditLogs.remove( rowCount );
+        }
+
+        prev =
+            request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId +
+                "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate=" +
+                endDate;
+        
+        next =
+            request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId +
+                "&artifactId=" + artifactId + "&repository=" + repository + "&startDate=" + startDate + "&endDate=" +
+                endDate;
+        
+        prev = StringUtils.replace( prev, " ", "%20" );
+        next = StringUtils.replace( next, " ", "%20" );
+    }
+
+    private List<String> getObservableRepositories()
+    {
+        try
+        {
+            return userRepositories.getObservableRepositoryIds( getPrincipal() );
+        }
+        catch ( PrincipalNotFoundException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( AccessDeniedException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        catch ( ArchivaSecurityException e )
+        {
+            log.warn( e.getMessage(), e );
+        }
+        return Collections.emptyList();
+    }
+
+    public String getRepository()
+    {
+        return repository;
+    }
+
+    public void setRepository( String repository )
+    {
+        this.repository = repository;
+    }
+
+    public List<String> getRepositories()
+    {
+        return repositories;
+    }
+
+    public void setRepositories( List<String> repositories )
+    {
+        this.repositories = repositories;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public List<ArchivaAuditLogs> getAuditLogs()
+    {
+        return auditLogs;
+    }
+
+    public void setAuditLogs( List<ArchivaAuditLogs> auditLogs )
+    {
+        this.auditLogs = auditLogs;
+    }
+
+    public int getRowCount()
+    {
+        return rowCount;
+    }
+
+    public void setRowCount( int rowCount )
+    {
+        this.rowCount = rowCount;
+    }
+
+    public String getStartDate()
+    {
+        return startDate;
+    }
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+
+    public String getEndDate()
+    {
+        return endDate;
+    }
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    public int getPage()
+    {
+        return page;
+    }
+
+    public void setPage( int page )
+    {
+        this.page = page;
+    }
+
+    public boolean getIsLastPage()
+    {
+        return isLastPage;
+    }
+
+    public void setIsLastPage( boolean isLastPage )
+    {
+        this.isLastPage = isLastPage;
+    }
+    
+    public String getPrev()
+    {
+        return prev;
+    }
+
+    public void setPrev( String prev )
+    {
+        this.prev = prev;
+    }
+
+    public String getNext()
+    {
+        return next;
+    }
+
+    public void setNext( String next )
+    {
+        this.next = next;
+    }
+    
+    public String getInitial()
+    {
+        return initial;
+    }
+
+    public void setInitial( String initial )
+    {
+        this.initial = initial;
+    }
+
+    public String getHeaderName()
+    {
+        return headerName;
+    }
+
+    public void setHeaderName( String headerName )
+    {
+        this.headerName = headerName;
+    }
+}
index 8df1acfddd5ba7958afec57346501f9c6f44697f..13884333594be782554050018dc9c1ff599f99ff 100644 (file)
       </result>
     </action>
     
+    <!--  audit logs -->
+    <action name="queryAuditLogReport" class="viewAuditLogReport" method="input">
+      <result name="input">/WEB-INF/jsp/reports/auditLogReport.jsp</result>
+    </action>
+    
+    <action name="viewAuditLogReport" class="viewAuditLogReport">
+      <result name="input">/WEB-INF/jsp/reports/auditLogReport.jsp</result>
+      <result>/WEB-INF/jsp/reports/auditLogReport.jsp</result>
+    </action>
+    
   </package>
 </struts>
 
index 52ec32bbeb163dedd380daf931c8e7204397bace..4dc48af6db35b7b44a4304a101a73353d884f5dd 100644 (file)
@@ -80,7 +80,7 @@
       </li>
     </ul>
 
-    <redback:ifAnyAuthorized permissions="archiva-upload-repository,archiva-delete-artifact,archiva-manage-users,archiva-access-reports,archiva-manage-configuration">
+    <redback:ifAnyAuthorized permissions="archiva-upload-repository,archiva-delete-artifact,archiva-manage-users,archiva-access-reports,archiva-manage-configuration,archiva-view-audit-logs">
       <h5>Manage</h5>
       <ul>
         <redback:ifAuthorized permission="archiva-access-reports">
             <my:currentWWUrl action="pickReport" namespace="/report">Reports</my:currentWWUrl>
           </li>
         </redback:ifAuthorized>
+        <redback:ifAuthorized permission="archiva-view-audit-logs">
+          <li class="none">
+            <my:currentWWUrl action="queryAuditLogReport" namespace="/report">Audit Log Report</my:currentWWUrl>
+          </li>
+        </redback:ifAuthorized>
         <redback:ifAuthorized permission="archiva-manage-users">
           <li class="none">
             <my:currentWWUrl action="userlist" namespace="/security">User Management</my:currentWWUrl>
           <li class="none">
             <my:currentWWUrl action="deleteArtifact" namespace="/">Delete Artifact</my:currentWWUrl>
           </li>
-        </redback:ifAuthorized>
+        </redback:ifAuthorized>        
           <%-- TODO: future options here.
              * Repository Statistics.
              * Web Services Statistics.
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
new file mode 100644 (file)
index 0000000..664f8e7
--- /dev/null
@@ -0,0 +1,152 @@
+<%--
+  ~ 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.
+  --%>
+
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib uri="http://www.extremecomponents.org" prefix="ec" %>
+
+<html>
+<head>
+
+  <title>Audit Log Report</title>
+  <s:head theme="ajax" />
+  
+  <link rel="stylesheet" href="<c:url value='/css/ui.datepicker.css'/>" type="text/css" media="all"/>
+  <script type="text/javascript" src="<c:url value='/js/jquery/jquery-1.2.6.pack.js'/>"></script>
+  <script type="text/javascript" src="<c:url value='/js/jquery/ui.datepicker.packed.js'/>"></script>
+  <script type="text/javascript" charset="utf-8">
+    $(document).ready(function()
+    {
+               $('#startDate').datepicker()
+               $('#endDate').datepicker()
+    });
+  </script>
+</head>
+
+<body>
+<h1>Audit Log Report</h1>
+  
+<div id="contentArea">
+  
+  <s:form action="viewAuditLogReport" namespace="/report" validate="false">
+     
+    <s:hidden name="initial"/>
+    
+    <div id="auditLogReport">  
+        <table id="auditLogFieds">
+          <tbody>
+            <tr>
+                     <td>Repository: </td>
+                     <td><s:select name="repository" list="repositories" theme="simple"/></td>
+                   <tr>
+                   <tr>
+                     <td>Group ID: </td>
+                     <td><s:textfield id="groupId" name="groupId" theme="simple"/></td>
+                   <tr>
+                   <tr>
+                     <td>Artifact ID: </td>
+                     <td><s:textfield id="artifactId" name="artifactId" theme="simple"/></td>
+                   <tr>
+                   <tr>
+                     <td>Start Date: </td>
+                     <td><s:textfield id="startDate" name="startDate" theme="simple"/>       
+                           <%--
+                           <script type="text/javascript">
+                             Calendar.setup({
+                               inputField     :    "startDate",     
+                               ifFormat       :    "%Y-%m-%d",             
+                               align          :    "Tl",           
+                               singleClick    :    true
+                             });
+                           </script>
+                           --%>
+                 </td>
+                   <tr>
+                   <tr>
+                     <td>End Date: </td>
+                     <td><s:textfield id="endDate" name="endDate" theme="simple"/>
+                               <%--
+                               <script type="text/javascript">
+                             Calendar.setup({
+                               inputField     :    "endDate",     
+                               ifFormat       :    "%Y-%m-%d",             
+                               align          :    "Tl",           
+                               singleClick    :    true
+                             });
+                           </script>
+                               --%>                    
+                 </td>
+                   <tr>
+                   <tr>
+                     <td>Row Count: </td>
+                     <td><s:textfield name="rowCount" theme="simple"/></td>
+                   <tr>
+                   <tr>
+                     <td/>
+                     <td style="text-align: right"><s:submit value="View Audit Log" theme="simple"/></td>
+                   </tr>
+                 </tbody>
+               </table>        
+    </div>    
+    
+    <p/>
+    
+    <div class="auditLogReportResults">
+    
+    <h2>${headerName}</h2>
+      <p>
+        <s:actionerror/>
+      </p>
+        
+           <c:if test="${not empty (auditLogs)}">  
+                 <table class="auditlogs" cellspacing="0">
+                <tr>
+                       <th>Event</th>
+                       <th>Repository</th>
+                       <th>Artifact</th>
+                       <th>Event Date</th>
+                       <th>Username</th>
+                     </tr>
+                   
+                   <c:forEach items="${auditLogs}" var="auditLog" varStatus="i">           
+                     <tr>
+                       <td>${auditLog.event}</td>
+                       <td>${auditLog.repositoryId}</td>
+                       <td>${auditLog.artifact}</td>
+                       <td>${auditLog.eventDate}</td>
+                       <td>${auditLog.username}</td>
+                     </tr>                 
+                   </c:forEach>
+                 </table>      
+                 
+                 <s:set name="page" value="page"/>
+             <c:if test="${page > 1}"><a href="<s:property value='prev' />">&lt;&lt;</a></c:if>
+                         <strong>Page: </strong>${page}
+                 <s:set name="isLastPage" value="isLastPage"/>           
+                 <c:if test="${!isLastPage}"><a href="<s:property value='next' />">&gt;&gt;</a></c:if>
+               </c:if>  
+       </div>
+   
+  </s:form>
+    
+  
+</div>
+
+</body>
+</html>
index a68b439a235caa1f733e4ce6d5e76fb83e245114..99661460890ba5b59f7037c1e9728aba19c5ab83 100644 (file)
@@ -435,4 +435,46 @@ div.versions {
 div.versions a.expand {
     font-size: 7pt;
        color: gray;    
-}
\ No newline at end of file
+}
+
+table.auditlogs {
+       text-align: center;
+       font-family: Verdana, Geneva, Arial, Helvetica, sans-serif ;
+       font-weight: normal;
+       font-size: 11px;
+       color: #fff;
+       width: 100%;
+       background-color: #666;
+       border: 0px;
+       border-collapse: collapse;
+       border-spacing: 0px;
+}
+
+table.auditlogs th {
+       background-color: #666;
+       color: #fff;
+       padding: 4px;
+       text-align: center;
+       border-bottom: 2px #fff solid;
+       font-size: 12px;
+       font-weight: bold;
+}
+
+table.auditlogs td {
+       background-color: #CCC;
+       color: #000;
+       padding: 4px;
+       text-align: center;
+       border: 1px #fff solid;
+}
+
+div.auditLogReportResults {
+       border: 1px dashed #DFDEDE;
+       margin-bottom: 15px;
+       margin-left: 2px;
+       padding: 5px;
+}
+
+
+
+
index f86660c56dc60e8190525ddf4fe770f8db2c585f..1af6eda88c24c5dba8f3489585029080b158e02b 100644 (file)
@@ -31,6 +31,8 @@ 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.configuration.RepositoryScanningConfiguration;
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
@@ -62,10 +64,14 @@ public class UploadActionTest
     private RepositoryContentFactory repoFactory;
 
     private MockControl repoFactoryControl;
+    
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    private MockControl auditLogsDaoControl;
 
     private static final String REPOSITORY_ID = "test-repo";
 
-    private Configuration config;
+    private Configuration config;    
 
     public void setUp()
         throws Exception
@@ -80,11 +86,16 @@ public class UploadActionTest
 
         repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
         repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
+        
+        auditLogsDaoControl = MockControl.createControl( ArchivaAuditLogsDao.class );
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        auditLogsDao = (ArchivaAuditLogsDao) auditLogsDaoControl.getMock();
 
         uploadAction = new UploadAction();
         uploadAction.setScheduler( scheduler );
         uploadAction.setConfiguration( archivaConfig );
         uploadAction.setRepositoryFactory( repoFactory );
+        uploadAction.setAuditLogsDao( auditLogsDao );
 
         File testRepo = new File( getBasedir(), "target/test-classes/test-repo" );
         testRepo.mkdirs();
@@ -216,16 +227,19 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
 
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
-
+        auditLogsDaoControl.verify();
+        
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
 
@@ -245,15 +259,18 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
 
         archivaConfigControl.replay();
         repoFactoryControl.replay();
-
+        auditLogsDaoControl.replay();
+        
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
@@ -319,15 +336,18 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
 
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
@@ -377,15 +397,18 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        
         archivaConfigControl.replay();
         repoFactoryControl.replay();
-
+        auditLogsDaoControl.replay();
+       
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertEquals( 6, new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list().length );
@@ -412,18 +435,23 @@ public class UploadActionTest
         
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
         
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         archivaConfigControl.reset();
         repoFactoryControl.reset();
+        auditLogsDaoControl.reset();
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
@@ -438,15 +466,18 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
 
         returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
@@ -467,9 +498,11 @@ public class UploadActionTest
 
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
-
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
@@ -484,6 +517,7 @@ public class UploadActionTest
 
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
@@ -506,9 +540,11 @@ public class UploadActionTest
     
         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null, 2 );
     
         archivaConfigControl.replay();
         repoFactoryControl.replay();
+        auditLogsDaoControl.replay();
     
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
@@ -523,6 +559,7 @@ public class UploadActionTest
         
         archivaConfigControl.verify();
         repoFactoryControl.verify();
+        auditLogsDaoControl.verify();
     
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation );
index b510a144d1bcf6039d0ab4d5a446cbaccf4ddefb..becbd156ef66d929b3b342ee4498650f50445657 100644 (file)
@@ -40,7 +40,7 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase
     private MockControl archivaConfigurationControl;
 
     private ArchivaConfiguration archivaConfiguration;
-
+    
     public void testConfirmDisableBadSourceOrTarget()
         throws Exception
     {
index 5ef78ba397865c59be09d7ef88a2e98ae188c209..7accb4b7cf76ad9ad7caca4902b09996fce6b1ec 100644 (file)
@@ -24,6 +24,8 @@ import org.apache.commons.io.FileUtils;
 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.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
@@ -51,6 +53,10 @@ public class AddManagedRepositoryActionTest
     private MockControl archivaConfigurationControl;
 
     private ArchivaConfiguration archivaConfiguration;
+    
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    private MockControl auditLogsDaoControl;
 
     private static final String REPO_ID = "repo-ident";
 
@@ -74,6 +80,11 @@ public class AddManagedRepositoryActionTest
         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
         action.setArchivaConfiguration( archivaConfiguration );
 
+        auditLogsDaoControl = MockControl.createControl( ArchivaAuditLogsDao.class );
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        auditLogsDao = (ArchivaAuditLogsDao) auditLogsDaoControl.getMock();
+        action.setAuditLogsDao( auditLogsDao );
+        
         roleManagerControl = MockControl.createControl( RoleManager.class );
         roleManager = (RoleManager) roleManagerControl.getMock();
         action.setRoleManager( roleManager );
@@ -148,15 +159,18 @@ public class AddManagedRepositoryActionTest
         ManagedRepositoryConfiguration repository = action.getRepository();
         populateRepository( repository );
 
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         assertFalse( location.exists() );
         String status = action.commit();
         assertEquals( Action.SUCCESS, status );
-        assertTrue( location.exists() );
-
+        assertTrue( location.exists() );        
         assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
 
         roleManagerControl.verify();
         archivaConfigurationControl.verify();
+        auditLogsDaoControl.verify();
     }
     
     
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaAuditLogsDaoStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaAuditLogsDaoStub.java
new file mode 100644 (file)
index 0000000..933aeb1
--- /dev/null
@@ -0,0 +1,34 @@
+package org.apache.maven.archiva.web.action.admin.repositories;
+
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
+
+public class ArchivaAuditLogsDaoStub
+    implements ArchivaAuditLogsDao
+{
+
+    public void deleteAuditLogs( ArchivaAuditLogs logs )
+        throws ArchivaDatabaseException
+    {
+        // TODO Auto-generated method stub
+    }
+
+    public List<ArchivaAuditLogs> queryAuditLogs( Constraint constraint )
+        throws ObjectNotFoundException, ArchivaDatabaseException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public ArchivaAuditLogs saveAuditLogs( ArchivaAuditLogs logs )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
index 8d8c4b2b9fdeb70ab009eec846af8468f2d49bbf..ccd69f49f0514cf1d22f6aeda24e25c01590043d 100644 (file)
@@ -27,6 +27,8 @@ 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.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.model.ArchivaProjectModel;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.codehaus.plexus.redback.role.RoleManager;
@@ -60,6 +62,10 @@ public class DeleteManagedRepositoryActionTest
 
     private ArchivaConfiguration archivaConfiguration;
     
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    private MockControl auditLogsDaoControl;
+    
     private static final String REPO_ID = "repo-ident";
 
     private File location;
@@ -80,6 +86,11 @@ public class DeleteManagedRepositoryActionTest
         archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
         action.setArchivaConfiguration( archivaConfiguration );
+        
+        auditLogsDaoControl = MockControl.createControl( ArchivaAuditLogsDao.class );
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        auditLogsDao = (ArchivaAuditLogsDao) auditLogsDaoControl.getMock();
+        action.setAuditLogsDao( auditLogsDao );
 
         roleManagerControl = MockControl.createControl( RoleManager.class );
         roleManager = (RoleManager) roleManagerControl.getMock();
@@ -117,9 +128,10 @@ public class DeleteManagedRepositoryActionTest
         ManagedRepositoryConfiguration repository = action.getRepository();
         assertNotNull( repository );
         assertRepositoryEquals( repository, createRepository() );
-
+        
         String status = action.execute();
         assertEquals( Action.SUCCESS, status );
+                
         repository = action.getRepository();
         assertRepositoryEquals( repository, createRepository() );
         assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories() );
@@ -132,8 +144,13 @@ public class DeleteManagedRepositoryActionTest
         
         Configuration configuration = prepDeletionTest( createRepository(), 4 );                
         
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         String status = action.deleteEntry();        
                 
+        auditLogsDaoControl.verify();
+        
         assertEquals( Action.SUCCESS, status );
 
         assertTrue( configuration.getManagedRepositories().isEmpty() );
@@ -148,7 +165,12 @@ public class DeleteManagedRepositoryActionTest
         
         Configuration configuration = prepDeletionTest( createRepository(), 4 );              
         
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         String status = action.deleteContents();
+        
+        auditLogsDaoControl.verify();
                
         assertEquals( Action.SUCCESS, status );
 
@@ -169,7 +191,12 @@ public class DeleteManagedRepositoryActionTest
 
         assertEquals( 1, configuration.getProxyConnectors().size() );
         
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         String status = action.deleteContents();
+        
+        auditLogsDaoControl.verify();
         assertEquals( Action.SUCCESS, status );
 
         assertTrue( configuration.getManagedRepositories().isEmpty() );
@@ -183,6 +210,7 @@ public class DeleteManagedRepositoryActionTest
     {
         ManagedRepositoryConfiguration originalRepository = createRepository();
         Configuration configuration = prepDeletionTest( originalRepository, 3 );
+                
         String status = action.execute();
         assertEquals( Action.SUCCESS, status );
 
@@ -205,8 +233,12 @@ public class DeleteManagedRepositoryActionTest
 
         assertEquals( 1, configuration.getRepositoryGroups().size() );
         
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         String status = action.deleteContents();
         assertEquals( Action.SUCCESS, status );
+        auditLogsDaoControl.verify();
 
         assertTrue( configuration.getManagedRepositories().isEmpty() );
         assertEquals( 0, ( ( RepositoryGroupConfiguration ) configuration.getRepositoryGroups().get( 0 ) ).getRepositories().size() );
index e688f8a29d26da9fc332eefe6e7147c14d771d24..6f9bdf16246b0b49253eb16eda53c6d3dffd705d 100644 (file)
@@ -23,9 +23,11 @@ import com.opensymphony.xwork2.Action;
 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.ArchivaDAO;
 import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
 import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.codehaus.plexus.redback.role.RoleManager;
@@ -66,6 +68,10 @@ public class EditManagedRepositoryActionTest
     private MockControl repoContentStatsDaoControl;
 
     private RepositoryContentStatisticsDAO repoContentStatsDao;
+    
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    private MockControl auditLogsDaoControl;
 
     private static final String REPO_ID = "repo-ident";
 
@@ -96,6 +102,11 @@ public class EditManagedRepositoryActionTest
         archivaDaoControl = MockControl.createControl( ArchivaDAO.class );
         archivaDao = (ArchivaDAO) archivaDaoControl.getMock();
         action.setArchivaDAO( archivaDao );
+        
+        auditLogsDaoControl = MockControl.createControl( ArchivaAuditLogsDao.class );
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        auditLogsDao = (ArchivaAuditLogsDao) auditLogsDaoControl.getMock();
+        action.setAuditLogsDao( auditLogsDao );
 
         repoContentStatsDaoControl = MockControl.createControl( RepositoryContentStatisticsDAO.class );
         repoContentStatsDao = (RepositoryContentStatisticsDAO) repoContentStatsDaoControl.getMock();
@@ -167,10 +178,13 @@ public class EditManagedRepositoryActionTest
         ManagedRepositoryConfiguration repository = action.getRepository();
         populateRepository( repository );
         repository.setName( "new repo name" );
-
+        
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         String status = action.commit();
         assertEquals( Action.SUCCESS, status );
-
+        
         ManagedRepositoryConfiguration newRepository = createRepository();
         newRepository.setName( "new repo name" );
         assertRepositoryEquals( repository, newRepository );
@@ -178,6 +192,7 @@ public class EditManagedRepositoryActionTest
 
         roleManagerControl.verify();
         archivaConfigurationControl.verify();
+        auditLogsDaoControl.verify();
     }
 
     public void testEditRepositoryLocationChanged()
@@ -226,6 +241,9 @@ public class EditManagedRepositoryActionTest
         action.prepare();
         assertEquals( REPO_ID, action.getRepoid() );
         
+        auditLogsDaoControl.expectAndReturn( auditLogsDao.saveAuditLogs( new ArchivaAuditLogs() ), null );
+        auditLogsDaoControl.replay();
+        
         ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
         populateRepository( repository );
         repository.setLocation( new File( "target/test/location/new" ).getCanonicalPath() );
@@ -238,6 +256,7 @@ public class EditManagedRepositoryActionTest
         archivaConfigurationControl.verify();
         archivaDaoControl.verify();
         repoContentStatsDaoControl.verify();
+        auditLogsDaoControl.verify();
     }
     
     private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository,
index cccf675cb7c6da8c0f948304bbdc873e24989d45..bb19ef4c11b35f68c072057c33f20d1d47eb083f 100644 (file)
       <role-hint>default</role-hint>
       <implementation>org.apache.maven.archiva.security.UserRepositoriesStub</implementation>
     </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
index d51572b7fd88102ca930ab325a16b0542e1959a8..ecd72a3ae628a1b399c0e1dc868a40411c11ba00 100644 (file)
       <role-hint>default</role-hint>
       <implementation>org.apache.maven.archiva.security.UserRepositoriesStub</implementation>
     </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index dc32d3f3d1745b37cb9297e31f754862bb2446f8..4ae525c16dd4713ba5e28d57cbc29c217f287cd3 100644 (file)
         <time-to-live-seconds>1800</time-to-live-seconds>
       </configuration>
     </component>    
-    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index dc32d3f3d1745b37cb9297e31f754862bb2446f8..a0b969b58d55abb562dc1457ba574eef8cc41981 100644 (file)
         <!-- 30 minutes = 1800 seconds  -->
         <time-to-live-seconds>1800</time-to-live-seconds>
       </configuration>
-    </component>    
-    
+    </component>  
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index afb64ee15a5010618355b6c09f999fe8bc2b2abb..673e760e88b9ea4d842d1cf5dce979d2a316d8dc 100644 (file)
       <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role>
       <role-hint>jdo</role-hint>
       <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub</implementation>
-    </component>        
-    
+    </component>       
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index f4d20ee6176cb4197c037552d761aacfb421bba5..0a8e9e7432c308f5019aec62a5e4ea79f5782a8f 100644 (file)
       <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role>
       <role-hint>jdo</role-hint>
       <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub</implementation>
-    </component>        
+    </component> 
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>       
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index c09e524a2646d37853394752ad8d6536c09c4b6e..cac84b95291a445c972c932ececfb628889b4bec 100644 (file)
         </requirement>
       </requirements>
     </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/SortRepositoriesActionTest.xml
new file mode 100644 (file)
index 0000000..62b568b
--- /dev/null
@@ -0,0 +1,28 @@
+<!--
+  ~ 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.
+  -->
+
+<plexus>
+  <components>    
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
+  </components>
+</plexus>
index dc68e12af815d01802e1d5168870d1d427b46aa3..8f21c14626540a0e8479093e7722811c8b4b50a3 100644 (file)
       <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub
       </implementation>
     </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
-</component-set>
\ No newline at end of file
+</component-set>
index 0fec42f00fc78904ee3b652f475883a414e7dc87..bb6632ca2fa31e3af56ace29a0a11889f640d91b 100644 (file)
       <role-hint>default</role-hint>
       <implementation>org.apache.maven.archiva.security.UserRepositoriesStub</implementation>
     </component>
+    <component>
+      <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaAuditLogsDaoStub</implementation>
+    </component>
   </components>
 </plexus>
index 113aba0e5cdd9f87c3c77d856ab78daa8fbb8e3d..ec4f1b97bbba1300a5a12e6c85068cbe79b59062 100644 (file)
@@ -24,6 +24,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
@@ -54,6 +55,8 @@ 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.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.repository.audit.AuditEvent;
 import org.apache.maven.archiva.repository.audit.AuditListener;
 import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
@@ -104,11 +107,13 @@ public class ArchivaDavResource
     private ArchivaTaskScheduler scheduler;
     
     private Logger log = LoggerFactory.getLogger( ArchivaDavResource.class );
+    
+    private ArchivaAuditLogsDao auditLogsDao;
 
     public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
                                DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory,
                                MimeTypes mimeTypes, List<AuditListener> auditListeners,
-                               ArchivaTaskScheduler scheduler )
+                               ArchivaTaskScheduler scheduler, ArchivaAuditLogsDao auditLogsDao )
     {
         this.localResource = new File( localResource ); 
         this.logicalResource = logicalResource;
@@ -123,15 +128,16 @@ public class ArchivaDavResource
         this.mimeTypes = mimeTypes;        
         this.auditListeners = auditListeners;
         this.scheduler = scheduler;
+        this.auditLogsDao = auditLogsDao;
     }
 
     public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository,
                                String remoteAddr, String principal, DavSession session, ArchivaDavResourceLocator locator,
                                DavResourceFactory factory, MimeTypes mimeTypes, List<AuditListener> auditListeners,
-                               ArchivaTaskScheduler scheduler )
+                               ArchivaTaskScheduler scheduler, ArchivaAuditLogsDao auditLogsDao )
     {
         this( localResource, logicalResource, repository, session, locator, factory, mimeTypes, auditListeners,
-              scheduler );
+              scheduler, auditLogsDao );
 
         this.remoteAddr = remoteAddr;
         this.principal = principal;
@@ -641,6 +647,27 @@ public class ArchivaDavResource
         {
             listener.auditEvent( event );
         }
+        
+        // identify as artifact deployment/upload
+        if( action.equals( AuditEvent.CREATE_FILE ) )
+        {
+            action = AuditEvent.UPLOAD_FILE;
+        }
+        
+        String user = principal;
+        if( principal == null )
+        {
+            user = "guest";
+        }
+        
+        ArchivaAuditLogs auditLogs = new ArchivaAuditLogs();
+        auditLogs.setArtifact( resource );
+        auditLogs.setEvent( action );
+        auditLogs.setEventDate( Calendar.getInstance().getTime() );
+        auditLogs.setRepositoryId( repositoryId );
+        auditLogs.setUsername( user );
+        
+        auditLogsDao.saveAuditLogs( auditLogs );
     }
     
     private void queueRepositoryTask( File localFile )
index a297659f5202a6fa824cfbfccf91a678f9aece70..2684c8ef2c61e6d7748ba3c761c5914663a1ef48 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.maven.archiva.common.utils.PathUtil;
 import org.apache.maven.archiva.common.utils.VersionUtil;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
 import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.policies.ProxyDownloadException;
@@ -168,6 +169,11 @@ public class ArchivaDavResourceFactory
      * @plexus.requirement
      */
     private ArchivaTaskScheduler scheduler;
+    
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ArchivaAuditLogsDao auditLogsDao;
 
     public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request,
                                        final DavServletResponse response )
@@ -264,7 +270,7 @@ public class ArchivaDavResourceFactory
                             new ArchivaDavResource( metadataChecksum.getAbsolutePath(), logicalResource.getPath(),
                                                     null, request.getRemoteAddr(), activePrincipal,
                                                     request.getDavSession(), archivaLocator, this, mimeTypes,
-                                                    auditListeners, scheduler );
+                                                    auditListeners, scheduler, auditLogsDao );
                     }
                 }
                 else
@@ -299,7 +305,7 @@ public class ArchivaDavResourceFactory
                                 new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
                                                         null, request.getRemoteAddr(), activePrincipal,
                                                         request.getDavSession(), archivaLocator, this, mimeTypes,
-                                                        auditListeners, scheduler );
+                                                        auditListeners, scheduler, auditLogsDao );
                         }
                         catch ( RepositoryMetadataException r )
                         {
@@ -418,7 +424,7 @@ public class ArchivaDavResourceFactory
             resource =
                 new ArchivaDavResource( resourceFile.getAbsolutePath(), path, managedRepository.getRepository(),
                                         request.getRemoteAddr(), activePrincipal, request.getDavSession(),
-                                        archivaLocator, this, mimeTypes, auditListeners, scheduler );
+                                        archivaLocator, this, mimeTypes, auditListeners, scheduler, auditLogsDao );
 
             if ( WebdavMethodUtil.isReadMethod( request.getMethod() ) )
             {
@@ -449,7 +455,7 @@ public class ArchivaDavResourceFactory
                                 new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
                                                         managedRepository.getRepository(), request.getRemoteAddr(),
                                                         activePrincipal, request.getDavSession(), archivaLocator, this,
-                                                        mimeTypes, auditListeners, scheduler );
+                                                        mimeTypes, auditListeners, scheduler, auditLogsDao );
                         }
                         catch ( LayoutException e )
                         {
@@ -529,7 +535,7 @@ public class ArchivaDavResourceFactory
                     log.debug( "Creating destination directory '" + destDir.getName() + "' (current user '" +
                         activePrincipal + "')" );
 
-                    triggerAuditEvent( request.getRemoteAddr(), logicalResource.getPath(), relPath,
+                    triggerAuditEvent( request.getRemoteAddr(), managedRepository.getId(), relPath,
                                        AuditEvent.CREATE_DIR, activePrincipal );
                 }
             }
@@ -565,7 +571,7 @@ public class ArchivaDavResourceFactory
         File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource );
         DavResource resource =
             new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource, managedRepository.getRepository(),
-                                    davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler );
+                                    davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler, auditLogsDao );
 
         resource.addLockManager( lockManager );
         return resource;
@@ -1093,4 +1099,9 @@ public class ArchivaDavResourceFactory
     {
         this.connectors = connectors;
     }
+    
+    public void setAuditLogsDao( ArchivaAuditLogsDao auditLogsDao )
+    {
+        this.auditLogsDao = auditLogsDao;
+    }
 }
index b2f38fdb430f011146aeab45b8c56231da04f61e..e5973b08c10bade92f2dce79428875b721653146 100644 (file)
@@ -33,6 +33,8 @@ 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.configuration.RepositoryGroupConfiguration;
+import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
@@ -81,6 +83,10 @@ public class ArchivaDavResourceFactoryTest
     private MockControl repoContentFactoryControl;
 
     private RepositoryContentFactory repoFactory;
+    
+    private ArchivaAuditLogsDao auditLogsDao;
+
+    private MockControl auditLogsDaoControl;
 
     public void setUp()
         throws Exception
@@ -96,6 +102,10 @@ public class ArchivaDavResourceFactoryTest
 
         archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        
+        auditLogsDaoControl = MockControl.createControl( ArchivaAuditLogsDao.class );
+        auditLogsDaoControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        auditLogsDao = (ArchivaAuditLogsDao) auditLogsDaoControl.getMock();
 
         config = new Configuration();
         config.addManagedRepository( createManagedRepository( RELEASES_REPO, new File( getBasedir(),
@@ -125,6 +135,7 @@ public class ArchivaDavResourceFactoryTest
         resourceFactory.setRepositoryFactory( repoFactory );
         resourceFactory.setRepositoryRequest( repoRequest );
         resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
+        resourceFactory.setAuditLogsDao( auditLogsDao );
     }
 
     private ManagedRepositoryConfiguration createManagedRepository( String id, String location, String layout )
@@ -392,7 +403,7 @@ public class ArchivaDavResourceFactoryTest
             long date = 2039842134;
             response.addDateHeader( "last-modified", date );
             responseControl.setVoidCallable();
-
+            
             archivaConfigurationControl.replay();
             repoContentFactoryControl.replay();
             requestControl.replay();
index 9379075853d8836d398bacf7cccd019f8a0b167b..a3c2d6eb92a192fda11f364a3c7a0686e584cc82 100644 (file)
@@ -20,7 +20,9 @@ package org.apache.maven.archiva.webdav;
  */
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.webdav.DavException;
@@ -37,12 +39,15 @@ 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.database.ArchivaAuditLogsDao;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.model.ArchivaAuditLogs;
 import org.apache.maven.archiva.repository.audit.AuditListener;
-import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
 import org.apache.maven.archiva.webdav.util.MimeTypes;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.spring.PlexusToSpringUtils;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 
 public class DavResourceTest
     extends PlexusInSpringTestCase
@@ -67,23 +72,27 @@ public class DavResourceTest
 
     private ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
     
+    private ArchivaAuditLogsDao auditLogsDao;
+    
     @Override
     protected void setUp()
         throws Exception
     {
         super.setUp();
         session = new ArchivaDavSession();
+        auditLogsDao = new ArchivaAuditLogsDaoImpl();
         mimeTypes = (MimeTypes) getApplicationContext().getBean( PlexusToSpringUtils.buildSpringId( MimeTypes.class ) );
         baseDir = getTestFile( "target/DavResourceTest" );
         baseDir.mkdirs();
         myResource = new File( baseDir, "myresource.jar" );
         assertTrue( "Could not create " + myResource.getAbsolutePath(), myResource.createNewFile() );
         resourceFactory = new RootContextDavResourceFactory();
+        
         resourceLocator =
-            (ArchivaDavResourceLocator) new ArchivaDavLocatorFactory().createResourceLocator( "/", REPOPATH );
+            (ArchivaDavResourceLocator) new ArchivaDavLocatorFactory().createResourceLocator( "/", REPOPATH );        
         resource = getDavResource( resourceLocator.getHref( false ), myResource );
         lockManager = new SimpleLockManager();
-        resource.addLockManager( lockManager );
+        resource.addLockManager( lockManager );        
     }
 
     @Override
@@ -98,7 +107,7 @@ public class DavResourceTest
     private DavResource getDavResource( String logicalPath, File file )
     {
         return new ArchivaDavResource( file.getAbsolutePath(), logicalPath, repository, session, resourceLocator,
-                                       resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null );
+                                       resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null, auditLogsDao );
     }
 
     public void testDeleteNonExistantResourceShould404()
@@ -305,7 +314,28 @@ public class DavResourceTest
         {
             return new ArchivaDavResource( baseDir.getAbsolutePath(), "/", repository, session, resourceLocator,
                                            resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(),
-                                           null );
+                                           null, auditLogsDao );
+        }
+    }
+    
+    private class ArchivaAuditLogsDaoImpl
+        implements ArchivaAuditLogsDao
+    {
+        public List<ArchivaAuditLogs> queryAuditLogs( Constraint constraint )
+            throws ObjectNotFoundException, ArchivaDatabaseException
+        {
+            return new ArrayList<ArchivaAuditLogs>();
+        }
+
+        public ArchivaAuditLogs saveAuditLogs( ArchivaAuditLogs logs )
+        {
+            return new ArchivaAuditLogs();
+        }
+    
+        public void deleteAuditLogs( ArchivaAuditLogs logs )
+            throws ArchivaDatabaseException
+        {
+        
         }
     }
 }
index 9066331de60ce78583b224b45c833060a40e0e96..f4119959fe52d67054af9e537918c0db3ca6b04a 100644 (file)
@@ -39,6 +39,7 @@ import org.codehaus.plexus.redback.authentication.AuthenticationResult;
 import org.codehaus.plexus.redback.authorization.UnauthorizedException;
 import org.codehaus.plexus.redback.system.DefaultSecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySession;
+import org.codehaus.plexus.redback.users.User;
 import org.codehaus.plexus.redback.users.memory.SimpleUser;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
@@ -352,11 +353,14 @@ public class RepositoryServletSecurityTest
         httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
         servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
 
+        User user = new SimpleUser();
+        user.setUsername( "admin" );
+        
         // ArchivaDavResourceFactory#isAuthorized()
         SecuritySession session = new DefaultSecuritySession();
         httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
         httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
+        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), user );
         servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
         servletAuthControl.expectAndReturn(
                                             servletAuth.isAuthorized( null, session, "internal",
index bd9196bdfd2f7261b34445a71c6f66fd43aa0490..719bc5f0154b422a71ff13292741f3cbe47d5888 100644 (file)
           <role>org.apache.maven.archiva.scheduled.ArchivaTaskScheduler</role>
           <field-name>scheduler</field-name>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+          <role-hint>jdo</role-hint>
+          <field-name>auditLogsDao</field-name>
+        </requirement>
       </requirements>
     </component>
     <component>
index 74a63e922ad7fac3cfc597ba9339c258ec15c561..4ee64c61bb5b53d8b84a25f69bf7af9c06310ef7 100644 (file)
           <role>org.apache.maven.archiva.scheduled.ArchivaTaskScheduler</role>
           <field-name>scheduler</field-name>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.database.ArchivaAuditLogsDao</role>
+          <role-hint>jdo</role-hint>
+          <field-name>auditLogsDao</field-name>
+        </requirement>
       </requirements>
     </component>
     <component>