From: Brett Porter Date: Thu, 31 Jul 2014 05:10:37 +0000 (+1000) Subject: split out audit facet and listener to match others X-Git-Tag: archiva-2.1.1~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fafb8d284f3b80847c0373d1f7485565ef306b19;p=archiva.git split out audit facet and listener to match others by placing these in the metadata model / API they can be used more broadly, while the storage-dependant implementation can be in a plugin. This means the plugins can be removed from the admin implementation, which can then be used (as required) in the CLI --- diff --git a/archiva-cli/pom.xml b/archiva-cli/pom.xml index f47154902..6faddb5a6 100644 --- a/archiva-cli/pom.xml +++ b/archiva-cli/pom.xml @@ -36,6 +36,10 @@ org.apache.archiva archiva-repository-admin-api + + org.apache.archiva + archiva-repository-admin-default + org.apache.archiva archiva-consumer-api diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java index e2a9d5caa..1f2a9e335 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java @@ -19,7 +19,7 @@ package org.apache.archiva.consumers.core.repository; * under the License. */ -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml index b64ff906c..f0f8d7701 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml @@ -47,15 +47,15 @@ org.apache.archiva - repository-statistics + archiva-plexus-bridge org.apache.archiva - archiva-plexus-bridge + metadata-repository-api org.apache.archiva - audit + metadata-model javax.inject diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java index 3baa42632..183e15b75 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java @@ -21,17 +21,18 @@ package org.apache.archiva.admin.repository; import org.apache.archiva.admin.model.AuditInformation; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryCommonValidator; -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.IndeterminateConfigurationException; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.components.registry.Registry; +import org.apache.archiva.repository.events.AuditListener; import org.modelmapper.ModelMapper; import org.modelmapper.convention.MatchingStrategies; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import javax.inject.Inject; import javax.inject.Named; @@ -47,6 +48,7 @@ public abstract class AbstractRepositoryAdmin protected Logger log = LoggerFactory.getLogger( getClass() ); @Inject + @Autowired(required = false) private List auditListeners = new ArrayList<>(); @Inject diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java index f357bc2db..a75a88e11 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java @@ -27,10 +27,10 @@ import org.apache.archiva.admin.model.beans.NetworkConfiguration; import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.UserInterfaceOptions; import org.apache.archiva.configuration.WebappConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.lang.StringUtils; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.maven.wagon.providers.http.HttpWagon; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java index af4fea009..0f8e54f3d 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java @@ -25,9 +25,9 @@ import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.RepositoryGroupConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index cfe4b624e..f398bca26 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -23,7 +23,6 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; @@ -31,6 +30,7 @@ import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RepositoryGroupConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java index 7b63551a3..7c3eb0c3e 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java @@ -23,10 +23,10 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.NetworkProxyConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java index 73450cbd5..fbf20481c 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java @@ -26,10 +26,10 @@ import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorOrderComparator; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.functors.ProxyConnectorSelectionPredicate; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index 28482f7c3..9f6a20b9d 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -23,13 +23,13 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.lang.StringUtils; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexCreator; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockAuditListener.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockAuditListener.java index 90cd99692..42abfcf5e 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockAuditListener.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockAuditListener.java @@ -18,8 +18,8 @@ package org.apache.archiva.admin.mock; * under the License. */ -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import org.springframework.stereotype.Service; import java.util.ArrayList; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java index 5abd7a6fa..2c46004ff 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java @@ -26,7 +26,7 @@ import org.apache.archiva.admin.model.beans.NetworkConfiguration; import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.junit.Test; import javax.inject.Inject; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/group/RepositoryGroupAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/group/RepositoryGroupAdminTest.java index a79d724d0..9403ae19d 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/group/RepositoryGroupAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/group/RepositoryGroupAdminTest.java @@ -23,7 +23,7 @@ import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.junit.Test; import javax.inject.Inject; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java index 4f73fa960..f2678290e 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java @@ -20,7 +20,7 @@ package org.apache.archiva.admin.repository.managed; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.junit.Test; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/networkproxy/NetworkProxyAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/networkproxy/NetworkProxyAdminTest.java index 0f6d37634..21020d1e8 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/networkproxy/NetworkProxyAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/networkproxy/NetworkProxyAdminTest.java @@ -22,7 +22,7 @@ import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.junit.Test; import javax.inject.Inject; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java index 0e4303d72..7c301d122 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java @@ -21,7 +21,7 @@ package org.apache.archiva.admin.repository.proxyconnector; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.junit.Test; import java.util.Arrays; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java index cf062996f..68864460b 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java @@ -20,7 +20,7 @@ package org.apache.archiva.admin.repository.remote; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.junit.Test; import java.util.List; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java index 104e0d212..89cd78be4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java @@ -25,8 +25,8 @@ import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.indexer.search.SearchResultHit; import org.apache.archiva.maven2.model.Artifact; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java index a5c76b0b9..cead4c0fa 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java @@ -20,7 +20,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.metadata.model.ArtifactMetadata; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index 462af2127..6c3aaa7d4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -23,7 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java index 1719a7188..6e6c90565 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java @@ -24,7 +24,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; import org.apache.archiva.common.utils.VersionComparator; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java index 559f160d8..3f05f7882 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java @@ -20,8 +20,8 @@ package org.apache.archiva.webdav; */ import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.common.filelock.FileLockException; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.common.filelock.FileLockTimeoutException; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index a239abaee..782682ae5 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -24,8 +24,8 @@ import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.audit.Auditable; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/repository/audit/TestAuditListener.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/repository/audit/TestAuditListener.java index b58cee62e..8cab4dc2c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/repository/audit/TestAuditListener.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/repository/audit/TestAuditListener.java @@ -19,8 +19,8 @@ package org.apache.archiva.repository.audit; * under the License. */ -import org.apache.archiva.audit.AuditEvent; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import java.util.ArrayList; import java.util.List; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java index e8e8b63a8..0d99709b6 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java @@ -21,7 +21,7 @@ package org.apache.archiva.webdav; import junit.framework.TestCase; import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.audit.AuditListener; +import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.webdav.DavException; diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/facets/AuditEvent.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/facets/AuditEvent.java new file mode 100644 index 000000000..ba47519e7 --- /dev/null +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/facets/AuditEvent.java @@ -0,0 +1,361 @@ +package org.apache.archiva.metadata.model.facets; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.metadata.model.MetadataFacet; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; + +/** + * AuditEvent + * + * + */ +public class AuditEvent + implements MetadataFacet +{ + public static final String TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS"; + + public static final String CREATE_DIR = "Created Directory"; + + public static final String CREATE_FILE = "Created File"; + + public static final String REMOVE_DIR = "Removed Directory"; + + public static final String REMOVE_FILE = "Removed File"; + + public static final String MODIFY_FILE = "Modified File"; + + public static final String MOVE_FILE = "Moved File"; + + public static final String MOVE_DIRECTORY = "Moved Directory"; + + public static final String COPY_DIRECTORY = "Copied Directory"; + + public static final String COPY_FILE = "Copied File"; + + public static final String UPLOAD_FILE = "Uploaded File"; + + public static final String ADD_LEGACY_PATH = "Added Legacy Artifact Path"; + + public static final String REMOVE_LEGACY_PATH = "Removed Legacy Artifact Path"; + + public static final String PURGE_ARTIFACT = "Purged Artifact"; + + public static final String PURGE_FILE = "Purged Support File"; + + public static final String REMOVE_SCANNED = "Removed in Filesystem"; + + public static final String MERGING_REPOSITORIES = "Merged Artifact"; + + // configuration events + + public static final String ADD_MANAGED_REPO = "Added Managed Repository"; + + public static final String MODIFY_MANAGED_REPO = "Updated Managed Repository"; + + public static final String DELETE_MANAGED_REPO = "Deleted Managed Repository"; + + public static final String ADD_REMOTE_REPO = "Added Remote Repository"; + + public static final String MODIFY_REMOTE_REPO = "Updated Remote Repository"; + + public static final String DELETE_REMOTE_REPO = "Deleted Remote Repository"; + + public static final String ADD_REPO_GROUP = "Added Repository Group"; + + public static final String DELETE_REPO_GROUP = "Deleted Repository Group"; + + public static final String MODIFY_REPO_GROUP = "Modify Repository Group"; + + public static final String ADD_REPO_TO_GROUP = "Added Repository to Group"; + + public static final String DELETE_REPO_FROM_GROUP = "Deleted Repository from Group"; + + public static final String ENABLE_REPO_CONSUMER = "Enabled Content Consumer"; + + public static final String DISABLE_REPO_CONSUMER = "Disabled Content Consumer"; + + public static final String ADD_PATTERN = "Added File Type Pattern"; + + public static final String REMOVE_PATTERN = "Removed File Type Pattern"; + + public static final String MERGE_REPO_REMOTE = "Merged Staging Repository Triggered Remotely"; + + public static final String ADD_PROXY_CONNECTOR = "Added Proxy Connector"; + + public static final String DELETE_PROXY_CONNECTOR = "Deleted Proxy Connector"; + + public static final String MODIFY_PROXY_CONNECTOR = "Updated Proxy Connector"; + + public static final String ADD_NETWORK_PROXY = "Added Network Proxy"; + + public static final String DELETE_NETWORK_PROXY = "Deleted Network Proxy"; + + public static final String MODIFY_NETWORK_PROXY = "Updated Network Proxy"; + + private String repositoryId; + + private String userId; + + private String remoteIP; + + // TODO: change to artifact reference? does it ever refer to just a path? + + private String resource; + + private String action; + + private Date timestamp; + + public static final String FACET_ID = "org.apache.archiva.audit"; + + private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); + + private static final int TS_LENGTH = TIMESTAMP_FORMAT.length(); + + public AuditEvent() + { + /* do nothing */ + } + + public AuditEvent( String name, String repositoryId ) + { + String ts = name.substring( 0, TS_LENGTH ); + try + { + timestamp = createNameFormat().parse( ts ); + } + catch ( ParseException e ) + { + throw new IllegalArgumentException( "Improperly formatted timestamp for audit log event: " + ts, e); + } + + if ( name.length() > TS_LENGTH ) + { + if ( name.charAt( TS_LENGTH ) != '/' ) + { + throw new IllegalArgumentException( + "Improperly formatted name for audit log event, no / separator between timestamp and resource: " + + name ); + } + } + + this.repositoryId = repositoryId; + } + + public AuditEvent( String repoId, String user, String resource, String action ) + { + this.repositoryId = repoId; + this.userId = user; + this.resource = resource; + this.action = action; + this.timestamp = Calendar.getInstance().getTime(); + } + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public String getUserId() + { + return userId; + } + + public void setUserId( String userId ) + { + this.userId = userId; + } + + public String getResource() + { + return resource; + } + + public void setResource( String resource ) + { + this.resource = resource; + } + + public String getAction() + { + return action; + } + + public void setAction( String action ) + { + this.action = action; + } + + public String getRemoteIP() + { + return remoteIP; + } + + public void setRemoteIP( String remoteIP ) + { + this.remoteIP = remoteIP; + } + + public Date getTimestamp() + { + return timestamp; + } + + public void setTimestamp( Date timestamp ) + { + this.timestamp = timestamp; + } + + @Override + public String getFacetId() + { + return FACET_ID; + } + + @Override + public String getName() + { + // use the hashCode here to make it unique if multiple events occur at a certain timestamp. None of the other + // fields is unique on its own + return createNameFormat().format( timestamp ) + "/" + Integer.toHexString( hashCode() ); + // TODO: a simple incremental counter might be better since it will retain ordering, but then we need to do a + // bit of locking... + } + + private static SimpleDateFormat createNameFormat() + { + SimpleDateFormat fmt = new SimpleDateFormat( TIMESTAMP_FORMAT ); + fmt.setTimeZone( UTC_TIME_ZONE ); + return fmt; + } + + @Override + public Map toProperties() + { + Map properties = new HashMap<>(); + 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; + } + + @Override + public void fromProperties( Map 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() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "AuditEvent" ); + sb.append( "{repositoryId='" ).append( repositoryId ).append( '\'' ); + sb.append( ", userId='" ).append( userId ).append( '\'' ); + sb.append( ", remoteIP='" ).append( remoteIP ).append( '\'' ); + sb.append( ", resource='" ).append( resource ).append( '\'' ); + sb.append( ", action='" ).append( action ).append( '\'' ); + sb.append( ", timestamp=" ).append( timestamp ); + sb.append( '}' ); + return sb.toString(); + } + + +} diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/repository/events/AuditListener.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/repository/events/AuditListener.java new file mode 100644 index 000000000..ade9f7959 --- /dev/null +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/repository/events/AuditListener.java @@ -0,0 +1,37 @@ +package org.apache.archiva.repository.events; + +/* + * 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.facets.AuditEvent; + +/** + * AuditListener + * + * + */ +public interface AuditListener +{ + /** + * Notification that an audit event occured. + * + * @param event the event details. + */ + void auditEvent( AuditEvent event ); +} diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java deleted file mode 100644 index b0da64d65..000000000 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEvent.java +++ /dev/null @@ -1,361 +0,0 @@ -package org.apache.archiva.audit; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.metadata.model.MetadataFacet; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; - -/** - * AuditEvent - * - * - */ -public class AuditEvent - implements MetadataFacet -{ - public static final String TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS"; - - public static final String CREATE_DIR = "Created Directory"; - - public static final String CREATE_FILE = "Created File"; - - public static final String REMOVE_DIR = "Removed Directory"; - - public static final String REMOVE_FILE = "Removed File"; - - public static final String MODIFY_FILE = "Modified File"; - - public static final String MOVE_FILE = "Moved File"; - - public static final String MOVE_DIRECTORY = "Moved Directory"; - - public static final String COPY_DIRECTORY = "Copied Directory"; - - public static final String COPY_FILE = "Copied File"; - - public static final String UPLOAD_FILE = "Uploaded File"; - - public static final String ADD_LEGACY_PATH = "Added Legacy Artifact Path"; - - public static final String REMOVE_LEGACY_PATH = "Removed Legacy Artifact Path"; - - public static final String PURGE_ARTIFACT = "Purged Artifact"; - - public static final String PURGE_FILE = "Purged Support File"; - - public static final String REMOVE_SCANNED = "Removed in Filesystem"; - - public static final String MERGING_REPOSITORIES = "Merged Artifact"; - - // configuration events - - public static final String ADD_MANAGED_REPO = "Added Managed Repository"; - - public static final String MODIFY_MANAGED_REPO = "Updated Managed Repository"; - - public static final String DELETE_MANAGED_REPO = "Deleted Managed Repository"; - - public static final String ADD_REMOTE_REPO = "Added Remote Repository"; - - public static final String MODIFY_REMOTE_REPO = "Updated Remote Repository"; - - public static final String DELETE_REMOTE_REPO = "Deleted Remote Repository"; - - public static final String ADD_REPO_GROUP = "Added Repository Group"; - - public static final String DELETE_REPO_GROUP = "Deleted Repository Group"; - - public static final String MODIFY_REPO_GROUP = "Modify Repository Group"; - - public static final String ADD_REPO_TO_GROUP = "Added Repository to Group"; - - public static final String DELETE_REPO_FROM_GROUP = "Deleted Repository from Group"; - - public static final String ENABLE_REPO_CONSUMER = "Enabled Content Consumer"; - - public static final String DISABLE_REPO_CONSUMER = "Disabled Content Consumer"; - - public static final String ADD_PATTERN = "Added File Type Pattern"; - - public static final String REMOVE_PATTERN = "Removed File Type Pattern"; - - public static final String MERGE_REPO_REMOTE = "Merged Staging Repository Triggered Remotely"; - - public static final String ADD_PROXY_CONNECTOR = "Added Proxy Connector"; - - public static final String DELETE_PROXY_CONNECTOR = "Deleted Proxy Connector"; - - public static final String MODIFY_PROXY_CONNECTOR = "Updated Proxy Connector"; - - public static final String ADD_NETWORK_PROXY = "Added Network Proxy"; - - public static final String DELETE_NETWORK_PROXY = "Deleted Network Proxy"; - - public static final String MODIFY_NETWORK_PROXY = "Updated Network Proxy"; - - private String repositoryId; - - private String userId; - - private String remoteIP; - - // TODO: change to artifact reference? does it ever refer to just a path? - - private String resource; - - private String action; - - private Date timestamp; - - public static final String FACET_ID = "org.apache.archiva.audit"; - - private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); - - private static final int TS_LENGTH = TIMESTAMP_FORMAT.length(); - - public AuditEvent() - { - /* do nothing */ - } - - public AuditEvent( String name, String repositoryId ) - { - String ts = name.substring( 0, TS_LENGTH ); - try - { - timestamp = createNameFormat().parse( ts ); - } - catch ( ParseException e ) - { - throw new IllegalArgumentException( "Improperly formatted timestamp for audit log event: " + ts, e); - } - - if ( name.length() > TS_LENGTH ) - { - if ( name.charAt( TS_LENGTH ) != '/' ) - { - throw new IllegalArgumentException( - "Improperly formatted name for audit log event, no / separator between timestamp and resource: " + - name ); - } - } - - this.repositoryId = repositoryId; - } - - public AuditEvent( String repoId, String user, String resource, String action ) - { - this.repositoryId = repoId; - this.userId = user; - this.resource = resource; - this.action = action; - this.timestamp = Calendar.getInstance().getTime(); - } - - public String getRepositoryId() - { - return repositoryId; - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } - - public String getUserId() - { - return userId; - } - - public void setUserId( String userId ) - { - this.userId = userId; - } - - public String getResource() - { - return resource; - } - - public void setResource( String resource ) - { - this.resource = resource; - } - - public String getAction() - { - return action; - } - - public void setAction( String action ) - { - this.action = action; - } - - public String getRemoteIP() - { - return remoteIP; - } - - public void setRemoteIP( String remoteIP ) - { - this.remoteIP = remoteIP; - } - - public Date getTimestamp() - { - return timestamp; - } - - public void setTimestamp( Date timestamp ) - { - this.timestamp = timestamp; - } - - @Override - public String getFacetId() - { - return FACET_ID; - } - - @Override - public String getName() - { - // use the hashCode here to make it unique if multiple events occur at a certain timestamp. None of the other - // fields is unique on its own - return createNameFormat().format( timestamp ) + "/" + Integer.toHexString( hashCode() ); - // TODO: a simple incremental counter might be better since it will retain ordering, but then we need to do a - // bit of locking... - } - - private static SimpleDateFormat createNameFormat() - { - SimpleDateFormat fmt = new SimpleDateFormat( TIMESTAMP_FORMAT ); - fmt.setTimeZone( UTC_TIME_ZONE ); - return fmt; - } - - @Override - public Map toProperties() - { - Map properties = new HashMap<>(); - 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; - } - - @Override - public void fromProperties( Map 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() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "AuditEvent" ); - sb.append( "{repositoryId='" ).append( repositoryId ).append( '\'' ); - sb.append( ", userId='" ).append( userId ).append( '\'' ); - sb.append( ", remoteIP='" ).append( remoteIP ).append( '\'' ); - sb.append( ", resource='" ).append( resource ).append( '\'' ); - sb.append( ", action='" ).append( action ).append( '\'' ); - sb.append( ", timestamp=" ).append( timestamp ); - sb.append( '}' ); - return sb.toString(); - } - - -} 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 index f25ef8ec9..620100fcf 100644 --- 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 @@ -21,6 +21,7 @@ package org.apache.archiva.audit; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacetFactory; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.springframework.stereotype.Service; /** diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java deleted file mode 100644 index 6e64d6ed8..000000000 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.apache.archiva.audit; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * AuditListener - * - * - */ -public interface AuditListener -{ - /** - * Notification that an audit event occured. - * - * @param event the event details. - */ - void auditEvent( AuditEvent event ); -} diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java index eeb99b5d7..37b5a5211 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java @@ -19,6 +19,8 @@ package org.apache.archiva.audit; * under the License. */ +import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.repository.events.AuditListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; 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 index 09d6b765b..73b0a16e6 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.archiva.audit; * under the License. */ +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java index 5e396b116..d43cff320 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java @@ -19,6 +19,8 @@ package org.apache.archiva.audit; * under the License. */ +import org.apache.archiva.repository.events.AuditListener; + /** * Auditable * 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 index ca93bbe43..44086185c 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.archiva.audit; * under the License. */ +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.slf4j.Logger; 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 index 3ad104fe5..8406bbb7a 100644 --- 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 @@ -19,9 +19,11 @@ package org.apache.archiva.audit; * under the License. */ +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.repository.events.AuditListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; 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 index 0505562a0..8119ba4e9 100644 --- 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 @@ -21,6 +21,7 @@ package org.apache.archiva.audit; import junit.framework.TestCase; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.easymock.EasyMock;