aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java14
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java7
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java33
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java24
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java16
5 files changed, 62 insertions, 32 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
index b749963da..c106c8e62 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
@@ -18,8 +18,10 @@ package org.apache.archiva.admin.repository.remote;
* under the License.
*/
+import org.apache.archiva.admin.AuditInformation;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.audit.AuditEvent;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
@@ -68,9 +70,10 @@ public class DefaultRemoteRepositoryAdmin
return null;
}
- public Boolean addRemoteRepository( RemoteRepository remoteRepository )
+ public Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
throws RepositoryAdminException
{
+ triggerAuditEvent( remoteRepository.getId(), null, AuditEvent.ADD_REMOTE_REPO, auditInformation );
getRepositoryCommonValidator().basicValidation( remoteRepository, false );
//TODO we can validate it's a good uri/url
@@ -94,12 +97,17 @@ public class DefaultRemoteRepositoryAdmin
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addRemoteRepository( remoteRepositoryConfiguration );
saveConfiguration( configuration );
+
+
return Boolean.TRUE;
}
- public Boolean deleteRemoteRepository( String repositoryId )
+ public Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
throws RepositoryAdminException
{
+
+ triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_REMOTE_REPO, auditInformation );
+
Configuration configuration = getArchivaConfiguration().getConfiguration();
RemoteRepositoryConfiguration remoteRepositoryConfiguration =
@@ -127,7 +135,7 @@ public class DefaultRemoteRepositoryAdmin
return Boolean.TRUE;
}
- public Boolean updateRemoteRepository( RemoteRepository remoteRepository )
+ public Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
throws RepositoryAdminException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
index 6a23ea9f4..3adde318f 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
@@ -19,6 +19,7 @@ package org.apache.archiva.admin.repository.remote;
*/
+import org.apache.archiva.admin.AuditInformation;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import java.util.List;
@@ -35,12 +36,12 @@ public interface RemoteRepositoryAdmin
RemoteRepository getRemoteRepository( String repositoryId )
throws RepositoryAdminException;
- Boolean deleteRemoteRepository( String repositoryId )
+ Boolean deleteRemoteRepository( String repositoryId, AuditInformation auditInformation )
throws RepositoryAdminException;
- Boolean addRemoteRepository( RemoteRepository remoteRepository )
+ Boolean addRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
throws RepositoryAdminException;
- Boolean updateRemoteRepository( RemoteRepository remoteRepository )
+ Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation )
throws RepositoryAdminException;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
index 02e72d357..2c5ae5cab 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
@@ -19,12 +19,18 @@ package org.apache.archiva.admin.repository;
*/
import junit.framework.TestCase;
+import org.apache.archiva.admin.AuditInformation;
+import org.apache.archiva.admin.mock.MockAuditListener;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.memory.SimpleUser;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import javax.inject.Inject;
+
/**
* @author Olivier Lamy
*/
@@ -36,5 +42,30 @@ public abstract class AbstractRepositoryAdminTest
protected Logger log = LoggerFactory.getLogger( getClass() );
public static final String APPSERVER_BASE_PATH = System.getProperty( "appserver.base" );
- // no op
+
+ @Inject
+ protected MockAuditListener mockAuditListener;
+
+ protected AuditInformation getFakeAuditInformation()
+ {
+ AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost" );
+ return auditInformation;
+ }
+
+ protected User getFakeUser()
+ {
+ SimpleUser user = new SimpleUser()
+ {
+ @Override
+ public Object getPrincipal()
+ {
+ return "root";
+ }
+
+ };
+
+ user.setUsername( "root" );
+ user.setFullName( "The top user" );
+ return user;
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
index 517d8c7df..581660251 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java
@@ -44,8 +44,7 @@ public class ManagedRepositoryAdminTest
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
- @Inject
- private MockAuditListener mockAuditListener;
+
@Inject
protected RoleManager roleManager;
@@ -416,28 +415,7 @@ public class ManagedRepositoryAdminTest
return null;
}
- AuditInformation getFakeAuditInformation()
- {
- AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost" );
- return auditInformation;
- }
- User getFakeUser()
- {
- SimpleUser user = new SimpleUser()
- {
- @Override
- public Object getPrincipal()
- {
- return "root";
- }
-
- };
-
- user.setUsername( "root" );
- user.setFullName( "The top user" );
- return user;
- }
ManagedRepository getTestManagedRepository( String repoId, String repoLocation )
{
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java
index 1da181adf..77ff94d73 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdminTest.java
@@ -19,6 +19,7 @@ package org.apache.archiva.admin.repository.remote;
*/
import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.apache.archiva.audit.AuditEvent;
import org.junit.Test;
import javax.inject.Inject;
@@ -60,11 +61,12 @@ public class RemoteRepositoryAdminTest
public void addAndDelete()
throws Exception
{
+ mockAuditListener.clearEvents();
int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
RemoteRepository remoteRepository = getRemoteRepository();
- remoteRepositoryAdmin.addRemoteRepository( remoteRepository );
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
@@ -76,12 +78,22 @@ public class RemoteRepositoryAdminTest
assertEquals( getRemoteRepository().getName(), repo.getName() );
assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
- remoteRepositoryAdmin.deleteRemoteRepository( "foo" );
+ remoteRepositoryAdmin.deleteRemoteRepository( "foo", getFakeAuditInformation() );
assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
assertNull( repo );
+
+ assertEquals( 2, mockAuditListener.getAuditEvents().size() );
+
+ assertEquals( AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+ assertEquals( "archiva-localhost", mockAuditListener.getAuditEvents().get( 0 ).getRemoteIP() );
+
+ assertEquals( AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get( 1 ).getAction() );
+ assertEquals( "root", mockAuditListener.getAuditEvents().get( 0 ).getUserId() );
+
}