]> source.dussan.org Git - archiva.git/commitdiff
Trying to remove compiler warning
authorMartin Stockhammer <martin_s@apache.org>
Sun, 1 Apr 2018 22:22:19 +0000 (00:22 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 1 Apr 2018 22:22:19 +0000 (00:22 +0200)
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java

index f30bf6a4fba7affa43f1a264b2c95aa077e61912..e36b394d7dc3a68c0a11b08f990fbb7919fc5590 100644 (file)
@@ -166,7 +166,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
 
             if ( needsMetadataUpdate )
             {
-                updateMetadata( path );
+                updateMetadata( artifactRef );
             }
         }
         catch ( LayoutException e )
@@ -183,17 +183,63 @@ public class CleanupReleasedSnapshotsRepositoryPurge
         }
     }
 
-    private void updateMetadata( String path )
+
+    /*
+     * TODO: Uses a deprecated API, but if we use the API with location string, it does not work as expected
+     * -> not sure what needs to be changed here.
+     */
+    @SuppressWarnings( "deprecation" )
+    private void updateMetadata( ArtifactReference artifact )
     {
+        VersionedReference versionRef = new VersionedReference( );
+        versionRef.setGroupId( artifact.getGroupId( ) );
+        versionRef.setArtifactId( artifact.getArtifactId( ) );
+        versionRef.setVersion( artifact.getVersion( ) );
+
+        ProjectReference projectRef = new ProjectReference( );
+        projectRef.setGroupId( artifact.getGroupId( ) );
+        projectRef.setArtifactId( artifact.getArtifactId( ) );
 
         try
         {
-            metadataTools.updateMetadata( repository, path );
+            metadataTools.updateMetadata( repository, versionRef );
+        }
+        catch ( ContentNotFoundException e )
+        {
+            // Ignore. (Just means we have no snapshot versions left to reference).
         }
         catch ( RepositoryMetadataException e )
         {
             // Ignore.
         }
+        catch ( IOException e )
+        {
+            // Ignore.
+        }
+        catch ( LayoutException e )
+        {
+            // Ignore.
+        }
 
+        try
+        {
+            metadataTools.updateMetadata( repository, projectRef );
+        }
+        catch ( ContentNotFoundException e )
+        {
+            // Ignore. (Just means we have no snapshot versions left to reference).
+        }
+        catch ( RepositoryMetadataException e )
+        {
+            // Ignore.
+        }
+        catch ( IOException e )
+        {
+            // Ignore.
+        }
+        catch ( LayoutException e )
+        {
+            // Ignore.
+        }
     }
 }
index 2ee46ed5fbfc9234d9cd8a4e87f297c386c252a3..01f9a29198c0e4850427f3a0f8e86ba18ccf84a9 100644 (file)
@@ -171,6 +171,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
 
         XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/release", metadataXml );
         XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
+        System.out.println(metadataXml);
         XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
                                      "//metadata/versioning/versions/version", metadataXml );
         XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
index 4444e7cce140ba08afb041418b53aad8528c0896..8312e2b61f8eb959f1f03592f1d92f562d604f00 100644 (file)
@@ -285,6 +285,8 @@ public class MetadataTools
         return reference;
     }
 
+
+
     public String toPath( ProjectReference reference )
     {
         StringBuilder path = new StringBuilder();