Author: oching
Date: Wed Feb 3 11:14:20 2010
New Revision: 905998
URL: http://svn.apache.org/viewvc?rev=905998&view=rev
Log:
[MRM-1316] audit log report does not restrict events to repositories that you
are a manager of
merged from trunk -r905996
Modified:
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
Modified:
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
URL:
http://svn.apache.org/viewvc/archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties?rev=905998&r1=905997&r2=905998&view=diff
==============================================================================
---
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
(original)
+++
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
Wed Feb 3 11:14:20 2010
@@ -77,6 +77,13 @@
ARTIFACTFILEPATH1=test
REPOSITORYID1=internal
+SNAPSHOT_GROUPID=org.apache.archiva
+SNAPSHOT_ARTIFACTID=archiva-test
+SNAPSHOT_VERSION=1.0-SNAPSHOT
+SNAPSHOT_PACKAGING=jar
+SNAPSHOT_ARTIFACTFILEPATH=test
+SNAPSHOT_REPOSITORYID=snapshots
+
# REPOSITORIES
# Manage Repositories
MANAGED_IDENTIFIER=testing1
Modified:
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
URL:
http://svn.apache.org/viewvc/archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java?rev=905998&r1=905997&r2=905998&view=diff
==============================================================================
---
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
(original)
+++
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
Wed Feb 3 11:14:20 2010
@@ -128,4 +128,40 @@
assertTextPresent( "internal" );
assertTextPresent( "admin" );
}
+
+ @Test (dependsOnMethods = { "testAddArtifactValidValues",
"testUserWithRepoManagerInternalRole" }, enabled = false )
+ public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
+ {
+ String groupId = getProperty( "SNAPSHOT_GROUPID" );
+ String artifactId = getProperty( "SNAPSHOT_ARTIFACTID" );
+ String version = getProperty( "SNAPSHOT_VERSION" );
+ String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
+ String packaging = getProperty( "SNAPSHOT_PACKAGING" );
+
+ addArtifact( groupId, artifactId, version, packaging, getProperty(
"SNAPSHOT_ARTIFACTFILEPATH" ), repo );
+ assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" +
version +
+ "' was successfully deployed to repository '" + repo + "'" );
+
+ clickLinkWithText( "Logout" );
+
+ login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ),
getUserRolePassword() );
+ 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" );
+
+ assertTextNotPresent( artifactId + "-" + version + "." + packaging );
+
+ clickLinkWithText( "Logout" );
+ login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD"
) );
+ }
}
Modified:
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
URL:
http://svn.apache.org/viewvc/archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java?rev=905998&r1=905997&r2=905998&view=diff
==============================================================================
---
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
(original)
+++
archiva/branches/archiva-1.3.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
Wed Feb 3 11:14:20 2010
@@ -149,7 +149,7 @@
}
SimpleConstraint constraint = new
MostRecentArchivaAuditLogsConstraint();
- auditLogs = (List<ArchivaAuditLogs>) dao.query( constraint );
+ auditLogs = filterLogs( (List<ArchivaAuditLogs>) dao.query( constraint
) );
}
public String execute()
@@ -216,7 +216,8 @@
try
{
- auditLogs = auditLogsDao.queryAuditLogs( constraint );
+ auditLogs = filterLogs( auditLogsDao.queryAuditLogs( constraint )
);
+
if( auditLogs.isEmpty() )
{
addActionError( "No audit logs found." );
@@ -244,6 +245,25 @@
return SUCCESS;
}
+ private List<ArchivaAuditLogs> filterLogs( List<ArchivaAuditLogs>
auditLogs )
+ {
+ List<String> observableRepos = getManageableRepositories();
+ List<ArchivaAuditLogs> filteredAuditLogs = new
ArrayList<ArchivaAuditLogs>();
+
+ if( auditLogs != null )
+ {
+ for( ArchivaAuditLogs auditLog : auditLogs )
+ {
+ if( observableRepos.contains( auditLog.getRepositoryId() ) )
+ {
+ filteredAuditLogs.add( auditLog );
+ }
+ }
+ }
+
+ return filteredAuditLogs;
+ }
+
private void paginate()
{
if ( auditLogs.size() <= rowCount )
@@ -270,6 +290,27 @@
next = StringUtils.replace( next, " ", "%20" );
}
+ private List<String> getManageableRepositories()
+ {
+ try
+ {
+ return userRepositories.getManagableRepositoryIds( 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();
+ }
+
private List<String> getObservableRepositories()
{
try