summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-01-19 06:15:09 +0000
committerBrett Porter <brett@apache.org>2010-01-19 06:15:09 +0000
commit606c82cbcad53a9f2c0dd1212ce302e3c8626910 (patch)
tree721b99dd1c650636b7c9909eb843b909c0311ba1 /archiva-modules
parent685419f0824f9f788513d3f3c3b89eac58118fe6 (diff)
parent96c99628aab4b63d71e660b661120596868a7f25 (diff)
downloadarchiva-606c82cbcad53a9f2c0dd1212ce302e3c8626910.tar.gz
archiva-606c82cbcad53a9f2c0dd1212ce302e3c8626910.zip
merged recent changes from trunk, and reimplemented incoming audit log functionality as a plugin using the metadata repository
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@900664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-artifact-converter/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-common/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-converter/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/pom.xml2
-rwxr-xr-xarchiva-modules/archiva-base/archiva-model/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-policies/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java159
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-transaction/pom.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-xml-tools/pom.xml2
-rw-r--r--archiva-modules/archiva-base/pom.xml2
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml2
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml2
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml2
-rw-r--r--archiva-modules/archiva-scheduler/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-applet/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-rss/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-security/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java2
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jarbin0 -> 1981 bytes
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md51
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom24
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md51
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml12
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md51
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml1
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java22
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java131
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java43
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java27
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java10
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java62
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java39
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/pom.xml15
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java381
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml10
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp9
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp152
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp16
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css37
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java20
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java5
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java12
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java5
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java6
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml2
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/pom.xml2
-rw-r--r--archiva-modules/archiva-web/pom.xml2
-rw-r--r--archiva-modules/metadata/content-model.txt12
-rw-r--r--archiva-modules/metadata/metadata-model/pom.xml2
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacetFactory.java2
-rw-r--r--archiva-modules/metadata/metadata-repository-api/pom.xml2
-rw-r--r--archiva-modules/metadata/pom.xml2
-rw-r--r--archiva-modules/plugins/audit/pom.xml45
-rw-r--r--archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java41
-rw-r--r--archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditManager.java36
-rw-r--r--archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java154
-rw-r--r--archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java44
-rw-r--r--archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java507
-rw-r--r--archiva-modules/plugins/maven2-repository/pom.xml2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java5
-rw-r--r--archiva-modules/plugins/metadata-repository-file/pom.xml2
-rw-r--r--archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java2
-rw-r--r--archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java18
-rw-r--r--archiva-modules/plugins/pom.xml3
-rw-r--r--archiva-modules/plugins/problem-reports/pom.xml2
-rw-r--r--archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemFacetFactory.java5
-rw-r--r--archiva-modules/plugins/repository-statistics/pom.xml2
-rw-r--r--archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java3
-rw-r--r--archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java5
-rw-r--r--archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java5
-rw-r--r--archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java22
-rw-r--r--archiva-modules/pom.xml2
110 files changed, 2076 insertions, 221 deletions
diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/pom.xml b/archiva-modules/archiva-base/archiva-artifact-converter/pom.xml
index 7e5ee9023..47832322c 100644
--- a/archiva-modules/archiva-base/archiva-artifact-converter/pom.xml
+++ b/archiva-modules/archiva-base/archiva-artifact-converter/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-artifact-converter</artifactId>
<name>Archiva Artifact Converter</name>
diff --git a/archiva-modules/archiva-base/archiva-checksum/pom.xml b/archiva-modules/archiva-base/archiva-checksum/pom.xml
index bf525a970..5d7053fea 100644
--- a/archiva-modules/archiva-base/archiva-checksum/pom.xml
+++ b/archiva-modules/archiva-base/archiva-checksum/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-checksum</artifactId>
<name>Archiva Checksum</name>
diff --git a/archiva-modules/archiva-base/archiva-common/pom.xml b/archiva-modules/archiva-base/archiva-common/pom.xml
index 91bdca84e..995be9b2f 100644
--- a/archiva-modules/archiva-base/archiva-common/pom.xml
+++ b/archiva-modules/archiva-base/archiva-common/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-common</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-configuration/pom.xml b/archiva-modules/archiva-base/archiva-configuration/pom.xml
index bae414035..ee8903172 100644
--- a/archiva-modules/archiva-base/archiva-configuration/pom.xml
+++ b/archiva-modules/archiva-base/archiva-configuration/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-configuration</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
index a3fb436eb..48b798bb9 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumers</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-consumer-api</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
index 369262da9..8984cc707 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumers</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-core-consumers</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml
index 12c821016..3f9c5d677 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumers</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-dependency-tree-consumer</artifactId>
<name>Archiva Consumers :: Dependency Tree Consumer</name>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml
index 928534dfc..a876293b2 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumers</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-lucene-consumers</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml
index ac3e6748a..1b87b3f0b 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>archiva-consumers</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-metadata-consumer</artifactId>
<name>Archiva Metadata Consumer</name>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml
index f9532f446..1420afcab 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-consumers</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-signature-consumers</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/pom.xml
index 8a1bfefe6..cb4c056c6 100644
--- a/archiva-modules/archiva-base/archiva-consumers/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-consumers</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-converter/pom.xml b/archiva-modules/archiva-base/archiva-converter/pom.xml
index fb94cdbde..4f3b253a4 100644
--- a/archiva-modules/archiva-base/archiva-converter/pom.xml
+++ b/archiva-modules/archiva-base/archiva-converter/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-converter</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml
index a91eb5956..003784012 100644
--- a/archiva-modules/archiva-base/archiva-indexer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-indexer</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-model/pom.xml b/archiva-modules/archiva-base/archiva-model/pom.xml
index e9d201a09..cd76560e2 100755
--- a/archiva-modules/archiva-base/archiva-model/pom.xml
+++ b/archiva-modules/archiva-base/archiva-model/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-model</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-policies/pom.xml b/archiva-modules/archiva-base/archiva-policies/pom.xml
index 22f14c2c0..f9e44d9ca 100644
--- a/archiva-modules/archiva-base/archiva-policies/pom.xml
+++ b/archiva-modules/archiva-base/archiva-policies/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-policies</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml
index 334b003ba..c2765c4e1 100644
--- a/archiva-modules/archiva-base/archiva-proxy/pom.xml
+++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-proxy</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
index cff1aae3b..041f1e919 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-repository-layer</artifactId>
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
index ead95b502..ec3556562 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
@@ -19,13 +19,25 @@ package org.apache.maven.archiva.repository.audit;
* under the License.
*/
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.archiva.metadata.model.MetadataFacet;
+
/**
* AuditEvent
- *
+ *
* @version $Id$
*/
public class AuditEvent
+ implements MetadataFacet
{
+ public static final String TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS";
+
public static final String CREATE_DIR = "Created Directory";
public static final String CREATE_FILE = "Created File";
@@ -82,47 +94,51 @@ public class AuditEvent
public static final String DISABLE_REPO_CONSUMER = "Disabled Content Consumer";
- public static final String ENABLE_DB_CONSUMER = "Enabled Database Consumer";
-
- public static final String DISABLE_DB_CONSUMER = "Disabled Database Consumer";
-
public static final String ADD_PATTERN = "Added File Type Pattern";
public static final String REMOVE_PATTERN = "Removed File Type Pattern";
- public static final String DB_SCHEDULE = "Modified Scanning Schedule";
-
private String repositoryId;
private String userId;
private String remoteIP;
+ // TODO: change to artifact reference? does it ever refer to just a path?
+
private String resource;
private String action;
+ private Date timestamp;
+
+ public static final String FACET_ID = "org.apache.archiva.audit";
+
public AuditEvent()
{
/* do nothing */
}
+ public AuditEvent( String name, String repositoryId )
+ {
+ try
+ {
+ timestamp = new SimpleDateFormat( TIMESTAMP_FORMAT ).parse( name );
+ }
+ catch ( ParseException e )
+ {
+ throw new IllegalArgumentException( "Improperly formatted timestamp for audit log event: " + name );
+ }
+ this.repositoryId = repositoryId;
+ }
+
public AuditEvent( String repoId, String user, String resource, String action )
{
this.repositoryId = repoId;
this.userId = user;
this.resource = resource;
this.action = action;
- }
-
- public AuditEvent( String user, String resource, String action )
- {
- this( null, user, resource, action );
- }
-
- public AuditEvent( String principal, String action2 )
- {
- this( null, principal, action2 );
+ this.timestamp = Calendar.getInstance().getTime();
}
public String getRepositoryId()
@@ -174,4 +190,113 @@ public class AuditEvent
{
this.remoteIP = remoteIP;
}
+
+ public Date getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp( Date timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+ public String getFacetId()
+ {
+ return FACET_ID;
+ }
+
+ public String getName()
+ {
+ return new SimpleDateFormat( TIMESTAMP_FORMAT ).format( timestamp );
+ }
+
+ public Map<String, String> toProperties()
+ {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put( "action", this.action );
+ if ( this.userId != null )
+ {
+ properties.put( "user", this.userId );
+ }
+ if ( this.remoteIP != null )
+ {
+ properties.put( "remoteIP", this.remoteIP );
+ }
+ if ( this.resource != null )
+ {
+ properties.put( "resource", this.resource );
+ }
+ return properties;
+ }
+
+ public void fromProperties( Map<String, String> properties )
+ {
+ this.action = properties.get( "action" );
+ this.remoteIP = properties.get( "remoteIP" );
+ this.userId = properties.get( "user" );
+ this.resource = properties.get( "resource" );
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ AuditEvent that = (AuditEvent) o;
+
+ if ( !action.equals( that.action ) )
+ {
+ return false;
+ }
+ if ( remoteIP != null ? !remoteIP.equals( that.remoteIP ) : that.remoteIP != null )
+ {
+ return false;
+ }
+ if ( repositoryId != null ? !repositoryId.equals( that.repositoryId ) : that.repositoryId != null )
+ {
+ return false;
+ }
+ if ( resource != null ? !resource.equals( that.resource ) : that.resource != null )
+ {
+ return false;
+ }
+ if ( !timestamp.equals( that.timestamp ) )
+ {
+ return false;
+ }
+ if ( userId != null ? !userId.equals( that.userId ) : that.userId != null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = repositoryId != null ? repositoryId.hashCode() : 0;
+ result = 31 * result + ( userId != null ? userId.hashCode() : 0 );
+ result = 31 * result + ( remoteIP != null ? remoteIP.hashCode() : 0 );
+ result = 31 * result + ( resource != null ? resource.hashCode() : 0 );
+ result = 31 * result + action.hashCode();
+ result = 31 * result + timestamp.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "AuditEvent{" + "repositoryId='" + repositoryId + '\'' + ", userId='" + userId + '\'' + ", remoteIP='" +
+ remoteIP + '\'' + ", resource='" + resource + '\'' + ", action='" + action + '\'' + ", timestamp=" +
+ timestamp + '}';
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml b/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml
index bafad290f..59a853f03 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>archiva-base</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-repository-scanner</artifactId>
<name>Archiva Repository Scanner</name>
diff --git a/archiva-modules/archiva-base/archiva-transaction/pom.xml b/archiva-modules/archiva-base/archiva-transaction/pom.xml
index a3a534604..1a6b7ba85 100644
--- a/archiva-modules/archiva-base/archiva-transaction/pom.xml
+++ b/archiva-modules/archiva-base/archiva-transaction/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-transaction</artifactId>
<name>Archiva Transactions</name>
diff --git a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml
index 0ef72ddcb..cc2214218 100644
--- a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml
+++ b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-xml-tools</artifactId>
diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml
index 8a23e35fb..6e79dcd2a 100644
--- a/archiva-modules/archiva-base/pom.xml
+++ b/archiva-modules/archiva-base/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-modules</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-base</artifactId>
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml
index ffcbe736b..13d30a2b6 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>archiva-scheduler</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-scheduler-api</artifactId>
<name>Archiva Base :: Scheduled Tasks :: API</name>
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
index 412d05472..78e0fac8b 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>archiva-scheduler</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-scheduler-indexing</artifactId>
<name>Archiva Base :: Scheduled Tasks :: Indexing</name>
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
index e92553661..7fa0d043f 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>archiva-scheduler</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-scheduler-repository</artifactId>
<name>Archiva Base :: Scheduled Tasks :: Repository Scanning</name>
diff --git a/archiva-modules/archiva-scheduler/pom.xml b/archiva-modules/archiva-scheduler/pom.xml
index 9da400013..079aa23a8 100644
--- a/archiva-modules/archiva-scheduler/pom.xml
+++ b/archiva-modules/archiva-scheduler/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-modules</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-scheduler</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-applet/pom.xml b/archiva-modules/archiva-web/archiva-applet/pom.xml
index af8cc7de2..5a317b861 100644
--- a/archiva-modules/archiva-web/archiva-applet/pom.xml
+++ b/archiva-modules/archiva-web/archiva-applet/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-applet</artifactId>
<name>Archiva Web :: Applet</name>
diff --git a/archiva-modules/archiva-web/archiva-rss/pom.xml b/archiva-modules/archiva-web/archiva-rss/pom.xml
index b94aa75c7..fb8bf31ec 100644
--- a/archiva-modules/archiva-web/archiva-rss/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rss/pom.xml
@@ -22,7 +22,7 @@
<parent>
<artifactId>archiva-web</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-rss</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml
index 7ad99695f..0affcaf62 100644
--- a/archiva-modules/archiva-web/archiva-security/pom.xml
+++ b/archiva-modules/archiva-web/archiva-security/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-security</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java
index 7c6f7b76d..396f9250a 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java
+++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java
@@ -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";
diff --git a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
index 235537e05..55b30e09e 100644
--- a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
+++ b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml
@@ -66,6 +66,11 @@
<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>
<description>Active Archiva Guest</description>
@@ -219,6 +224,12 @@
<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>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
index d70d16632..060823d68 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-webapp-test</artifactId>
<packaging>pom</packaging>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar
new file mode 100644
index 000000000..d98bcfb34
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar
Binary files differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5
new file mode 100644
index 000000000..7359be6f9
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5
@@ -0,0 +1 @@
+ea7dea9244b2a0975cfa117dc34fe18e \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1
new file mode 100644
index 000000000..45ec67894
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1
@@ -0,0 +1 @@
+1039566ff5361d07eccd1243c45929b96441c7d6 \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom
new file mode 100644
index 000000000..cbec59866
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <name>test</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+<distributionManagement>
+<repository>
+ <id>test</id>
+<url>file://localhost/Users/brett/scm/archiva/archiva/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal</url>
+</repository>
+</distributionManagement>
+</project>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5
new file mode 100644
index 000000000..3b20276cd
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5
@@ -0,0 +1 @@
+f80c7c493716de649a99db00cd2ff34c \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1
new file mode 100644
index 000000000..d7c09225e
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1
@@ -0,0 +1 @@
+4b95c6fa09d1e02efdb69129f53f025e33bc8958 \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml
new file mode 100644
index 000000000..68287fd4e
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+ <versioning>
+ <versions>
+ <version>1.0</version>
+ </versions>
+ <lastUpdated>20100114015837</lastUpdated>
+ </versioning>
+</metadata>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5
new file mode 100644
index 000000000..4bb9667e4
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5
@@ -0,0 +1 @@
+dab1b8c2475fe839f387ceaef0d82b30 \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1
new file mode 100644
index 000000000..f00268387
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1
@@ -0,0 +1 @@
+4e5b414d5419121ef75131cb52235a9abbf2095a \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
index c107bda61..e8607fb3b 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
@@ -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/ArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java
index ca03471de..1f60076bc 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java
@@ -83,34 +83,36 @@ public class ArtifactManagementTest
assertTextPresent( "Please add a file to upload." );
}
+ @Test( enabled = false )
public void testAddArtifactValidValues()
{
- addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ // TODO: disable test on non *chrome browsers, there is no way to do file uploads (SEL-63)
+ addArtifact( getGroupId() , "testAddArtifactValidValues", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Artifact 'test:test:1.0' was successfully deployed to repository 'internal'" );
}
//MRM-747
- @Test(dependsOnMethods = { "testAddArtifactValidValues" } )
+ @Test( enabled = false )
public void testAddArtifactBlockRedeployments()
{
- addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
- assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
+ // TODO: disable test on non *chrome browsers, there is no way to do file uploads (SEL-63)
+ addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
+ assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
}
- public void testAddArtifactValidValues1()
+ @Test( enabled = false )
+ public void testDeleteArtifact()
{
+ //prep
String groupId = getProperty( "GROUPID1" );
String artifactId = getProperty( "ARTIFACTID1" );
String version = getProperty( "VERSION1" );
String packaging = getProperty( "PACKAGING1" );
String repositoryId = getProperty( "REPOSITORYID1" );
+ // TODO: do this differently as it only works in Firefox's chrome mode
addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
- }
-
- @Test(dependsOnMethods = { "testAddArtifactValidValues1" } )
- public void testDeleteArtifact()
- {
+
deleteArtifact( "delete", "delete", "1.0", "internal");
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
}
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
index 000000000..daedc24a9
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
@@ -0,0 +1,131 @@
+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." );
+ }
+
+ // TODO: add test for adding via WebDAV
+ // TODO: disable if not running on *chrome
+ @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
+ 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" );
+ }
+
+ // TODO: add test for adding via WebDAV
+ // TODO: disable if not running on *chrome
+ @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
+ 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" );
+ }
+
+ // TODO: add test for adding via WebDAV
+ // TODO: disable if not running on *chrome
+ @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false )
+ 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" );
+ }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
index ab6ba818a..c9c60ecce 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
@@ -45,6 +45,7 @@ public class BrowseTest
}
// MRM-1278
+ @Test( enabled = false )
public void testCorrectRepositoryInBrowse()
{
File artifact =
@@ -63,6 +64,7 @@ public class BrowseTest
String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
+ // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
// upload a snapshot artifact to repository 'releases'
addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(),
releasesRepo );
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java
index 8d1e817e7..3431ebf9e 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java
@@ -22,7 +22,7 @@ package org.apache.archiva.web.test;
import org.apache.archiva.web.test.parent.AbstractArchivaTest;
import org.testng.annotations.Test;
-@Test( groups = { "findartifact" }, dependsOnMethods = { "testAddArtifactValidValues1" }, sequential = true )
+@Test( groups = { "findartifact" }, sequential = true )
public class FindArtifactTest
extends AbstractArchivaTest
{
@@ -33,9 +33,9 @@ public class FindArtifactTest
assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." );
}
- @Test( dependsOnMethods = { "testFindArtifactNullValues" })
public void testFindArtifactUsingChecksum()
{
+ goToFindArtifactPage();
setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" );
clickButtonWithValue( "Search" );
assertTextPresent( "No results found" );
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java
index d46c16907..756763fec 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java
@@ -22,13 +22,12 @@ package org.apache.archiva.web.test;
import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest;
import org.testng.annotations.Test;
-@Test( groups = { "reports" }, dependsOnMethods = { "testAddArtifactValidValues" } )
+@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class ReportsTest
extends AbstractArtifactReportsTest
{
//TODO Tests for repository with defects
-// @Test(dependsOnMethods = { "testAddArtifactValidValues" } )
public void testRepoStatisticsWithoutRepoCompared()
{
goToReportsPage();
@@ -57,7 +56,6 @@ public class ReportsTest
assertTextPresent( "Start Date must be earlier than the End Date" );
}
- @Test(dependsOnMethods = { "testAddArtifactValidValues" } )
public void testRepositoryStatistics()
{
String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
@@ -78,7 +76,6 @@ public class ReportsTest
assertTextPresent( "Statistics Report" );
}
- @Test(dependsOnMethods = { "testAddArtifactValidValues" } )
public void testRepositoryHealthWithoutDefect()
{
goToReportsPage();
@@ -89,7 +86,6 @@ public class ReportsTest
assertTextPresent( "The operation generated an empty report." );
}
- @Test(dependsOnMethods = { "testAddArtifactValidValues" } )
public void testRepositoryHealthWithoutGroupId()
{
goToReportsPage();
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
index c4d5bcad9..6d00d1a32 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
@@ -1,8 +1,5 @@
package org.apache.archiva.web.test;
-import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
-import org.testng.annotations.Test;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -22,6 +19,10 @@ import org.testng.annotations.Test;
* under the License.
*/
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
@Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
public class RepositoryScanningTest
extends AbstractRepositoryTest
@@ -38,7 +39,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_0" , "**/*.dll" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
- assertTextPresent( "**/*.dll" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
}
@Test (dependsOnMethods = { "testAddArtifactFileType" } )
@@ -46,14 +47,15 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_0" , "**/*.zip" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" );
- assertTextPresent( "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
}
@Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
public void testDeleteArtifactFileType()
{
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
- assertTextNotPresent( "dll" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" );
}
@Test (dependsOnMethods = { "testDeleteArtifactFileType" } )
@@ -69,7 +71,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_1" , "**/*-" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
- assertTextPresent( "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
}
@Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } )
@@ -77,14 +79,15 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_1" , "**/*.test" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
- assertTextPresent( "**/*.test" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
}
@Test (dependsOnMethods = { "testAddAutoRemove" } )
public void testDeleteAutoRemove()
{
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
- assertTextNotPresent( "test" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" );
}
@Test (dependsOnMethods = { "testDeleteAutoRemove" } )
@@ -92,7 +95,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_2" , "" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
- assertTextPresent( "Unable to process blank pattern." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
}
@Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } )
@@ -100,7 +103,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_2" , "**/*.sh" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
- assertTextPresent( "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
}
@Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } )
@@ -108,14 +111,15 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_2" , "**/*.log" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
- assertTextPresent( "**/*.log" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
}
@Test (dependsOnMethods = { "testAddIgnoredArtifacts" } )
public void testDeleteIgnoredArtifacts()
{
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
- assertTextNotPresent( "log" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" );
}
//
@@ -124,7 +128,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_3" , "" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
- assertTextPresent( "Unable to process blank pattern." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
}
@Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } )
@@ -132,7 +136,7 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_3" , "**/*.xml" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
- assertTextPresent( "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
+ Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
}
@Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } )
@@ -140,14 +144,15 @@ public class RepositoryScanningTest
{
setFieldValue( "newpattern_3" , "**/*.html" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
- assertTextPresent( "**/*.html" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
}
@Test (dependsOnMethods = { "testAddIndexableContent" } )
public void testDeleteIndexableContent()
{
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
- assertTextNotPresent( "html" );
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" );
}
@Test (dependsOnMethods = { "testDeleteIndexableContent" } )
@@ -172,10 +177,6 @@ public class RepositoryScanningTest
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
clickButtonWithValue( "Update Consumers" );
- // remove the ff. 2 lines if MRM-1238 will be fixed.
- getSelenium().goBack();
- waitPage();
-
assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java
index e23e6bf93..c22e02be7 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java
@@ -26,7 +26,6 @@ import org.testng.annotations.Test;
public class RepositoryTest
extends AbstractRepositoryTest
{
- @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public void testAddManagedRepoValidValues()
{
goToRepositoriesPage();
@@ -37,11 +36,9 @@ public class RepositoryTest
assertRepositoriesPage();
}
- @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
public void testAddManagedRepoInvalidValues()
- {
- goToRepositoriesPage();
- assertRepositoriesPage();
+ {
+ goToRepositoriesPage();
clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
assertTextPresent( "You must enter a repository identifier." );
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
index 08a748a49..d10700985 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
@@ -19,6 +19,8 @@ package org.apache.archiva.web.test;
* under the License.
*/
+import java.io.File;
+
import org.apache.archiva.web.test.parent.AbstractSearchTest;
import org.testng.annotations.Test;
@@ -34,7 +36,6 @@ public class SearchTest
assertTextPresent( "No results found" );
}
- @Test (dependsOnMethods = { "testAddArtifactValidValues" } )
public void testSearchExistingArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
@@ -43,7 +44,6 @@ public class SearchTest
assertLinkPresent( "test" );
}
- @Test (dependsOnMethods = { "testAddArtifactValidValues" } )
public void testViewSearchedArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
@@ -66,12 +66,29 @@ public class SearchTest
assertTextPresent( "Advanced Search - At least one search criteria must be provided." );
}
- /* public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
+ public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
{
- searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, null, null, null );
+ searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, getProperty( "REPOSITORYID" ), null, null );
assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
- }*/
+ }
+
+ public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
+ {
+ searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null, null );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( "test" );
+ }
+
+ public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
+ {
+ searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
+ assertTextPresent( "No results found" );
+ assertTextNotPresent( "Results" );
+ assertTextNotPresent( "Hits: 1 to 1 of 1" );
+ assertLinkNotPresent( "test" );
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java
index 081320fb8..befbea954 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java
@@ -21,6 +21,7 @@ package org.apache.archiva.web.test;
import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
import org.testng.annotations.Test;
+import org.testng.Assert;
@Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class VirtualRepositoryTest
@@ -37,26 +38,25 @@ public class VirtualRepositoryTest
{
addRepositoryGroup( "testing" );
//assertAddedRepositoryLink( "testing" );
- assertTextPresent( "testing" );
+ Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" );
}
@Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
public void testAddRepositoryToRepositoryGroup()
{
addRepositoryToRepositoryGroup( "testing", "internal" );
- assertTextPresent( "internal" );
+ Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ), "internal" );
//clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
//getSelenium().goBack();
}
@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
public void testDeleteRepositoryOfRepositoryGroup()
- {
- goToRepositoryGroupsPage();
+ {
deleteRepositoryInRepositoryGroups();
assertTextPresent( "Repository Groups" );
assertTextNotPresent( "No Repository Groups Defined." );
- waitPage();
+ Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) );
}
@Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java
index 4e6ed3182..947d7cbf3 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java
@@ -20,18 +20,28 @@ package org.apache.archiva.web.test.listener;
*/
import java.io.File;
+import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
import org.apache.archiva.web.test.parent.AbstractSeleniumTest;
+import org.apache.commons.io.FileUtils;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
+import com.thoughtworks.selenium.Selenium;
public class CaptureScreenShotsListener
extends TestListenerAdapter
{
@Override
+ public void onTestSkipped( ITestResult tr )
+ {
+ System.out.println( "Test " + tr.getName() + " -> Skipped" );
+ super.onTestSkipped( tr );
+ }
+
+ @Override
public void onTestFailure( ITestResult tr )
{
captureError( tr );
@@ -48,40 +58,38 @@ public class CaptureScreenShotsListener
private void captureError( ITestResult tr )
{
- try
- {
- captureScreenshot( tr );
- }
- catch ( RuntimeException e )
- {
- System.out.println( "Error when take screenshot for test " + tr.getName() );
- e.printStackTrace();
- }
- }
-
- // captureAssertionError() creates a 'target/screenshots' directory and saves '.png' page screenshot of the
- // encountered error
- private void captureScreenshot( ITestResult tr )
- {
- File f = new File( "" );
- String filePath = f.getAbsolutePath();
- Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
- String time = sdf.format( d );
- String fs = File.separator;
- File targetPath = new File( filePath + fs + "target" + fs + "screenshots" );
- targetPath.mkdir();
- String cName = tr.getTestClass().getName();
+ String time = sdf.format( new Date() );
+ File targetPath = new File( "target", "screenshots" );
StackTraceElement stackTrace[] = tr.getThrowable().getStackTrace();
+ String cName = tr.getTestClass().getName();
int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
String methodName = stackTrace[index].getMethodName();
int lNumber = stackTrace[index].getLineNumber();
String lineNumber = Integer.toString( lNumber );
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
- String fileName =
- targetPath.toString() + fs + methodName + "(" + className + ".java_" + lineNumber + ")-" + time + ".png";
- AbstractSeleniumTest.getSelenium().windowMaximize();
- AbstractSeleniumTest.getSelenium().captureEntirePageScreenshot( fileName, "" );
+ targetPath.mkdirs();
+ Selenium selenium = AbstractSeleniumTest.getSelenium();
+ String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
+ try
+ {
+ selenium.windowMaximize();
+ File fileName = new File( targetPath, fileBaseName + ".png" );
+ selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "" );
+ }
+ catch ( RuntimeException e )
+ {
+ System.out.println( "Error when take screenshot for test " + tr.getName() + ": " + e.getMessage() );
+ try
+ {
+ File fileName = new File( targetPath, fileBaseName + ".html" );
+ FileUtils.writeStringToFile( fileName, selenium.getHtmlSource() );
+ }
+ catch ( IOException ioe )
+ {
+ System.out.println( ioe.getMessage() );
+ }
+ }
}
private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java
index 830c39cd7..cf03765b0 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java
@@ -14,7 +14,7 @@ public abstract class AbstractArtifactManagementTest
public String getArtifactId()
{
- String artifactId = getProperty( "GROUPID" ) ;
+ String artifactId = getProperty( "ARTIFACTID" ) ;
return artifactId;
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java
index b6237b8ef..52f02ef8a 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java
@@ -1,6 +1,26 @@
package org.apache.archiva.web.test.parent;
+/*
+ * 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.io.File;
+import org.testng.Assert;
public abstract class AbstractRepositoryTest
extends AbstractArchivaTest
@@ -80,12 +100,13 @@ public abstract class AbstractRepositoryTest
public void deleteRepositoryInRepositoryGroups()
{
+ goToRepositoryGroupsPage();
getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
+ waitPage();
}
public void deleteRepositoryGroup( String repositoryName )
{
- //goToRepositoryGroupsPage();
getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
waitPage();
assertDeleteRepositoryGroupPage( repositoryName );
@@ -306,23 +327,23 @@ public abstract class AbstractRepositoryTest
assertTextPresent( "Repository Scanning - File Types" );
String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
String [] arrayArtifactTypes = artifactsTypes.split( "," );
- for (String artifacttypes : arrayArtifactTypes )
- assertTextPresent( artifacttypes );
+ for (int i = 0; i < arrayArtifactTypes.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]);
String autoremove = "**/*.bak,**/*~,**/*-";
String [] arrayAutoremove = autoremove.split( "," );
- for ( String arrayautoremove : arrayAutoremove )
- assertTextPresent( arrayautoremove );
+ for (int i = 0; i < arrayAutoremove.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]);
String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
String [] arrayIgnored = ignored.split( "," );
- for ( String arrayignored : arrayIgnored )
- assertTextPresent( arrayignored );
+ for (int i = 0; i < arrayIgnored.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]);
String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
String [] arrayIndexableContent = indexableContent.split( "," );
- for ( String indexablecontent : arrayIndexableContent )
- assertTextPresent( indexablecontent );
+ for (int i = 0; i < arrayIndexableContent.length; i++)
+ Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
}
/////////////////////////////////////////////
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
index 410ec14ab..5b787b502 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
@@ -25,7 +25,7 @@ public abstract class AbstractSearchTest
//Search
public void goToSearchPage()
{
- if ( !"Apache Archiva \\ Quick Search".equals( getSelenium().getTitle() ) )
+ if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
{
clickLinkWithText( "Search" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
@@ -107,6 +107,10 @@ public abstract class AbstractSearchTest
setFieldValue( "rowCount", rowCount );
}
+ if ( repositoryId != null )
+ {
+ selectValue( "filteredSearch_repositoryId", repositoryId );
+ }
clickSubmitWithLocator( "filteredSearch_0" );
}
-} \ No newline at end of file
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
index 2c697d725..cb4fee208 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
@@ -140,14 +140,13 @@ public abstract class AbstractSeleniumTest {
public void assertPage( String title )
{
- // Collapse spaces
- String actualTitle = getSelenium().getTitle().replaceAll( "[ \n\r]+", " " );
- Assert.assertEquals( actualTitle, title );
+ Assert.assertEquals( getTitle(), title );
}
public String getTitle()
{
- return getSelenium().getTitle();
+ // Collapse spaces
+ return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " );
}
public String getHtmlContent()
diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml
index b39989c85..9edf9a8ff 100644
--- a/archiva-modules/archiva-web/archiva-webapp/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-webapp</artifactId>
<packaging>war</packaging>
@@ -39,6 +39,10 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>audit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>archiva-scheduler-repository</artifactId>
</dependency>
<dependency>
@@ -64,7 +68,6 @@
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-metadata-consumer</artifactId>
- <version>1.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -250,23 +253,19 @@
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-model</artifactId>
- <version>1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
- <version>1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-file</artifactId>
- <version>1.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId> <!-- FIXME: temporary coupling to plugin, should be runtime -->
<artifactId>maven2-repository</artifactId>
- <version>1.3-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
@@ -307,9 +306,9 @@
<phase>compile</phase>
<configuration>
<tasks>
- <mkdir dir="${basedir}/target/archiva/WEB-INF/"/>
+ <mkdir dir="${basedir}/target/archiva/WEB-INF/" />
<copy todir="${basedir}/target/archiva/WEB-INF/">
- <fileset dir="${basedir}/target" includes="classes/" excludes="**/struts.xml"/>
+ <fileset dir="${basedir}/target" includes="classes/" excludes="**/struts.xml" />
</copy>
</tasks>
</configuration>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java
index 5a1d04da7..9fc4d979c 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/PlexusActionSupport.java
@@ -89,7 +89,7 @@ public abstract class PlexusActionSupport
protected void triggerAuditEvent( String resource, String action )
{
- AuditEvent event = new AuditEvent( getPrincipal(), resource, action );
+ AuditEvent event = new AuditEvent( null, getPrincipal(), resource, action );
event.setRemoteIP( getRemoteAddr() );
for ( AuditListener listener : auditListeners )
@@ -100,7 +100,7 @@ public abstract class PlexusActionSupport
protected void triggerAuditEvent( String action )
{
- AuditEvent event = new AuditEvent( getPrincipal(), action );
+ AuditEvent event = new AuditEvent( null, getPrincipal(), null, action );
event.setRemoteIP( getRemoteAddr() );
for ( AuditListener listener : auditListeners )
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
index d560c5a06..0919ee8a1 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
@@ -147,7 +147,7 @@ public class UploadAction
* @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
*/
private ArchivaTaskScheduler scheduler;
-
+
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5};
public void setArtifact( File file )
@@ -415,7 +415,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
index 000000000..d2244cfa5
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
@@ -0,0 +1,381 @@
+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.archiva.audit.AuditManager;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.security.AccessDeniedException;
+import org.apache.maven.archiva.security.ArchivaSecurityException;
+import org.apache.maven.archiva.security.PrincipalNotFoundException;
+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;
+
+ 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<AuditEvent> 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" };
+
+ /**
+ * @plexus.requirement
+ */
+ private AuditManager auditManager;
+
+ 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;
+ }
+
+ auditLogs = auditManager.getMostRecentAuditEvents();
+ }
+
+ public String execute()
+ throws Exception
+ {
+ Date startDateInDF;
+ Date endDateInDF;
+ 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;
+
+ String repo = repository.equals( ALL_REPOSITORIES ) ? null : repository;
+ // TODO: query by artifact
+ auditLogs = auditManager.getAuditEventsInRange( repo, startDateInDF, endDateInDF );
+
+ if( auditLogs.isEmpty() )
+ {
+ addActionError( "No audit logs found." );
+ initial = "true";
+ }
+ else
+ {
+ initial = "false";
+ }
+
+ headerName = HEADER_RESULTS;
+ paginate();
+
+ 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<AuditEvent> getAuditLogs()
+ {
+ return 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;
+ }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
index 9579dbba0..f1b689cea 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
@@ -111,6 +111,12 @@ public class ContextUtils
}
return name;
}
+ else
+ {
+ // respect chains of proxies, return first one (as it's the outermost visible one)
+ String[] hosts = name.split( "," );
+ name = hosts[0].trim();
+ }
return name;
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
index 2f21561c6..02659ff3d 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
@@ -510,6 +510,16 @@
</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>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp
index 2b2e6a66e..c4666f173 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/accessToNoRepos.jsp
@@ -22,7 +22,7 @@
<html>
<head>
- <title>You have access to no repositories</title>
+ <title>You do not have access to any repository</title>
<s:head/>
</head>
@@ -31,8 +31,8 @@
<div id="contentArea">
<div id="results">
- You have access to no repositories.
- Ask your system administrator for access.
+ You do not have access to any repository.
+ Please contact your system administrator and request for access.
</div>
</div>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
index b91f70952..37ebbf517 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp
@@ -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">
@@ -88,6 +88,11 @@
<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>
@@ -112,7 +117,7 @@
<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
index 000000000..02d029550
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
@@ -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/no-theme/jquery-ui-1.7.2.custom.css'/>" type="text/css" />
+ <script type="text/javascript" src="<c:url value='/js/jquery-1.3.2.min.js'/>"></script>
+ <script type="text/javascript" src="<c:url value='/js/jquery-ui-1.7.2.custom.min.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>Resource</th>
+ <th>Event Date</th>
+ <th>Username</th>
+ </tr>
+
+ <c:forEach items="${auditLogs}" var="auditLog" varStatus="i">
+ <tr>
+ <td>${auditLog.action}</td>
+ <td>${auditLog.repositoryId}</td>
+ <td>${auditLog.resource}</td>
+ <td>${auditLog.timestamp}</td>
+ <td>${auditLog.userId}</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>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp
index 990b5833e..1db6f6b05 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/statisticsReport.jsp
@@ -154,6 +154,10 @@
<th>Archetypes</th>
<th>Jars</th>
<th>Wars</th>
+ <th>Ears</th>
+ <th>Exes</th>
+ <th>Dlls</th>
+ <th>Zips</th>
</tr>
<c:forEach var="stats" items="${repositoryStatistics}" varStatus="i">
@@ -168,6 +172,10 @@
<td align="right">${stats.totalCountForType['maven-archetype']}</td>
<td align="right">${stats.totalCountForType['jar']}</td>
<td align="right">${stats.totalCountForType['war']}</td>
+ <td align="right">${stats.totalCountForType['ear']}</td>
+ <td align="right">${stats.totalCountForType['exe']}</td>
+ <td align="right">${stats.totalCountForType['dll']}</td>
+ <td align="right">${stats.totalCountForType['zip']}</td>
</tr>
</c:forEach>
</table>
@@ -187,6 +195,10 @@
<th>Archetypes</th>
<th>Jars</th>
<th>Wars</th>
+ <th>Ears</th>
+ <th>Exes</th>
+ <th>Dlls</th>
+ <th>Zips</th>
</tr>
<c:forEach var="stats" items="${repositoryStatistics}">
@@ -201,6 +213,10 @@
<td align="right">${stats.totalCountForType['maven-archetype']}</td>
<td align="right">${stats.totalCountForType['jar']}</td>
<td align="right">${stats.totalCountForType['war']}</td>
+ <td align="right">${stats.totalCountForType['ear']}</td>
+ <td align="right">${stats.totalCountForType['exe']}</td>
+ <td align="right">${stats.totalCountForType['dll']}</td>
+ <td align="right">${stats.totalCountForType['zip']}</td>
</tr>
</c:forEach>
</table>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
index ef9c51eac..9f9322a5f 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
@@ -350,3 +350,40 @@ div.versions a.expand {
list-style-image: url(../images/icon_warning_sml.gif)
}
+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;
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
index 9131af530..8a98bd2d6 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
@@ -48,10 +48,6 @@ import org.easymock.classextension.MockClassControl;
public class UploadActionTest
extends PlexusInSpringTestCase
{
- private ArchivaTaskScheduler scheduler;
-
- private MockControl schedulerControl;
-
private UploadAction uploadAction;
private ArchivaConfiguration archivaConfig;
@@ -61,25 +57,25 @@ public class UploadActionTest
private RepositoryContentFactory repoFactory;
private MockControl repoFactoryControl;
-
+
private static final String REPOSITORY_ID = "test-repo";
- private Configuration config;
+ private Configuration config;
public void setUp()
throws Exception
{
super.setUp();
- schedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
- scheduler = (ArchivaTaskScheduler) schedulerControl.getMock();
+ MockControl schedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
+ ArchivaTaskScheduler scheduler = (ArchivaTaskScheduler) schedulerControl.getMock();
archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
-
+
uploadAction = new UploadAction();
uploadAction.setScheduler( scheduler );
uploadAction.setConfiguration( archivaConfig );
@@ -411,7 +407,7 @@ public class UploadActionTest
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
-
+
archivaConfigControl.replay();
repoFactoryControl.replay();
@@ -505,10 +501,10 @@ public class UploadActionTest
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
-
+
archivaConfigControl.replay();
repoFactoryControl.replay();
-
+
String returnString = uploadAction.doUpload();
assertEquals( Action.SUCCESS, returnString );
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
index b510a144d..becbd156e 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
@@ -40,7 +40,7 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase
private MockControl archivaConfigurationControl;
private ArchivaConfiguration archivaConfiguration;
-
+
public void testConfirmDisableBadSourceOrTarget()
throws Exception
{
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
index ef32ea249..61479d247 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java
@@ -51,7 +51,7 @@ public class AddManagedRepositoryActionTest
private MockControl archivaConfigurationControl;
private ArchivaConfiguration archivaConfiguration;
-
+
private static final String REPO_ID = "repo-ident";
private File location;
@@ -145,8 +145,7 @@ public class AddManagedRepositoryActionTest
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();
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
index d4f631679..a7bf0b97e 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
@@ -79,7 +79,7 @@ public class DeleteManagedRepositoryActionTest
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
action.setArchivaConfiguration( archivaConfiguration );
-
+
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
action.setRoleManager( roleManager );
@@ -127,9 +127,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() );
@@ -146,7 +147,7 @@ public class DeleteManagedRepositoryActionTest
Configuration configuration = prepDeletionTest( createRepository(), 4 );
- String status = action.deleteEntry();
+ String status = action.deleteEntry();
assertEquals( Action.SUCCESS, status );
@@ -168,7 +169,7 @@ public class DeleteManagedRepositoryActionTest
Configuration configuration = prepDeletionTest( createRepository(), 4 );
String status = action.deleteContents();
-
+
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
@@ -194,6 +195,7 @@ public class DeleteManagedRepositoryActionTest
assertEquals( 1, configuration.getProxyConnectors().size() );
String status = action.deleteContents();
+
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
@@ -211,6 +213,7 @@ public class DeleteManagedRepositoryActionTest
ManagedRepositoryConfiguration originalRepository = createRepository();
Configuration configuration = prepDeletionTest( originalRepository, 3 );
+
String status = action.execute();
assertEquals( Action.SUCCESS, status );
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
index f9b4a7ae6..7c894ea32 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java
@@ -140,10 +140,10 @@ public class EditManagedRepositoryActionTest
ManagedRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
repository.setName( "new repo name" );
-
+
String status = action.commit();
assertEquals( Action.SUCCESS, status );
-
+
ManagedRepositoryConfiguration newRepository = createRepository();
newRepository.setName( "new repo name" );
assertRepositoryEquals( repository, newRepository );
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml
index dc32d3f3d..c01790ca8 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.xml
@@ -38,7 +38,7 @@
<!-- 30 minutes = 1800 seconds -->
<time-to-live-seconds>1800</time-to-live-seconds>
</configuration>
- </component>
+ </component>
</components>
</plexus>
diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml
index 95341522e..d85241cee 100644
--- a/archiva-modules/archiva-web/archiva-webdav/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-webdav</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
index eff87127e..23727d0b4 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
@@ -403,9 +403,15 @@ public class ArchivaDavResource
private void triggerAuditEvent( DavResource member, String event ) throws DavException
{
String path = logicalResource + "/" + member.getDisplayName();
-
- triggerAuditEvent( checkDavResourceIsArchivaDavResource( member ).remoteAddr, locator.getRepositoryId(), path,
- event );
+
+ ArchivaDavResource resource = checkDavResourceIsArchivaDavResource( member );
+ AuditEvent auditEvent = new AuditEvent( locator.getRepositoryId(), resource.principal, path, event );
+ auditEvent.setRemoteIP( resource.remoteAddr );
+
+ for ( AuditListener listener : auditListeners )
+ {
+ listener.auditEvent( auditEvent );
+ }
}
public void move( DavResource destination )
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
index c1cd85cf3..e92f87a32 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
@@ -528,7 +528,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 );
}
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
index b2f38fdb4..0d30388bb 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
@@ -81,7 +81,7 @@ public class ArchivaDavResourceFactoryTest
private MockControl repoContentFactoryControl;
private RepositoryContentFactory repoFactory;
-
+
public void setUp()
throws Exception
{
@@ -96,7 +96,7 @@ public class ArchivaDavResourceFactoryTest
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-
+
config = new Configuration();
config.addManagedRepository( createManagedRepository( RELEASES_REPO, new File( getBasedir(),
"target/test-classes/" +
@@ -392,7 +392,7 @@ public class ArchivaDavResourceFactoryTest
long date = 2039842134;
response.addDateHeader( "last-modified", date );
responseControl.setVoidCallable();
-
+
archivaConfigurationControl.replay();
repoContentFactoryControl.replay();
requestControl.replay();
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java
index 8b656d8ec..8e22e72de 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/DavResourceTest.java
@@ -77,11 +77,12 @@ public class DavResourceTest
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
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java
index 9066331de..f4119959f 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java
@@ -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",
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml
index 8a190a1e2..b307f9b1b 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-xmlrpc</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-xmlrpc-api</artifactId>
<name>Archiva Web :: XML-RPC API</name>
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
index 492d5b8d4..b020b60bf 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>archiva-xmlrpc</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-xmlrpc-client</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml
index 62d2859a0..159002b45 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-xmlrpc</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-xmlrpc-security</artifactId>
<name>Archiva Web :: XML-RPC Security</name>
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
index 665095d74..ab685fb61 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-xmlrpc</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-xmlrpc-services</artifactId>
<name>Archiva Web :: XML-RPC Services</name>
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml
index 923bd525c..d9abce24a 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-xmlrpc</artifactId>
<name>Archiva Web :: XML-RPC</name>
diff --git a/archiva-modules/archiva-web/pom.xml b/archiva-modules/archiva-web/pom.xml
index c65901d1a..c4b17053d 100644
--- a/archiva-modules/archiva-web/pom.xml
+++ b/archiva-modules/archiva-web/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-modules</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-web</artifactId>
diff --git a/archiva-modules/metadata/content-model.txt b/archiva-modules/metadata/content-model.txt
index 4d6565816..547af9ec8 100644
--- a/archiva-modules/metadata/content-model.txt
+++ b/archiva-modules/metadata/content-model.txt
@@ -95,6 +95,18 @@ The following is the intended content model for the metadata content repository:
| |-- maven:plugins.compiler.artifactId=
| `-- maven:plugins.compiler.name=
|-- facets/
+ | |-- org.apache.archiva.audit/
+ | | `-- 2010/
+ | | `-- 01/
+ | | `-- 19/
+ | | `-- 093600.000/
+ | | |-- action=
+ | | |-- artifact.id=
+ | | |-- artifact.namespace=
+ | | |-- artifact.projectId=
+ | | |-- artifact.version=
+ | | |-- remoteIP=
+ | | `-- user=
| |-- org.apache.archiva.metadata.repository.stats/
| | `-- 2009/
| | `-- 12/
diff --git a/archiva-modules/metadata/metadata-model/pom.xml b/archiva-modules/metadata/metadata-model/pom.xml
index ccd593426..65226f899 100644
--- a/archiva-modules/metadata/metadata-model/pom.xml
+++ b/archiva-modules/metadata/metadata-model/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>metadata</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>metadata-model</artifactId>
<name>Archiva Metadata Model</name>
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacetFactory.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacetFactory.java
index b9e313a80..e0804edc1 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacetFactory.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacetFactory.java
@@ -22,4 +22,6 @@ package org.apache.archiva.metadata.model;
public interface MetadataFacetFactory
{
MetadataFacet createMetadataFacet();
+
+ MetadataFacet createMetadataFacet( String repositoryId, String name );
}
diff --git a/archiva-modules/metadata/metadata-repository-api/pom.xml b/archiva-modules/metadata/metadata-repository-api/pom.xml
index 0f36161fc..c98dd2a00 100644
--- a/archiva-modules/metadata/metadata-repository-api/pom.xml
+++ b/archiva-modules/metadata/metadata-repository-api/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>metadata</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>metadata-repository-api</artifactId>
<name>Archiva Metadata Repository API</name>
diff --git a/archiva-modules/metadata/pom.xml b/archiva-modules/metadata/pom.xml
index 3e7159b5a..646612a45 100644
--- a/archiva-modules/metadata/pom.xml
+++ b/archiva-modules/metadata/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>archiva-modules</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>metadata</artifactId>
<name>Archiva Metadata</name>
diff --git a/archiva-modules/plugins/audit/pom.xml b/archiva-modules/plugins/audit/pom.xml
new file mode 100644
index 000000000..276905786
--- /dev/null
+++ b/archiva-modules/plugins/audit/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>plugins</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>audit</artifactId>
+ <name>Audit Logging</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-repository-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java
new file mode 100644
index 000000000..9573d5509
--- /dev/null
+++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java
@@ -0,0 +1,41 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.model.MetadataFacetFactory;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+
+/**
+ * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.audit"
+ */
+public class AuditEventFactory
+ implements MetadataFacetFactory
+{
+ public MetadataFacet createMetadataFacet()
+ {
+ throw new UnsupportedOperationException( "Must construct an audit event with a name" );
+ }
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new AuditEvent( name, repositoryId );
+ }
+} \ No newline at end of file
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditManager.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditManager.java
new file mode 100644
index 000000000..addb9c0e3
--- /dev/null
+++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditManager.java
@@ -0,0 +1,36 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+
+public interface AuditManager
+{
+ List<AuditEvent> getMostRecentAuditEvents();
+
+ void addAuditEvent( AuditEvent event );
+
+ void deleteAuditEvents( String repositoryId );
+
+ List<AuditEvent> getAuditEventsInRange( String repositoryId, Date startTime, Date endTime );
+} \ No newline at end of file
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
new file mode 100644
index 000000000..e8161f982
--- /dev/null
+++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
@@ -0,0 +1,154 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.apache.archiva.audit.AuditManager"
+ */
+public class DefaultAuditManager
+ implements AuditManager
+{
+ /**
+ * @plexus.requirement
+ */
+ private MetadataRepository metadataRepository;
+
+ private static final int NUM_RECENT_REVENTS = 10;
+
+ private static final Logger log = LoggerFactory.getLogger( DefaultAuditManager.class );
+
+ public List<AuditEvent> getMostRecentAuditEvents()
+ {
+ // TODO: consider a more efficient implementation that directly gets the last ten from the content repository
+ List<AuditRecord> records = new ArrayList<AuditRecord>();
+ for ( String repositoryId : metadataRepository.getRepositories() )
+ {
+ List<String> timestamps = metadataRepository.getMetadataFacets( repositoryId, AuditEvent.FACET_ID );
+ for ( String timestamp : timestamps )
+ {
+ records.add( new AuditRecord( repositoryId, timestamp ) );
+ }
+ }
+ Collections.sort( records );
+ records = records.subList( 0, records.size() < NUM_RECENT_REVENTS ? records.size() : NUM_RECENT_REVENTS );
+
+ List<AuditEvent> events = new ArrayList<AuditEvent>( records.size() );
+ for ( AuditRecord record : records )
+ {
+ AuditEvent auditEvent =
+ (AuditEvent) metadataRepository.getMetadataFacet( record.repositoryId, AuditEvent.FACET_ID,
+ record.name );
+ events.add( auditEvent );
+ }
+ return events;
+ }
+
+ public void addAuditEvent( AuditEvent event )
+ {
+ // ignore those with no repository - they will still be logged to the textual audit log
+ if ( event.getRepositoryId() != null )
+ {
+ metadataRepository.addMetadataFacet( event.getRepositoryId(), event );
+ }
+ }
+
+ public void deleteAuditEvents( String repositoryId )
+ {
+ metadataRepository.removeMetadataFacets( repositoryId, AuditEvent.FACET_ID );
+ }
+
+ public List<AuditEvent> getAuditEventsInRange( String repoId, Date startTime, Date endTime )
+ {
+ Collection<String> repositoryIds =
+ repoId != null ? Collections.singletonList( repoId ) : metadataRepository.getRepositories();
+
+ List<AuditEvent> results = new ArrayList<AuditEvent>();
+ for ( String repositoryId : repositoryIds )
+ {
+ List<String> list = metadataRepository.getMetadataFacets( repositoryId, AuditEvent.FACET_ID );
+ for ( String name : list )
+ {
+ try
+ {
+ Date date = new SimpleDateFormat( AuditEvent.TIMESTAMP_FORMAT ).parse( name );
+ if ( ( startTime == null || !date.before( startTime ) ) &&
+ ( endTime == null || !date.after( endTime ) ) )
+ {
+ AuditEvent event =
+ (AuditEvent) metadataRepository.getMetadataFacet( repositoryId, AuditEvent.FACET_ID, name );
+ results.add( event );
+ }
+ }
+ catch ( ParseException e )
+ {
+ log.error( "Invalid audit event found in the metadata repository: " + e.getMessage() );
+ // continue and ignore this one
+ }
+ }
+ }
+ Collections.sort( results, new Comparator<AuditEvent>()
+ {
+ public int compare( AuditEvent o1, AuditEvent o2 )
+ {
+ return o2.getTimestamp().compareTo( o1.getTimestamp() );
+ }
+ } );
+ return results;
+ }
+
+ public void setMetadataRepository( MetadataRepository metadataRepository )
+ {
+ this.metadataRepository = metadataRepository;
+ }
+
+ private static final class AuditRecord
+ implements Comparable<AuditRecord>
+ {
+ private String repositoryId;
+
+ private String name;
+
+ public AuditRecord( String repositoryId, String name )
+ {
+ this.repositoryId = repositoryId;
+ this.name = name;
+ }
+
+ public int compareTo( AuditRecord other )
+ {
+ // reverse ordering
+ return other.name.compareTo( name );
+ }
+ }
+}
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java
new file mode 100644
index 000000000..612eb51af
--- /dev/null
+++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java
@@ -0,0 +1,44 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.repository.audit.AuditListener;
+
+/**
+ * @plexus.component role="org.apache.maven.archiva.repository.audit.AuditListener" role-hint="metadata"
+ */
+public class MetadataAuditListener
+ implements AuditListener
+{
+ /**
+ * @plexus.requirement
+ */
+ private AuditManager auditManager;
+
+ public void auditEvent( AuditEvent event )
+ {
+ // for now we only log upload events, some of the others are quite noisy
+ if ( event.getAction().equals( AuditEvent.CREATE_FILE ) || event.getAction().equals( AuditEvent.UPLOAD_FILE ) )
+ {
+ auditManager.addAuditEvent( event );
+ }
+ }
+}
diff --git a/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
new file mode 100644
index 000000000..a384a83dc
--- /dev/null
+++ b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
@@ -0,0 +1,507 @@
+package org.apache.archiva.audit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.audit.AuditEvent;
+import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+public class AuditManagerTest
+ extends TestCase
+{
+ private DefaultAuditManager auditManager;
+
+ private MockControl metadataRepositoryControl;
+
+ private MetadataRepository metadataRepository;
+
+ private static final String AUDIT_EVENT_BASE = "2010/01/18/123456.";
+
+ private static final String TEST_REPO_ID = "test-repo";
+
+ private static final String TEST_REPO_ID_2 = "repo2";
+
+ private static final String TEST_USER = "test_user";
+
+ private static final String TEST_RESOURCE_BASE = "test/resource";
+
+ private static final String TEST_IP_ADDRESS = "127.0.0.1";
+
+ private static final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat( AuditEvent.TIMESTAMP_FORMAT );
+
+ private static final DecimalFormat MILLIS_FORMAT = new DecimalFormat( "000" );
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ auditManager = new DefaultAuditManager();
+
+ metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
+ metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+ auditManager.setMetadataRepository( metadataRepository );
+
+ ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
+ repository.setId( TEST_REPO_ID );
+ repository.setLocation( "" );
+ ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent();
+ content.setRepository( repository );
+ MockControl control = MockClassControl.createControl( RepositoryContentFactory.class );
+ RepositoryContentFactory contentFactory = (RepositoryContentFactory) control.getMock();
+ contentFactory.getManagedRepositoryContent( TEST_REPO_ID );
+ control.setDefaultReturnValue( content );
+ control.replay();
+ }
+
+ public void testGetMostRecentEvents()
+ throws ParseException
+ {
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
+ Collections.singletonList( TEST_REPO_ID ) );
+
+ int numEvents = 11;
+ List<String> eventNames = new ArrayList<String>( numEvents );
+ for ( int i = 0; i < numEvents; i++ )
+ {
+ eventNames.add( AUDIT_EVENT_BASE + MILLIS_FORMAT.format( i ) );
+ }
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), eventNames );
+
+ for ( String name : eventNames.subList( 1, eventNames.size() ) )
+ {
+ AuditEvent event = createTestEvent( name );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name ), event );
+ }
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events = auditManager.getMostRecentAuditEvents();
+ assertNotNull( events );
+ assertEquals( numEvents - 1, events.size() );
+ int expectedTimestampCounter = numEvents - 1;
+ for ( AuditEvent event : events )
+ {
+ String num = MILLIS_FORMAT.format( expectedTimestampCounter );
+ assertEvent( event, AUDIT_EVENT_BASE + num, TEST_RESOURCE_BASE + "/" + num );
+ expectedTimestampCounter--;
+ }
+
+ metadataRepositoryControl.verify();
+ }
+
+ private static AuditEvent createTestEvent( String name )
+ throws ParseException
+ {
+ return createTestEvent( TEST_REPO_ID, name );
+ }
+
+ private static AuditEvent createTestEvent( String repositoryId, String name )
+ throws ParseException
+ {
+ AuditEvent event = new AuditEvent();
+ event.setTimestamp( TIMESTAMP_FORMAT.parse( name ) );
+ event.setAction( AuditEvent.UPLOAD_FILE );
+ event.setRemoteIP( TEST_IP_ADDRESS );
+ event.setRepositoryId( repositoryId );
+ event.setUserId( TEST_USER );
+ event.setResource( TEST_RESOURCE_BASE + "/" + name.substring( AUDIT_EVENT_BASE.length() ) );
+ return event;
+ }
+
+ public void testGetMostRecentEventsLessThan10()
+ throws ParseException
+ {
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
+ Collections.singletonList( TEST_REPO_ID ) );
+ int numEvents = 5;
+ List<String> eventNames = new ArrayList<String>( numEvents );
+ for ( int i = 0; i < numEvents; i++ )
+ {
+ eventNames.add( AUDIT_EVENT_BASE + MILLIS_FORMAT.format( i ) );
+ }
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), eventNames );
+
+ for ( String name : eventNames )
+ {
+ AuditEvent event = createTestEvent( name );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name ), event );
+ }
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events = auditManager.getMostRecentAuditEvents();
+ assertNotNull( events );
+ assertEquals( numEvents, events.size() );
+ int expectedTimestampCounter = numEvents - 1;
+ for ( AuditEvent event : events )
+ {
+ String num = MILLIS_FORMAT.format( expectedTimestampCounter );
+ assertEvent( event, AUDIT_EVENT_BASE + num, TEST_RESOURCE_BASE + "/" + num );
+ expectedTimestampCounter--;
+ }
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetMostRecentEventsInterleavedRepositories()
+ throws ParseException
+ {
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
+ Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ) );
+ int numEvents = 11;
+ Map<String, List<String>> eventNames = new LinkedHashMap<String, List<String>>();
+ List<AuditEvent> events = new ArrayList<AuditEvent>();
+ eventNames.put( TEST_REPO_ID, new ArrayList<String>() );
+ eventNames.put( TEST_REPO_ID_2, new ArrayList<String>() );
+ for ( int i = 0; i < numEvents; i++ )
+ {
+ String name = AUDIT_EVENT_BASE + MILLIS_FORMAT.format( i );
+ String repositoryId = i % 2 == 0 ? TEST_REPO_ID : TEST_REPO_ID_2;
+ eventNames.get( repositoryId ).add( name );
+ events.add( createTestEvent( repositoryId, name ) );
+ }
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), eventNames.get( TEST_REPO_ID ) );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID_2, AuditEvent.FACET_ID ),
+ eventNames.get( TEST_REPO_ID_2 ) );
+
+ for ( AuditEvent event : events.subList( 1, events.size() ) )
+ {
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( event.getRepositoryId(), AuditEvent.FACET_ID, event.getName() ),
+ event );
+ }
+ metadataRepositoryControl.replay();
+
+ events = auditManager.getMostRecentAuditEvents();
+ assertNotNull( events );
+ assertEquals( numEvents - 1, events.size() );
+ int expectedTimestampCounter = numEvents - 1;
+ for ( AuditEvent event : events )
+ {
+ String num = MILLIS_FORMAT.format( expectedTimestampCounter );
+ assertEvent( event, AUDIT_EVENT_BASE + num, TEST_RESOURCE_BASE + "/" + num,
+ expectedTimestampCounter % 2 == 0 ? TEST_REPO_ID : TEST_REPO_ID_2 );
+ expectedTimestampCounter--;
+ }
+
+ metadataRepositoryControl.verify();
+ }
+
+ private static void assertEvent( AuditEvent event, String name, String resource )
+ {
+ assertEvent( event, name, resource, TEST_REPO_ID );
+ }
+
+ private static void assertEvent( AuditEvent event, String name, String resource, String repositoryId )
+ {
+ assertEquals( name, TIMESTAMP_FORMAT.format( event.getTimestamp() ) );
+ assertEquals( AuditEvent.UPLOAD_FILE, event.getAction() );
+ assertEquals( TEST_IP_ADDRESS, event.getRemoteIP() );
+ assertEquals( repositoryId, event.getRepositoryId() );
+ assertEquals( TEST_USER, event.getUserId() );
+ assertEquals( resource, event.getResource() );
+ }
+
+ public void testGetMostRecentEventsWhenEmpty()
+ {
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
+ Collections.singletonList( TEST_REPO_ID ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), Collections.emptyList() );
+ metadataRepositoryControl.replay();
+
+ assertTrue( auditManager.getMostRecentAuditEvents().isEmpty() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testAddAuditEvent()
+ throws ParseException
+ {
+ String name = TIMESTAMP_FORMAT.format( new Date() );
+ AuditEvent event = createTestEvent( name );
+
+ metadataRepository.addMetadataFacet( TEST_REPO_ID, event );
+
+ metadataRepositoryControl.replay();
+
+ auditManager.addAuditEvent( event );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testAddAuditEventNoRepositoryId()
+ throws ParseException
+ {
+ String name = TIMESTAMP_FORMAT.format( new Date() );
+ AuditEvent event = createTestEvent( null, name );
+
+ // should just be ignored
+
+ metadataRepositoryControl.replay();
+
+ auditManager.addAuditEvent( event );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testDeleteStats()
+ {
+ metadataRepository.removeMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID );
+
+ metadataRepositoryControl.replay();
+
+ auditManager.deleteAuditEvents( TEST_REPO_ID );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeInside()
+ throws ParseException
+ {
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent = createTestEvent( name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ),
+ Arrays.asList( name1, name2, name3 ) );
+
+ // only match the middle one
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name2 ), expectedEvent );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( TEST_REPO_ID, new Date( current.getTime() - 4000 ),
+ new Date( current.getTime() - 2000 ) );
+
+ assertEquals( 1, events.size() );
+ assertEvent( events.get( 0 ), name2, expectedEvent.getResource() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeUpperOutside()
+ throws ParseException
+ {
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent2 = createTestEvent( name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+ AuditEvent expectedEvent3 = createTestEvent( name3 );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ),
+ Arrays.asList( name1, name2, name3 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name2 ), expectedEvent2 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name3 ), expectedEvent3 );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( TEST_REPO_ID, new Date( current.getTime() - 4000 ), current );
+
+ assertEquals( 2, events.size() );
+ assertEvent( events.get( 0 ), name3, expectedEvent3.getResource() );
+ assertEvent( events.get( 1 ), name2, expectedEvent2.getResource() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeLowerOutside()
+ throws ParseException
+ {
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ AuditEvent expectedEvent1 = createTestEvent( name1 );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent2 = createTestEvent( name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ),
+ Arrays.asList( name1, name2, name3 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name1 ), expectedEvent1 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name2 ), expectedEvent2 );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( TEST_REPO_ID, new Date( current.getTime() - 20000 ),
+ new Date( current.getTime() - 2000 ) );
+
+ assertEquals( 2, events.size() );
+ assertEvent( events.get( 0 ), name2, expectedEvent2.getResource() );
+ assertEvent( events.get( 1 ), name1, expectedEvent1.getResource() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeLowerAndUpperOutside()
+ throws ParseException
+ {
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ AuditEvent expectedEvent1 = createTestEvent( name1 );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent2 = createTestEvent( name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+ AuditEvent expectedEvent3 = createTestEvent( name3 );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ),
+ Arrays.asList( name1, name2, name3 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name1 ), expectedEvent1 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name2 ), expectedEvent2 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name3 ), expectedEvent3 );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( TEST_REPO_ID, new Date( current.getTime() - 20000 ), current );
+
+ assertEquals( 3, events.size() );
+ assertEvent( events.get( 0 ), name3, expectedEvent3.getResource() );
+ assertEvent( events.get( 1 ), name2, expectedEvent2.getResource() );
+ assertEvent( events.get( 2 ), name1, expectedEvent1.getResource() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeMultipleRepositories()
+ throws ParseException
+ {
+ metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(),
+ Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ) );
+
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ AuditEvent expectedEvent1 = createTestEvent( TEST_REPO_ID, name1 );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent2 = createTestEvent( TEST_REPO_ID_2, name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+ AuditEvent expectedEvent3 = createTestEvent( TEST_REPO_ID, name3 );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), Arrays.asList( name1, name3 ) );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID_2, AuditEvent.FACET_ID ), Arrays.asList( name2 ) );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name1 ), expectedEvent1 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID_2, AuditEvent.FACET_ID, name2 ), expectedEvent2 );
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, name3 ), expectedEvent3 );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( null, new Date( current.getTime() - 20000 ), current );
+
+ assertEquals( 3, events.size() );
+ assertEvent( events.get( 0 ), name3, expectedEvent3.getResource() );
+ assertEvent( events.get( 1 ), name2, expectedEvent2.getResource(), TEST_REPO_ID_2 );
+ assertEvent( events.get( 2 ), name1, expectedEvent1.getResource() );
+
+ metadataRepositoryControl.verify();
+ }
+
+ public void testGetEventsRangeNotInside()
+ throws ParseException
+ {
+ Date current = new Date();
+
+ String name1 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 12345 ) );
+ AuditEvent expectedEvent1 = createTestEvent( name1 );
+ Date expectedTimestamp = new Date( current.getTime() - 3000 );
+ String name2 = TIMESTAMP_FORMAT.format( expectedTimestamp );
+ AuditEvent expectedEvent2 = createTestEvent( name2 );
+ String name3 = TIMESTAMP_FORMAT.format( new Date( current.getTime() - 1000 ) );
+ AuditEvent expectedEvent3 = createTestEvent( name3 );
+
+ metadataRepositoryControl.expectAndReturn(
+ metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ),
+ Arrays.asList( name1, name2, name3 ) );
+
+ metadataRepositoryControl.replay();
+
+ List<AuditEvent> events =
+ auditManager.getAuditEventsInRange( TEST_REPO_ID, new Date( current.getTime() - 20000 ),
+ new Date( current.getTime() - 16000 ) );
+
+ assertEquals( 0, events.size() );
+
+ metadataRepositoryControl.verify();
+ }
+} \ No newline at end of file
diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml
index 6a696c690..14c3d24fb 100644
--- a/archiva-modules/plugins/maven2-repository/pom.xml
+++ b/archiva-modules/plugins/maven2-repository/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>maven2-repository</artifactId>
<name>Maven 2.x Repository Support</name>
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
index 5de3777af..e874b3f40 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
@@ -32,4 +32,9 @@ public class MavenProjectFacetFactory
{
return new MavenProjectFacet();
}
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ throw new UnsupportedOperationException( "There is no valid name for project version facets" );
+ }
}
diff --git a/archiva-modules/plugins/metadata-repository-file/pom.xml b/archiva-modules/plugins/metadata-repository-file/pom.xml
index 09eeeb71b..f9188f8b3 100644
--- a/archiva-modules/plugins/metadata-repository-file/pom.xml
+++ b/archiva-modules/plugins/metadata-repository-file/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>metadata-repository-file</artifactId>
<name>File System Backed Metadata Repository</name>
diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
index 6011dbca8..195c11b44 100644
--- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
@@ -293,7 +293,7 @@ public class FileMetadataRepository
MetadataFacetFactory metadataFacetFactory = metadataFacetFactories.get( facetId );
if ( metadataFacetFactory != null )
{
- metadataFacet = metadataFacetFactory.createMetadataFacet();
+ metadataFacet = metadataFacetFactory.createMetadataFacet( repositoryId, name );
Map<String, String> map = new HashMap<String, String>();
for ( String key : properties.stringPropertyNames() )
{
diff --git a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
index 915b0190f..ed71d570b 100644
--- a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
+++ b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
@@ -69,6 +69,8 @@ public class FileMetadataRepositoryTest
private static final String TEST_SHA1 = "2e5daf0201ddeb068a62d5e08da18657ab2c6be9";
+ private static final String TEST_METADATA_VALUE = "test-metadata";
+
public void setUp()
throws Exception
{
@@ -84,7 +86,12 @@ public class FileMetadataRepositoryTest
{
public MetadataFacet createMetadataFacet()
{
- return new TestMetadataFacet( "test-metadata" );
+ return new TestMetadataFacet( TEST_METADATA_VALUE );
+ }
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new TestMetadataFacet( TEST_METADATA_VALUE );
}
} );
@@ -93,7 +100,12 @@ public class FileMetadataRepositoryTest
{
public MetadataFacet createMetadataFacet()
{
- return new TestMetadataFacet( "", "test-value" );
+ return new TestMetadataFacet( "", TEST_VALUE );
+ }
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new TestMetadataFacet( "", TEST_VALUE );
}
} );
repository.setMetadataFacetFactories( factories );
@@ -189,7 +201,7 @@ public class FileMetadataRepositoryTest
{
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( null ) );
- assertEquals( new TestMetadataFacet( "test-metadata" ),
+ assertEquals( new TestMetadataFacet( TEST_METADATA_VALUE ),
repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
diff --git a/archiva-modules/plugins/pom.xml b/archiva-modules/plugins/pom.xml
index 19878499a..a564ac416 100644
--- a/archiva-modules/plugins/pom.xml
+++ b/archiva-modules/plugins/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>archiva-modules</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>plugins</artifactId>
<name>Archiva Core Plugins</name>
@@ -31,5 +31,6 @@
<module>maven2-repository</module>
<module>repository-statistics</module>
<module>problem-reports</module>
+ <module>audit</module>
</modules>
</project> \ No newline at end of file
diff --git a/archiva-modules/plugins/problem-reports/pom.xml b/archiva-modules/plugins/problem-reports/pom.xml
index 955cfdf62..5d98090a5 100644
--- a/archiva-modules/plugins/problem-reports/pom.xml
+++ b/archiva-modules/plugins/problem-reports/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>problem-reports</artifactId>
<name>Archiva Problem Reporting Plugin</name>
diff --git a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemFacetFactory.java b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemFacetFactory.java
index aeb602b59..5f95f1496 100644
--- a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemFacetFactory.java
+++ b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/RepositoryProblemFacetFactory.java
@@ -32,4 +32,9 @@ public class RepositoryProblemFacetFactory
{
return new RepositoryProblemFacet();
}
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new RepositoryProblemFacet();
+ }
}
diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml
index 83a2df5d7..247e1d884 100644
--- a/archiva-modules/plugins/repository-statistics/pom.xml
+++ b/archiva-modules/plugins/repository-statistics/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<artifactId>repository-statistics</artifactId>
<name>Repository Statistics</name>
diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
index 80d50359e..60ce58a15 100644
--- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
+++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
@@ -20,6 +20,7 @@ package org.apache.archiva.metadata.repository.stats;
*/
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -164,7 +165,7 @@ public class DefaultRepositoryStatisticsManager
{
try
{
- Date date = RepositoryStatistics.SCAN_TIMESTAMP.parse( name );
+ Date date = new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT ).parse( name );
if ( ( startTime == null || !date.before( startTime ) ) &&
( endTime == null || !date.after( endTime ) ) )
{
diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java
index 79678ac3d..68407cb54 100644
--- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java
+++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java
@@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository.stats;
* under the License.
*/
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
@@ -48,7 +47,7 @@ public class RepositoryStatistics
public static String FACET_ID = "org.apache.archiva.metadata.repository.stats";
- static final DateFormat SCAN_TIMESTAMP = new SimpleDateFormat( "yyyy/MM/dd/HHmmss.SSS" );
+ static final String SCAN_TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS";
private Map<String, Long> totalCountForType = new HashMap<String, Long>();
@@ -144,7 +143,7 @@ public class RepositoryStatistics
public String getName()
{
- return SCAN_TIMESTAMP.format( scanStartTime );
+ return new SimpleDateFormat( SCAN_TIMESTAMP_FORMAT ).format( scanStartTime );
}
public Map<String, String> toProperties()
diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java
index d819195f8..49716a99c 100644
--- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java
+++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsFactory.java
@@ -32,4 +32,9 @@ public class RepositoryStatisticsFactory
{
return new RepositoryStatistics();
}
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new RepositoryStatistics();
+ }
} \ No newline at end of file
diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
index 09ec07907..453e3a4d8 100644
--- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
+++ b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
@@ -20,6 +20,7 @@ package org.apache.archiva.metadata.repository.stats;
*/
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -82,10 +83,11 @@ public class RepositoryStatisticsManagerTest
public void testGetLatestStats()
throws ParseException
{
- Date endTime = new Date( RepositoryStatistics.SCAN_TIMESTAMP.parse( SECOND_TEST_SCAN ).getTime() + 60000 );
+ Date startTime = parseTimestamp( SECOND_TEST_SCAN );
+ Date endTime = new Date( startTime.getTime() + 60000 );
RepositoryStatistics stats = new RepositoryStatistics();
- stats.setScanStartTime( RepositoryStatistics.SCAN_TIMESTAMP.parse( SECOND_TEST_SCAN ) );
+ stats.setScanStartTime( startTime );
stats.setScanEndTime( endTime );
stats.setTotalArtifactFileSize( 1314527915L );
stats.setNewFileCount( 123 );
@@ -110,13 +112,24 @@ public class RepositoryStatisticsManagerTest
assertEquals( 2031, stats.getTotalProjectCount() );
assertEquals( 529, stats.getTotalGroupCount() );
assertEquals( 56229, stats.getTotalFileCount() );
- assertEquals( SECOND_TEST_SCAN, RepositoryStatistics.SCAN_TIMESTAMP.format( stats.getScanStartTime() ) );
+ assertEquals( SECOND_TEST_SCAN, formatTimestamp( stats.getScanStartTime() ) );
assertEquals( SECOND_TEST_SCAN, stats.getName() );
assertEquals( endTime, stats.getScanEndTime() );
metadataRepositoryControl.verify();
}
+ private static String formatTimestamp( Date value )
+ {
+ return new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT ).format( value );
+ }
+
+ private static Date parseTimestamp( String value )
+ throws ParseException
+ {
+ return new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT ).parse( value );
+ }
+
public void testGetLatestStatsWhenEmpty()
{
metadataRepositoryControl.expectAndReturn(
@@ -516,8 +529,7 @@ public class RepositoryStatisticsManagerTest
metadataRepositoryControl.expectAndReturn(
metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ),
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ),
- createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT",
- "pom" ) ) );
+ createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
metadataRepositoryControl.expectAndReturn(
metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ),
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ),
diff --git a/archiva-modules/pom.xml b/archiva-modules/pom.xml
index 262af917b..6420502b3 100644
--- a/archiva-modules/pom.xml
+++ b/archiva-modules/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>archiva</artifactId>
<groupId>org.apache.archiva</groupId>
- <version>1.3-SNAPSHOT</version>
+ <version>1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-modules</artifactId>