]> source.dussan.org Git - archiva.git/commitdiff
Switching the checksum module to java.nio
authorMartin Stockhammer <martin_s@apache.org>
Sat, 2 Sep 2017 20:05:16 +0000 (22:05 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Sat, 2 Sep 2017 20:05:16 +0000 (22:05 +0200)
32 files changed:
archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java
archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java
archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java
archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java
archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtil.java [deleted file]
archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java
archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java
archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/archiva/policies/ChecksumPolicy.java
archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ChecksumPolicyTest.java
archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java
archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/CopyFileEventTest.java
archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/CreateFileEventTest.java
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411Test.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java
archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java

index 39a11c5380d5d321ebfb27a39dc02ae266461252..6459a1c9704e82236443d0a5f6585f018274c94b 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.archiva.checksum;
  * under the License.
  */
 
-import org.apache.commons.io.FileUtils;
+import org.apache.archiva.common.utils.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
 import java.util.List;
@@ -49,18 +50,21 @@ import java.util.regex.Pattern;
  */
 public class ChecksummedFile
 {
+
+    private static Charset FILE_ENCODING = Charset.forName( "UTF-8" );
+
     private final Logger log = LoggerFactory.getLogger( ChecksummedFile.class );
 
     private static final Pattern METADATA_PATTERN = Pattern.compile( "maven-metadata-\\S*.xml" );
 
-    private final File referenceFile;
+    private final Path referenceFile;
 
     /**
      * Construct a ChecksummedFile object.
      *
      * @param referenceFile
      */
-    public ChecksummedFile( final File referenceFile )
+    public ChecksummedFile( final Path referenceFile )
     {
         this.referenceFile = referenceFile;
     }
@@ -76,7 +80,7 @@ public class ChecksummedFile
         throws IOException
     {
 
-        try (InputStream fis = Files.newInputStream( referenceFile.toPath() ))
+        try (InputStream fis = Files.newInputStream( referenceFile ))
         {
             Checksum checksum = new Checksum( checksumAlgorithm );
             checksum.update( fis );
@@ -91,14 +95,14 @@ public class ChecksummedFile
      * @return the checksum File that was created.
      * @throws IOException if there was a problem either reading the referenceFile, or writing the checksum file.
      */
-    public File createChecksum( ChecksumAlgorithm checksumAlgorithm )
+    public Path createChecksum( ChecksumAlgorithm checksumAlgorithm )
         throws IOException
     {
-        File checksumFile = new File( referenceFile.getAbsolutePath() + "." + checksumAlgorithm.getExt() );
-        Files.deleteIfExists( checksumFile.toPath() );
+        Path checksumFile = referenceFile.resolveSibling( referenceFile.getFileName() + "." + checksumAlgorithm.getExt() );
+        Files.deleteIfExists( checksumFile );
         String checksum = calculateChecksum( checksumAlgorithm );
-        Files.write( checksumFile.toPath(), //
-                     ( checksum + "  " + referenceFile.getName() ).getBytes(), //
+        Files.write( checksumFile, //
+                     ( checksum + "  " + referenceFile.getFileName().toString() ).getBytes(), //
                      StandardOpenOption.CREATE_NEW );
         return checksumFile;
     }
@@ -109,9 +113,9 @@ public class ChecksummedFile
      * @param checksumAlgorithm the hash that we are interested in.
      * @return the checksum file to return
      */
-    public File getChecksumFile( ChecksumAlgorithm checksumAlgorithm )
+    public Path getChecksumFile( ChecksumAlgorithm checksumAlgorithm )
     {
-        return new File( referenceFile.getAbsolutePath() + "." + checksumAlgorithm.getExt() );
+        return referenceFile.resolveSibling( referenceFile.getFileName() + "." + checksumAlgorithm.getExt() );
     }
 
     /**
@@ -142,16 +146,16 @@ public class ChecksummedFile
     public boolean isValidChecksums( ChecksumAlgorithm algorithms[] )
     {
 
-        try (InputStream fis = Files.newInputStream( referenceFile.toPath() ))
+        try (InputStream fis = Files.newInputStream( referenceFile))
         {
             List<Checksum> checksums = new ArrayList<>( algorithms.length );
             // Create checksum object for each algorithm.
             for ( ChecksumAlgorithm checksumAlgorithm : algorithms )
             {
-                File checksumFile = getChecksumFile( checksumAlgorithm );
+                Path checksumFile = getChecksumFile( checksumAlgorithm );
 
                 // Only add algorithm if checksum file exists.
-                if ( checksumFile.exists() )
+                if ( Files.exists(checksumFile) )
                 {
                     checksums.add( new Checksum( checksumAlgorithm ) );
                 }
@@ -183,10 +187,10 @@ public class ChecksummedFile
                 for ( Checksum checksum : checksums )
                 {
                     ChecksumAlgorithm checksumAlgorithm = checksum.getAlgorithm();
-                    File checksumFile = getChecksumFile( checksumAlgorithm );
+                    Path checksumFile = getChecksumFile( checksumAlgorithm );
 
-                    String rawChecksum = FileUtils.readFileToString( checksumFile );
-                    String expectedChecksum = parseChecksum( rawChecksum, checksumAlgorithm, referenceFile.getName() );
+                    String rawChecksum = FileUtils.readFileToString( checksumFile , FILE_ENCODING );
+                    String expectedChecksum = parseChecksum( rawChecksum, checksumAlgorithm, referenceFile.getFileName().toString() );
 
                     if ( !StringUtils.equalsIgnoreCase( expectedChecksum, checksum.getChecksum() ) )
                     {
@@ -231,7 +235,7 @@ public class ChecksummedFile
             return true;
         }
 
-        try (InputStream fis = Files.newInputStream( referenceFile.toPath() ))
+        try (InputStream fis = Files.newInputStream( referenceFile ))
         {
             // Parse file once, for all checksums.
             Checksum.update( checksums, fis );
@@ -250,23 +254,23 @@ public class ChecksummedFile
             ChecksumAlgorithm checksumAlgorithm = checksum.getAlgorithm();
             try
             {
-                File checksumFile = getChecksumFile( checksumAlgorithm );
+                Path checksumFile = getChecksumFile( checksumAlgorithm );
                 String actualChecksum = checksum.getChecksum();
 
-                if ( checksumFile.exists() )
+                if ( Files.exists(checksumFile) )
                 {
-                    String rawChecksum = FileUtils.readFileToString( checksumFile );
-                    String expectedChecksum = parseChecksum( rawChecksum, checksumAlgorithm, referenceFile.getName() );
+                    String rawChecksum = FileUtils.readFileToString( checksumFile, FILE_ENCODING);
+                    String expectedChecksum = parseChecksum( rawChecksum, checksumAlgorithm, referenceFile.getFileName().toString() );
 
                     if ( !StringUtils.equalsIgnoreCase( expectedChecksum, actualChecksum ) )
                     {
                         // create checksum (again)
-                        FileUtils.writeStringToFile( checksumFile, actualChecksum + "  " + referenceFile.getName() );
+                        FileUtils.writeStringToFile( checksumFile, FILE_ENCODING, actualChecksum + "  " + referenceFile.getFileName().toString());
                     }
                 }
                 else
                 {
-                    FileUtils.writeStringToFile( checksumFile, actualChecksum + "  " + referenceFile.getName() );
+                    FileUtils.writeStringToFile( checksumFile, FILE_ENCODING, actualChecksum + "  " + referenceFile.getFileName().toString() );
                 }
             }
             catch ( IOException e )
index 93b9cbeb1e126b2abe91aef16229ec765a30c301..fafa10319267eb7038ede96fb331b7eec87326b9 100644 (file)
@@ -20,11 +20,14 @@ package org.apache.archiva.checksum;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.common.utils.FileUtils;
 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
 import org.junit.runner.RunWith;
 
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 /**
  * AbstractChecksumTestCase
@@ -35,26 +38,30 @@ import java.io.File;
 public abstract class AbstractChecksumTestCase
     extends TestCase
 {
-    public File getTestOutputDir()
+    public Path getTestOutputDir()
     {
-        File dir = new File( FileUtil.getBasedir(), "target/test-output/" + getName() );
-        if ( dir.exists() == false )
+        Path dir = Paths.get( FileUtils.getBasedir(), "target/test-output/" + getName() );
+        if ( !Files.exists(dir))
         {
-            if ( dir.mkdirs() == false )
+            try
             {
-                fail( "Unable to create test output directory: " + dir.getAbsolutePath() );
+                Files.createDirectories( dir );
+            }
+            catch ( IOException e )
+            {
+                fail( "Unable to create test output directory: " + dir.toAbsolutePath() );
             }
         }
         return dir;
     }
 
-    public File getTestResource( String filename )
+    public Path getTestResource( String filename )
     {
-        File dir = new File( FileUtil.getBasedir(), "src/test/resources" );
-        File file = new File( dir, filename );
-        if ( file.exists() == false )
+        Path dir = Paths.get( FileUtils.getBasedir(), "src/test/resources" );
+        Path file = dir.resolve(filename );
+        if ( !Files.exists(file))
         {
-            fail( "Test Resource does not exist: " + file.getAbsolutePath() );
+            fail( "Test Resource does not exist: " + file.toAbsolutePath() );
         }
         return file;
     }
index 39719ccbd40eec40e615b090bed037935a7e4d65..56fc5ad492a1315744c6fed32415523f3bd365cf 100644 (file)
@@ -19,14 +19,13 @@ package org.apache.archiva.checksum;
  * under the License.
  */
 
-import java.io.File;
-import java.nio.file.Paths;
-
 import junit.framework.TestCase;
 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.nio.file.Paths;
+
 /**
  * ChecksumAlgorithmTest
  *
index 11df7b9b5602de088ad0a7a9700705e5e99f03ac..bc7f0b274ddeaf0474ab82475f4b6a39da5a3d04 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.archiva.checksum;
  * under the License.
  */
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 import junit.framework.TestCase;
 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * ChecksumTest
  *
index 69d34f28daaa4705b18aba53237e9c7eca62c618..04c63912c4d0c9cd62e341c8543b2e9c4f892caa 100644 (file)
@@ -19,14 +19,18 @@ package org.apache.archiva.checksum;
  * under the License.
  */
 
-import org.apache.commons.io.FileUtils;
+import org.apache.archiva.common.utils.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 
 /**
  * ChecksummedFileTest
@@ -46,6 +50,8 @@ public class ChecksummedFileTest
 
     private static final String REMOTE_METADATA_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
 
+    private static final Charset FILE_ENCODING = Charset.forName( "UTF-8" );
+
 
     @Before
     public void cleanTestDir()
@@ -60,36 +66,36 @@ public class ChecksummedFileTest
         }
     }
 
-    private File createTestableJar( String filename )
+    private Path createTestableJar( String filename )
         throws IOException
     {
-        File srcFile = getTestResource( filename );
-        File destFile = new File( getTestOutputDir(), srcFile.getName() );
-        FileUtils.copyFile( srcFile, destFile );
+        Path srcFile = getTestResource( filename );
+        Path destFile = getTestOutputDir( ).resolve( srcFile.getFileName());
+        Files.copy( srcFile, destFile, StandardCopyOption.REPLACE_EXISTING );
         return destFile;
     }
 
-    private File createTestableJar( String filename, boolean copySha1, boolean copyMd5 )
+    private Path createTestableJar( String filename, boolean copySha1, boolean copyMd5 )
         throws IOException
     {
-        File srcFile = getTestResource( filename );
-        File jarFile = new File( getTestOutputDir(), srcFile.getName() );
-        FileUtils.copyFile( srcFile, jarFile );
+        Path srcFile = getTestResource( filename );
+        Path jarFile = getTestOutputDir().resolve(srcFile.getFileName() );
+        Files.copy( srcFile, jarFile, StandardCopyOption.REPLACE_EXISTING );
 
         if ( copySha1 )
         {
-            File srcSha1 = new File( srcFile.getAbsolutePath() + ".sha1" );
-            File sha1File = new File( jarFile.getAbsolutePath() + ".sha1" );
+            Path srcSha1 = srcFile.resolveSibling( srcFile.getFileName() + ".sha1" );
+            Path sha1File = jarFile.resolveSibling( jarFile.getFileName() + ".sha1" );
 
-            FileUtils.copyFile( srcSha1, sha1File );
+            Files.copy( srcSha1, sha1File, StandardCopyOption.REPLACE_EXISTING );
         }
 
         if ( copyMd5 )
         {
-            File srcMd5 = new File( srcFile.getAbsolutePath() + ".md5" );
-            File md5File = new File( jarFile.getAbsolutePath() + ".md5" );
+            Path srcMd5 = srcFile.resolveSibling( srcFile.getFileName() + ".md5" );
+            Path md5File = jarFile.resolveSibling( jarFile.getFileName() + ".md5" );
 
-            FileUtils.copyFile( srcMd5, md5File );
+            Files.copy( srcMd5, md5File, StandardCopyOption.REPLACE_EXISTING );
         }
 
         return jarFile;
@@ -99,7 +105,7 @@ public class ChecksummedFileTest
     public void testCalculateChecksumMd5()
         throws IOException
     {
-        File testfile = getTestResource( "examples/redback-authz-open.jar" );
+        Path testfile = getTestResource( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
         String expectedChecksum = "f42047fe2e177ac04d0df7aa44d408be";
         String actualChecksum = checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 );
@@ -110,7 +116,7 @@ public class ChecksummedFileTest
     public void testCalculateChecksumSha1()
         throws IOException
     {
-        File testfile = getTestResource( "examples/redback-authz-open.jar" );
+        Path testfile = getTestResource( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
         String expectedChecksum = "2bb14b388973351b0a4dfe11d171965f59cc61a1";
         String actualChecksum = checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 );
@@ -121,12 +127,12 @@ public class ChecksummedFileTest
     public void testCreateChecksum()
         throws IOException
     {
-        File testableJar = createTestableJar( "examples/redback-authz-open.jar" );
+        Path testableJar = createTestableJar( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testableJar );
         checksummedFile.createChecksum( ChecksumAlgorithm.SHA1 );
-        File hashFile = checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 );
-        assertTrue( "ChecksumAlgorithm file should exist.", hashFile.exists() );
-        String hashContents = FileUtils.readFileToString( hashFile );
+        Path hashFile = checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 );
+        assertTrue( "ChecksumAlgorithm file should exist.", Files.exists(hashFile) );
+        String hashContents = org.apache.commons.io.FileUtils.readFileToString( hashFile.toFile() );
         hashContents = StringUtils.trim( hashContents );
         assertEquals( "2bb14b388973351b0a4dfe11d171965f59cc61a1  redback-authz-open.jar", hashContents );
     }
@@ -135,11 +141,11 @@ public class ChecksummedFileTest
     public void testFixChecksum()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar" );
-        File sha1File = new File( jarFile.getAbsolutePath() + ".sha1" );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar" );
+        Path sha1File = jarFile.resolveSibling( jarFile.getFileName()+ ".sha1" );
 
         // A typical scenario seen in the wild.
-        FileUtils.writeStringToFile( sha1File, "sha1sum: redback-authz-open.jar: No such file or directory" );
+        org.apache.commons.io.FileUtils.writeStringToFile( sha1File.toFile(), "sha1sum: redback-authz-open.jar: No such file or directory" );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertFalse( "ChecksummedFile.isValid(SHA1) == false",
@@ -155,15 +161,15 @@ public class ChecksummedFileTest
     @Test
     public void testGetChecksumFile()
     {
-        ChecksummedFile checksummedFile = new ChecksummedFile( new File( "test.jar" ) );
-        assertEquals( "test.jar.sha1", checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 ).getName() );
+        ChecksummedFile checksummedFile = new ChecksummedFile( Paths.get( "test.jar" ) );
+        assertEquals( "test.jar.sha1", checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 ).getFileName().toString() );
     }
 
     @Test
     public void testIsValidChecksum()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar", true, false );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar", true, false );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertTrue( "ChecksummedFile.isValid(SHA1)", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) );
@@ -173,11 +179,11 @@ public class ChecksummedFileTest
     public void testIsValidChecksumInvalidSha1Format()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar" );
-        File sha1File = new File( jarFile.getAbsolutePath() + ".sha1" );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar" );
+        Path sha1File = jarFile.resolveSibling( jarFile.getFileName() + ".sha1" );
 
         // A typical scenario seen in the wild.
-        FileUtils.writeStringToFile( sha1File, "sha1sum: redback-authz-open.jar: No such file or directory" );
+        FileUtils.writeStringToFile( sha1File, FILE_ENCODING, "sha1sum: redback-authz-open.jar: No such file or directory" );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertFalse( "ChecksummedFile.isValid(SHA1)", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) );
@@ -188,7 +194,7 @@ public class ChecksummedFileTest
     public void testIsValidChecksumNoChecksumFiles()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar", false, false );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar", false, false );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertFalse( "ChecksummedFile.isValid(SHA1,MD5)", checksummedFile.isValidChecksums(
@@ -200,7 +206,7 @@ public class ChecksummedFileTest
     public void testIsValidChecksumSha1AndMd5()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar", true, true );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar", true, true );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertTrue( "ChecksummedFile.isValid(SHA1,MD5)", checksummedFile.isValidChecksums(
@@ -211,7 +217,7 @@ public class ChecksummedFileTest
     public void testIsValidChecksumSha1NoMd5()
         throws IOException
     {
-        File jarFile = createTestableJar( "examples/redback-authz-open.jar", true, false );
+        Path jarFile = createTestableJar( "examples/redback-authz-open.jar", true, false );
 
         ChecksummedFile checksummedFile = new ChecksummedFile( jarFile );
         assertTrue( "ChecksummedFile.isValid(SHA1)", checksummedFile.isValidChecksums(
@@ -226,7 +232,7 @@ public class ChecksummedFileTest
         String expected = SERVLETAPI_SHA1
             + "  /home/projects/maven/repository-staging/to-ibiblio/maven2/servletapi/servletapi/2.4/servletapi-2.4.pom";
 
-        File testfile = getTestResource( "examples/redback-authz-open.jar" );
+        Path testfile = getTestResource( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
         String s = checksummedFile.parseChecksum( expected, ChecksumAlgorithm.SHA1,
                                                   "servletapi/servletapi/2.4/servletapi-2.4.pom" );
@@ -239,7 +245,7 @@ public class ChecksummedFileTest
         throws IOException
     {
         String expected = SERVLETAPI_SHA1 + "  -";
-        File testfile = getTestResource( "examples/redback-authz-open.jar" );
+        Path testfile = getTestResource( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
         String s = checksummedFile.parseChecksum( expected, ChecksumAlgorithm.SHA1,
                                                   "servletapi/servletapi/2.4/servletapi-2.4.pom" );
@@ -251,7 +257,7 @@ public class ChecksummedFileTest
         throws IOException
     {
         String expected = "SHA1(-)=" + SERVLETAPI_SHA1;
-        File testfile = getTestResource( "examples/redback-authz-open.jar" );
+        Path testfile = getTestResource( "examples/redback-authz-open.jar" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
         String s = checksummedFile.parseChecksum( expected, ChecksumAlgorithm.SHA1,
                                                   "servletapi/servletapi/2.4/servletapi-2.4.pom" );
@@ -263,7 +269,7 @@ public class ChecksummedFileTest
         throws IOException
     {
         String expected = REMOTE_METADATA_SHA1 + "  /home/test/repository/examples/metadata/maven-metadata.xml";
-        File testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
+        Path testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
 
         try
@@ -283,7 +289,7 @@ public class ChecksummedFileTest
         throws IOException
     {
         String expected = REMOTE_METADATA_MD5 + "  ./examples/metadata/maven-metadata.xml";
-        File testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
+        Path testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
         ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
 
         try
diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtil.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtil.java
deleted file mode 100644 (file)
index d60a3a5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.archiva.common.utils;
-
-/*
- * 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 java.io.File;
-
-public class FileUtil
-{
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
-}
\ No newline at end of file
index 0c8683d985fe061ac741a774ea78af5c3a7dc0a7..71dcb8da1bacbe298f52800b1c2f44979e2af310 100644 (file)
@@ -18,9 +18,15 @@ package org.apache.archiva.common.utils;
  * under the License.
  */
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
 import java.util.Comparator;
 import java.util.Optional;
 
@@ -32,6 +38,7 @@ import java.util.Optional;
  */
 public class FileUtils
 {
+    private static final Logger log = LoggerFactory.getLogger( FileUtils.class );
     /**
      * Deletes the directory recursively and quietly.
      *
@@ -85,4 +92,44 @@ public class FileUtils
             throw new IOException("Error during recursive delete of "+dir.toAbsolutePath());
         }
     }
+
+    public static String readFileToString( Path file, Charset encoding)
+    {
+        try
+        {
+            return new String(Files.readAllBytes( file ), encoding  );
+        }
+        catch ( IOException e )
+        {
+            log.error("Could not read from file {}", file);
+            return "";
+        }
+    }
+
+    public static void writeStringToFile( Path file, Charset encoding, String value )
+    {
+        try
+        {
+            Files.write( file,  value.getBytes( encoding ), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
+        }
+        catch ( IOException e )
+        {
+            log.error("Could not write to file {}", file);
+        }
+    }
+
+    /**
+     * Return the base directory 
+     * @return
+     */
+    public static String getBasedir()
+    {
+        String basedir = System.getProperty( "basedir" );
+        if ( basedir == null )
+        {
+            basedir = Paths.get("").toAbsolutePath().toString();
+        }
+
+        return basedir;
+    }
 }
index 7811bdfc631313ead2fe38c47677bbccef85bd41..c91d2f841a9765d3f72cecc15ff5725d7f9cc93b 100644 (file)
@@ -25,7 +25,7 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
 import javax.inject.Inject;
-import org.apache.archiva.common.utils.FileUtil;
+
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -53,7 +53,7 @@ public class ArchivaConfigurationMRM789Test
 
     public static Path getTestFile( String path )
     {
-        return Paths.get( FileUtil.getBasedir(), path );
+        return Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
     }
 
     protected <T> T lookup( Class<T> clazz, String hint )
@@ -66,18 +66,18 @@ public class ArchivaConfigurationMRM789Test
     public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting()
         throws Exception
     {
-        Path repo = Paths.get( FileUtil.getBasedir(), "target/test-classes/existing_snapshots" );
+        Path repo = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-classes/existing_snapshots" );
         Files.createDirectories(repo);
 
-        repo = Paths.get( FileUtil.getBasedir(), "target/test-classes/existing_internal" );
+        repo = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-classes/existing_internal" );
         Files.createDirectories(repo);
 
         String existingTestDefaultArchivaConfigFile = FileUtils.readFileToString(
             getTestFile( "target/test-classes/org/apache/archiva/configuration/test-default-archiva.xml" ).toFile(), FILE_ENCODING );
         existingTestDefaultArchivaConfigFile =
-            StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir() );
+            StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", org.apache.archiva.common.utils.FileUtils.getBasedir() );
 
-        Path generatedTestDefaultArchivaConfigFile = Paths.get( FileUtil.getBasedir(),
+        Path generatedTestDefaultArchivaConfigFile = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(),
                                                                "target/test-classes/org/apache/archiva/configuration/default-archiva.xml" );
 
         FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile.toFile(), existingTestDefaultArchivaConfigFile,
index 1cc64ccd2fe5415612af155585f374975c0cacc6..ca4312cf6b9631d317ead74dbf0d8d65f7ed4892 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.archiva.configuration;
  * under the License.
  */
 
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.redback.components.registry.RegistryException;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
@@ -63,7 +62,7 @@ public class ArchivaConfigurationTest
 
     public static Path getTestFile( String path )
     {
-        return Paths.get( FileUtil.getBasedir(), path );
+        return Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
     }
 
     protected <T> T lookup( Class<T> clazz, String hint )
index 9984b0b06c033233d166c773f7b3e361ebee76ac..58e93b5ddac6517ce76cb284808dc43a785b38e9 100644 (file)
@@ -157,7 +157,7 @@ public class ArtifactMissingChecksumsConsumer
 
         if ( checksumFile.exists( ) )
         {
-            checksum = new ChecksummedFile( artifactFile );
+            checksum = new ChecksummedFile( artifactFile.toPath() );
             try
             {
                 if ( !checksum.isValidChecksum( checksumAlgorithm ) )
@@ -176,7 +176,7 @@ public class ArtifactMissingChecksumsConsumer
         }
         else if ( !checksumFile.exists( ) )
         {
-            checksum = new ChecksummedFile( artifactFile );
+            checksum = new ChecksummedFile( artifactFile.toPath() );
             try
             {
                 checksum.createChecksum( checksumAlgorithm );
index bf4f85b241094da022fc5d497ae28c5b6648cdc1..824e7678d19e19b3ec59d25c4e10cf3ccab03660 100644 (file)
@@ -105,7 +105,7 @@ public class ArtifactMissingChecksumsConsumerTest
 
         Path md5Path = Paths.get( repoConfig.getLocation(), path + ".md5" );
 
-        ChecksummedFile checksum = new ChecksummedFile( new File( repoConfig.getLocation(), path ) );
+        ChecksummedFile checksum = new ChecksummedFile( Paths.get(repoConfig.getLocation(), path ) );
 
         Assertions.assertThat( sha1Path.toFile() ).exists();
         Assertions.assertThat( md5Path.toFile() ).exists();
index a737e845e36565ae6180e30d30ce8b3c3f2f89db..8d79bd682a37f7056bf2fca85e4be77ed5780449 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.archiva.converter.artifact;
 
 import junit.framework.TestCase;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.artifact.Artifact;
@@ -108,7 +107,7 @@ public class LegacyToDefaultConverterTest
 
     public static File getTestFile( String path )
     {
-        return new File( FileUtil.getBasedir(), path );
+        return new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
     }
 
     private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
@@ -429,7 +428,7 @@ public class LegacyToDefaultConverterTest
         Artifact artifact =
             createArtifact( "org.apache.maven.plugins", "maven-foo-plugin", "1.0", "1.0", "maven-plugin" );
         artifact.setFile(
-            new File( FileUtil.getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) );
+            new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) );
         artifactConverter.convert( artifact, targetRepository );
         // There is a warning but I can't figure out how to look at it. Eyeballing the results it appears
         // the plugin is being coverted correctly.
index e3b96f0430e0aa80894c99dae401f565c4eeeab7..f9e2cf301a263dcd68d1f54a81fc6dba66ce9011 100644 (file)
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
 import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
@@ -99,11 +98,11 @@ public abstract class AbstractMavenRepositorySearch
     {
         super.setUp();
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ).exists() );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ) );
+        assertFalse( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ).exists() );
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
+        assertFalse( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() );
 
         archivaConfigControl = EasyMock.createControl();
 
@@ -137,11 +136,11 @@ public abstract class AbstractMavenRepositorySearch
             nexusIndexer.removeIndexingContext( indexingContext, true );
         }
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_1 ).exists() );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
+        assertFalse( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 ).exists() );
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
-        assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 ).exists() );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
+        assertFalse( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 ).exists() );
 
         super.tearDown();
     }
