]> source.dussan.org Git - archiva.git/commitdiff
revert r910400, look for a simpler solution and unit test
authorBrett Porter <brett@apache.org>
Tue, 16 Feb 2010 06:17:00 +0000 (06:17 +0000)
committerBrett Porter <brett@apache.org>
Tue, 16 Feb 2010 06:17:00 +0000 (06:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@910410 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/audit/AuditEvent.java
archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java

index d2269ee5041ad82ef30a01ab4292c7930472c27a..12189f31bc92315565af4b2c38b4972ef59c7d92 100644 (file)
@@ -126,9 +126,7 @@ public class AuditEvent
     {
         try
         {
-            int index = name.lastIndexOf( '/' );
-            String ts = index > 0 ? name.substring( 0, index ) : name;
-            timestamp = createNameFormat().parse( ts );
+            timestamp = createNameFormat().parse( name );
         }
         catch ( ParseException e )
         {
@@ -213,9 +211,7 @@ public class AuditEvent
 
     public String getName()
     {
-        // we add the resource name to the end to avoid clashes at that timestamp
-        // TODO: this is still not robust enough and the content model should be revised
-        return createNameFormat().format( timestamp ) + "/" + resource.substring( resource.lastIndexOf( '/' ) + 1 );
+        return createNameFormat().format( timestamp );
     }
 
     private static SimpleDateFormat createNameFormat()
index 28c62456a9d9a022d03f344cd5ca9d91e268fcc9..2bb3399a87599dc6a909a201898348b9ed0176db 100644 (file)
@@ -138,16 +138,16 @@ public class AuditManagerTest
         return createTestEvent( TEST_REPO_ID, name );
     }
 
-    private static AuditEvent createTestEvent( String repositoryId, String t )
+    private static AuditEvent createTestEvent( String repositoryId, String name )
         throws ParseException
     {
         AuditEvent event = new AuditEvent();
-        event.setTimestamp( TIMESTAMP_FORMAT.parse( AUDIT_EVENT_BASE + t ) );
+        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 + "/" + t );
+        event.setResource( TEST_RESOURCE_BASE + "/" + name.substring( AUDIT_EVENT_BASE.length() ) );
         return event;
     }
 
@@ -197,11 +197,10 @@ public class AuditManagerTest
         eventNames.put( TEST_REPO_ID_2, new ArrayList<String>() );
         for ( int i = 0; i < numEvents; i++ )
         {
-            String t = MILLIS_FORMAT.format( i );
-            String name = AUDIT_EVENT_BASE + t + "/" + t;
+            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, t ) );
+            events.add( createTestEvent( repositoryId, name ) );
         }
 
         metadataRepositoryControl.expectAndReturn(