@@ -150,7 +149,7 @@ public abstract class AbstractMavenRepositorySearch
     {
         ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
         repositoryConfig.setId( repository );
-        repositoryConfig.setLocation( FileUtil.getBasedir() + "/target/repos/" + repository );
+        repositoryConfig.setLocation( org.apache.archiva.common.utils.FileUtils.getBasedir() + "/target/repos/" + repository );
         File f = new File( repositoryConfig.getLocation() );
         if ( !f.exists() )
         {
@@ -176,7 +175,7 @@ public abstract class AbstractMavenRepositorySearch
             nexusIndexer.removeIndexingContext( context, true );
         }
 
-        File indexerDirectory = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer" );
+        File indexerDirectory = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer" );
 
         if ( indexerDirectory.exists() )
         {
@@ -185,7 +184,7 @@ public abstract class AbstractMavenRepositorySearch
 
         assertFalse( indexerDirectory.exists() );
 
-        File lockFile = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
+        File lockFile = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
         if ( lockFile.exists() )
         {
             lockFile.delete();
@@ -193,10 +192,10 @@ public abstract class AbstractMavenRepositorySearch
 
         assertFalse( lockFile.exists() );
 
-        File repo = new File( FileUtil.getBasedir(), "src/test/" + repository );
+        File repo = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + repository );
         assertTrue( repo.exists() );
         File indexDirectory =
-            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
+            new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
         indexDirectory.deleteOnExit();
         FileUtils.deleteDirectory( indexDirectory );
 
index 6d4f6acabb24dbbd50c2245270a704d6e9fa0a68..5968513628e900d8093725b68ca52cad323ec86c 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.archiva.indexer.search;
  * under the License.
  */
 
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.indexer.util.SearchUtil;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.maven.index_shaded.lucene.index.IndexUpgrader;
@@ -49,11 +48,11 @@ public class MavenRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<>();
-        files.add( Paths.get( FileUtil.getBasedir(), "src/test", TEST_REPO_1,
+        files.add( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test", TEST_REPO_1,
                               "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ).toFile() );
-        files.add( Paths.get( FileUtil.getBasedir(), "src/test", TEST_REPO_1,
+        files.add( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test", TEST_REPO_1,
                               "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ).toFile() );
-        files.add( Paths.get( FileUtil.getBasedir(), "src/test", TEST_REPO_1,
+        files.add( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test", TEST_REPO_1,
                               "org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ).toFile() );
 
         createIndex( TEST_REPO_1, files, scan );
@@ -63,19 +62,19 @@ public class MavenRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) );
-        files.add( new File( FileUtil.getBasedir(),
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(),
                              "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(),
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(),
                              "src/test/" + TEST_REPO_1 + "/com/classname-search/1.0/classname-search-1.0.jar" ) );
 
         createIndex( TEST_REPO_1, files, scan );
@@ -86,13 +85,13 @@ public class MavenRepositorySearchTest
     {
         List<File> files = new ArrayList<>();
 
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
 
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom" ) );
 
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar" ) );
 
         createIndex( TEST_REPO_1, files, scan );
@@ -327,9 +326,9 @@ public class MavenRepositorySearchTest
         createSimpleIndex( true );
 
         List<File> files = new ArrayList<>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
         createIndex( TEST_REPO_2, files, false );
 
@@ -458,9 +457,9 @@ public class MavenRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<>();
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_2
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
         createIndex( TEST_REPO_2, files, false );
 
@@ -544,9 +543,9 @@ public class MavenRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<>();
-        files.add( new File( FileUtil.getBasedir(),
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(),
                              "src/test/" + TEST_REPO_1 + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( FileUtil.getBasedir(), "src/test/" + TEST_REPO_1
+        files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
             + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
         createIndex( TEST_REPO_1, files, true );
 
index 00e37a8391c1795acf4da6f12f1d22e7ee55e259..7c219336151620ae132a659a10130f827e0693c4 100644 (file)
@@ -108,7 +108,7 @@ public class ChecksumPolicy
 
         if ( FAIL.equals( policySetting ) )
         {
-            ChecksummedFile checksum = new ChecksummedFile( localFile );
+            ChecksummedFile checksum = new ChecksummedFile( localFile.toPath() );
             if ( checksum.isValidChecksums( algorithms ) )
             {
                 return;
@@ -131,7 +131,7 @@ public class ChecksumPolicy
 
         if ( FIX.equals( policySetting ) )
         {
-            ChecksummedFile checksum = new ChecksummedFile( localFile );
+            ChecksummedFile checksum = new ChecksummedFile( localFile.toPath() );
             if ( checksum.fixChecksums( algorithms ) )
             {
                 log.debug( "Checksum policy set to FIX, checksum files have been updated." );
index 0ecce463a4961971cac2026a31d4ee975669de11..ec1cd216504c5691a59bbe0d33d939265dd3aad9 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.policies;
  */
 
 import org.apache.commons.io.FileUtils;
-import org.apache.archiva.common.utils.FileUtil;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
@@ -365,7 +364,7 @@ public class ChecksumPolicyTest
 
     public static File getTestFile( String path )
     {
-        return new File( FileUtil.getBasedir(), path );
+        return new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
     }
 
 }
index 5869f673080c66adc548e5a351f5d9be0c197f92..5043594df930f86d77daaed06f1c14be82481979 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.archiva.common.filelock.FileLockException;
 import org.apache.archiva.common.filelock.FileLockManager;
 import org.apache.archiva.common.filelock.FileLockTimeoutException;
 import org.apache.archiva.common.filelock.Lock;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ConfigurationNames;
@@ -65,7 +64,6 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.archiva.scheduler.repository.model.RepositoryTask;
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.SystemUtils;
@@ -88,7 +86,6 @@ import javax.inject.Inject;
 import javax.inject.Named;
 import java.io.File;
 import java.io.IOException;
-import java.lang.reflect.Proxy;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
index 01f733767d4d64af97deb80003b0c1dd988f3929..d54c797b02f7d3dfab0dd4b8bcd7dc5b424febb5 100644 (file)
@@ -23,7 +23,6 @@ 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.common.utils.FileUtil;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
@@ -43,7 +42,6 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
index 71258fc082206fa350ffe1d5eb49305a399eee94..d04de274dc8b1ac74ca9dec422fa0dd60514e5f4 100644 (file)
@@ -477,7 +477,7 @@ public class MetadataTools
 
         RepositoryMetadataWriter.write( metadata, metadataFile );
 
-        ChecksummedFile checksum = new ChecksummedFile( metadataFile.toFile() );
+        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
         checksum.fixChecksums( algorithms );
     }
 
@@ -650,7 +650,7 @@ public class MetadataTools
 
         // Save the metadata model to disk.
         RepositoryMetadataWriter.write( metadata, metadataFile );
-        ChecksummedFile checksum = new ChecksummedFile( metadataFile.toFile() );
+        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
         checksum.fixChecksums( algorithms );
     }
 
@@ -890,7 +890,7 @@ public class MetadataTools
 
         // Save the metadata model to disk.
         RepositoryMetadataWriter.write( metadata, metadataFile );
-        ChecksummedFile checksum = new ChecksummedFile( metadataFile.toFile() );
+        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
         checksum.fixChecksums( algorithms );
     }
 
index 360f64df875d47b2d47cea08e7b136267cb394af..6a707ab9ad3acb74c10f5f39fc0923a5ac058fbf 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.transaction;
  */
 
 import org.apache.commons.io.FileUtils;
-import org.apache.archiva.common.utils.FileUtil;
 
 import java.io.File;
 import java.io.IOException;
@@ -33,11 +32,11 @@ import org.junit.Test;
 public class CopyFileEventTest
     extends AbstractFileEventTest
 {
-    private File testDir = new File( FileUtil.getBasedir(), "target/transaction-tests/copy-file" );
+    private File testDir = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/transaction-tests/copy-file" );
 
     private File testDest = new File( testDir, "test-file.txt" );
 
-    private File testSource = new File( FileUtil.getBasedir(), "target/transaction-tests/test-file.txt" );
+    private File testSource = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/transaction-tests/test-file.txt" );
 
     private File testDestChecksum;
 
@@ -163,7 +162,7 @@ public class CopyFileEventTest
     {
         super.tearDown();
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "target/transaction-tests" ) );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/transaction-tests" ) );
     }
 
     @Override
index 42b2f624554906d0b6dc9d741782abf3e83a8439..0f8695220fec2e3bd38b5f6509d26e72f9c57fda 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.archiva.transaction;
 import java.io.File;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.archiva.common.utils.FileUtil;
 import org.junit.After;
 import org.junit.Test;
 
@@ -31,7 +30,7 @@ import org.junit.Test;
 public class CreateFileEventTest
     extends AbstractFileEventTest
 {
-    private File testDir = new File( FileUtil.getBasedir(), "target/transaction-tests/create-file" );
+    private File testDir = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/transaction-tests/create-file" );
 
     @Test
     public void testCreateCommitRollback()
@@ -56,7 +55,7 @@ public class CreateFileEventTest
         assertChecksumRollback( testFile );
 
         assertFalse( "Test file parent directories has been rolledback too", testDir.exists() );
-        assertTrue( "target directory still exists", new File( FileUtil.getBasedir(), "target" ).exists() );
+        assertTrue( "target directory still exists", new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target" ).exists() );
     }
 
     @Test
@@ -122,6 +121,6 @@ public class CreateFileEventTest
     {
         super.tearDown();
 
-        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "target/transaction-tests" ) );
+        FileUtils.deleteDirectory( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/transaction-tests" ) );
     }
 }
index ef0dd86eda9a7d8943f3d2268734d4cad055717f..b7e630e1e8fc2c7993abb761bb0c069e802ec893 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.archiva.scheduler.indexing;
 
 import org.apache.archiva.admin.model.beans.RemoteRepository;
 import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.common.utils.FileUtils;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.maven.index.FlatSearchRequest;
 import org.apache.maven.index.FlatSearchResponse;
@@ -145,7 +145,7 @@ public class DownloadRemoteIndexTaskTest
     {
         RemoteRepository remoteRepository = new RemoteRepository();
         File indexDirectory =
-            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
+            new File( FileUtils.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
         indexDirectory.mkdirs();
         indexDirectory.deleteOnExit();
 
index 629a44d6c1d30a355c4ba2bc26841a76a574c672..1f0fd73cb00da28f7023fe043aee26c213538a39 100644 (file)
@@ -557,7 +557,7 @@ public class DefaultRepositoriesService
 
     private void fixChecksums( File file )
     {
-        ChecksummedFile checksum = new ChecksummedFile( file );
+        ChecksummedFile checksum = new ChecksummedFile( file.toPath() );
         checksum.fixChecksums( algorithms );
     }
 
@@ -1188,7 +1188,7 @@ public class DefaultRepositoriesService
         metadata.setAvailableVersions( availableVersions );
 
         RepositoryMetadataWriter.write( metadata, metadataFile.toPath() );
-        ChecksummedFile checksum = new ChecksummedFile( metadataFile );
+        ChecksummedFile checksum = new ChecksummedFile( metadataFile.toPath() );
         checksum.fixChecksums( algorithms );
     }
 
index bc1b545ab10ecb00bd65120fec85ad2c8b6e7cb5..cce73ba2bfe4df530088e1a39b6bf2db24b73806 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.archiva.rest.services;
 
 import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
 import org.apache.archiva.redback.rest.services.AbstractRestServicesTest;
 import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
@@ -45,7 +44,6 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.junit.After;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -334,7 +332,7 @@ public abstract class AbstractArchivaRestTest
 
     protected ManagedRepository getTestManagedRepository()
     {
-        String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
+        String location = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repo" ).getAbsolutePath();
         return new ManagedRepository( "TEST", "test", location, "default", true, true, false, "2 * * * * ?", null,
                                       false, 2, 3, true, false, "my nice repo", false );
 
index f745c043d73dc9e9db4915e67fbb3c8f4dd460cc..aab1ea9621073300f7af3a883d702316e0ac7cb2 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.rest.services;
  */
 
 import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.BrowseResultEntry;
@@ -542,7 +541,7 @@ public class RepositoriesServiceTest
 
     protected ManagedRepository getTestManagedRepository( String id, String path )
     {
-        String location = new File( FileUtil.getBasedir(), "target/" + path ).getAbsolutePath();
+        String location = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/" + path ).getAbsolutePath();
         return new ManagedRepository( id, id, location, "default", true, true, true, "2 * * * * ?", null, false, 80, 80,
                                       true, false );
     }
index b272489c13cca29dd9537d6154b8dfa6c9e86df3..d3b67064e9f68eead91ca01af813d2b35bb5c5ed 100644 (file)
@@ -551,7 +551,7 @@ public class DefaultFileUploadService
 
     private void fixChecksums( File file )
     {
-        ChecksummedFile checksum = new ChecksummedFile( file );
+        ChecksummedFile checksum = new ChecksummedFile( file.toPath() );
         checksum.fixChecksums( algorithms );
     }
 
index 37c1b91864702f73145acb4433b3278d9d367900..44a77e037b3ee3616390711dcbf0a89a66a5eb21 100644 (file)
@@ -883,7 +883,7 @@ public class Maven2RepositoryStorage
     {
         metadata.setWhenGathered( new Date() );
         metadata.setFileLastModified( file.lastModified() );
-        ChecksummedFile checksummedFile = new ChecksummedFile( file );
+        ChecksummedFile checksummedFile = new ChecksummedFile( file.toPath() );
         try
         {
             metadata.setMd5( checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ) );
index dcc05ea119243c41ebc671bf7e9ecfae15bd0f0f..ed630ad660fb30d9449d27b74763500566806779 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository.storage.maven2;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
@@ -494,15 +493,15 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest
     {
         for ( String path : pathsToBeDeleted )
         {
-            File dir = new File( FileUtil.getBasedir(), path );
+            File dir = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
             FileUtils.deleteDirectory( dir );
 
             assertFalse( dir.exists() );
         }
-        File dest = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
         File parentPom =
-            new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
-        File rootPom = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
+            new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
+        File rootPom = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
 
         FileUtils.deleteDirectory( dest );
         FileUtils.deleteDirectory( parentPom );
@@ -516,8 +515,8 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest
     private File copyTestArtifactWithParent( String srcPath, String destPath )
         throws IOException
     {
-        File src = new File( FileUtil.getBasedir(), srcPath );
-        File dest = new File( FileUtil.getBasedir(), destPath );
+        File src = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), srcPath );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), destPath );
 
         FileUtils.copyDirectory( src, dest );
         assertTrue( dest.exists() );
index 0b2f65071c419afab551b2ffe380e06ebf3e3f93..5242414ba3d8318afa1b5f34484131e8f67eb94e 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository.storage.maven2;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
@@ -398,15 +397,15 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
     {
         for ( String path : pathsToBeDeleted )
         {
-            File dir = new File( FileUtil.getBasedir(), path );
+            File dir = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
             FileUtils.deleteDirectory( dir );
 
             assertFalse( dir.exists() );
         }
-        File dest = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
         File parentPom =
-            new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
-        File rootPom = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
+            new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
+        File rootPom = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
 
         FileUtils.deleteDirectory( dest );
         FileUtils.deleteDirectory( parentPom );
@@ -420,8 +419,8 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
     private File copyTestArtifactWithParent( String srcPath, String destPath )
         throws IOException
     {
-        File src = new File( FileUtil.getBasedir(), srcPath );
-        File dest = new File( FileUtil.getBasedir(), destPath );
+        File src = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), srcPath );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), destPath );
 
         FileUtils.copyDirectory( src, dest );
         assertTrue( dest.exists() );
index 24e9b2609cc744ca028f0e0223814a25aa56d35e..46ef5ac54d096c5773eaec1859e1cc2b1bd0f8bd 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository.storage.maven2;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
@@ -53,7 +52,6 @@ import javax.inject.Named;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
-import java.nio.file.CopyOption;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -773,15 +771,15 @@ public class Maven2RepositoryMetadataResolverTest
     {
         for ( String path : pathsToBeDeleted )
         {
-            File dir = new File( FileUtil.getBasedir(), path );
+            File dir = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
             FileUtils.deleteDirectory( dir );
 
             assertFalse( dir.exists() );
         }
-        File dest = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
         File parentPom =
-            new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
-        File rootPom = new File( FileUtil.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
+            new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
+        File rootPom = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
 
         FileUtils.deleteDirectory( dest );
         FileUtils.deleteDirectory( parentPom );
@@ -795,8 +793,8 @@ public class Maven2RepositoryMetadataResolverTest
     private File copyTestArtifactWithParent( String srcPath, String destPath )
         throws IOException
     {
-        File src = new File( FileUtil.getBasedir(), srcPath );
-        File dest = new File( FileUtil.getBasedir(), destPath );
+        File src = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), srcPath );
+        File dest = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), destPath );
 
         FileUtils.copyDirectory( src, dest );
         assertTrue( dest.exists() );
index 7a81e13c6918c071bea6511c51aa4d38b6b2d6af..54ff2e947663658165db338946066bced7d70c65 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.archiva.repository.content.maven2;
  */
 
 import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.common.utils.FileUtils;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.model.ArtifactReference;
 import org.apache.archiva.repository.ManagedRepositoryContent;
@@ -368,7 +368,7 @@ public class RepositoryRequestTest
     private ManagedRepositoryContent createManagedRepo( String layout )
         throws Exception
     {
-        File repoRoot = new File( FileUtil.getBasedir() + "/target/test-repo" );
+        File repoRoot = new File( FileUtils.getBasedir() + "/target/test-repo" );
         return createManagedRepositoryContent( "test-internal", "Internal Test Repo", repoRoot, layout );
     }
 
index 4983004041b370563e71b60d8a6cd5b27949af1c..5fcb71731856a4a2d80c7b4abc28d06c2ce616ab 100644 (file)
@@ -149,7 +149,7 @@ public class DuplicateArtifactsConsumer
         //  alternatively this could come straight from the storage resolver, which could populate the artifact metadata
         //  in the later parse call with the desired checksum and use that
         String checksumSha1;
-        ChecksummedFile checksummedFile = new ChecksummedFile( artifactFile );
+        ChecksummedFile checksummedFile = new ChecksummedFile( artifactFile.toPath() );
         try
         {
             checksumSha1 = checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 );