]> source.dussan.org Git - archiva.git/commitdiff
Migration repository admin to java.nio
authorMartin Stockhammer <martin.stockhammer@ars.de>
Fri, 8 Sep 2017 09:41:32 +0000 (11:41 +0200)
committerMartin Stockhammer <martin.stockhammer@ars.de>
Fri, 8 Sep 2017 09:41:32 +0000 (11:41 +0200)
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/group/RepositoryGroupAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.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-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockMergedRemoteIndexesScheduler.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/group/RepositoryGroupAdminTest.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java

index 007248f6f113e77d78e179f59ccd82f456f067c6..8cef4f30b6082c8fcc65f1bf4e3fccabc27f78cd 100644 (file)
@@ -22,7 +22,7 @@ import org.apache.archiva.admin.model.AuditInformation;
 import org.apache.archiva.admin.model.RepositoryAdminException;
 import org.apache.archiva.admin.model.beans.RepositoryGroup;
 
-import java.io.File;
+import java.nio.file.Path;
 import java.util.List;
 import java.util.Map;
 
@@ -75,5 +75,5 @@ public interface RepositoryGroupAdmin
     Map<String, List<String>> getRepositoryToGroupMap()
         throws RepositoryAdminException;
 
-    File getMergedIndexDirectory( String repositoryGroupId );
+    Path getMergedIndexDirectory(String repositoryGroupId );
 }
index 024c3521701488d498a2a80e71ba1f96bdb5f768..37fe14a2a9494d933890caf1c668697e6ece8005 100644 (file)
@@ -36,7 +36,10 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -65,16 +68,16 @@ public class DefaultRepositoryGroupAdmin
     @Inject
     private MergedRemoteIndexesScheduler mergedRemoteIndexesScheduler;
 
-    private File groupsDirectory;
+    private Path groupsDirectory;
 
     @PostConstruct
     public void initialize()
     {
         String appServerBase = getRegistry().getString( "appserver.base" );
-        groupsDirectory = new File( appServerBase + File.separatorChar + "groups" );
-        if ( !groupsDirectory.exists() )
+        groupsDirectory = Paths.get( appServerBase, "groups" );
+        if ( !Files.exists(groupsDirectory) )
         {
-            groupsDirectory.mkdirs();
+            Files.exists(groupsDirectory);
         }
 
         try
@@ -82,12 +85,16 @@ public class DefaultRepositoryGroupAdmin
             for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
             {
                 mergedRemoteIndexesScheduler.schedule( repositoryGroup,
-                                                       getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
+                                                       getMergedIndexDirectory( repositoryGroup.getId() ));
                 // create the directory for each group if not exists
-                File groupPath = new File( groupsDirectory, repositoryGroup.getId() );
-                if ( !groupPath.exists() )
+                Path groupPath = groupsDirectory.resolve(repositoryGroup.getId() );
+                if ( !Files.exists(groupPath) )
                 {
-                    groupPath.mkdirs();
+                    try {
+                        Files.createDirectories(groupPath);
+                    } catch (IOException e) {
+                        log.error("Could not create directory {}", groupPath);
+                    }
                 }
             }
         }
@@ -100,9 +107,9 @@ public class DefaultRepositoryGroupAdmin
 
 
     @Override
-    public File getMergedIndexDirectory( String repositoryGroupId )
+    public Path getMergedIndexDirectory( String repositoryGroupId )
     {
-        return new File( groupsDirectory, repositoryGroupId );
+        return groupsDirectory.resolve( repositoryGroupId );
     }
 
     @Override
@@ -156,7 +163,7 @@ public class DefaultRepositoryGroupAdmin
         configuration.addRepositoryGroup( repositoryGroupConfiguration );
         saveConfiguration( configuration );
         triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation );
-        mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
+        mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) );
         return Boolean.TRUE;
     }
 
@@ -212,7 +219,7 @@ public class DefaultRepositoryGroupAdmin
             triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation );
         }
         mergedRemoteIndexesScheduler.unschedule( repositoryGroup );
-        mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
+        mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) );
         return Boolean.TRUE;
     }
 
index dea091287ed332a08b4a7dada446e500d3a905bb..d36546a99f421fef9bd315f520504cec40029307 100644 (file)
@@ -55,15 +55,11 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Named;
-import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
 
 /**
  * FIXME review the staging mechanism to have a per user session one
@@ -392,11 +388,8 @@ public class DefaultManagedRepositoryAdmin
         if ( deleteContent )
         {
             // TODO could be async ? as directory can be huge
-            File dir = new File( repository.getLocation() );
-            if ( !FileUtils.deleteQuietly( dir ) )
-            {
-                throw new RepositoryAdminException( "Cannot delete repository " + dir );
-            }
+            Path dir = Paths.get( repository.getLocation() );
+            org.apache.archiva.common.utils.FileUtils.deleteQuietly( dir );
         }
 
         // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
@@ -530,8 +523,8 @@ public class DefaultManagedRepositoryAdmin
                 }
 
                 // delete directory too as only content is deleted
-                File indexDirectory = indexingContext.getIndexDirectoryFile();
-                FileUtils.deleteDirectory( indexDirectory );
+                Path indexDirectory = indexingContext.getIndexDirectoryFile().toPath();
+                org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
 
                 createIndexContext( managedRepository );
             }
@@ -553,19 +546,19 @@ public class DefaultManagedRepositoryAdmin
         throws RepositoryAdminException, IOException
     {
         // Normalize the path
-        File file = new File( repository.getLocation() );
+        Path file = Paths.get( repository.getLocation() );
         if ( !file.isAbsolute() )
         {
             // add appserver.base/repositories
-            file = new File( getRegistry().getString( "appserver.base" ) + File.separatorChar + "repositories",
+            file = Paths.get( getRegistry().getString( "appserver.base" ),"repositories",
                              repository.getLocation() );
         }
-        repository.setLocation( file.getCanonicalPath() );
-        if ( !file.exists() )
+        repository.setLocation( file.normalize().toString() );
+        if ( !Files.exists(file) )
         {
-            file.mkdirs();
+            Files.createDirectories(file);
         }
-        if ( !file.exists() || !file.isDirectory() )
+        if ( !Files.exists(file) || !Files.isDirectory(file) )
         {
             throw new RepositoryAdminException(
                 "Unable to add repository - no write access, can not create the root directory: " + file );
@@ -589,18 +582,22 @@ public class DefaultManagedRepositoryAdmin
         }
 
         // take care first about repository location as can be relative
-        File repositoryDirectory = new File( repository.getLocation() );
+        Path repositoryDirectory = Paths.get( repository.getLocation() );
 
         if ( !repositoryDirectory.isAbsolute() )
         {
             repositoryDirectory =
-                new File( getRegistry().getString( "appserver.base" ) + File.separatorChar + "repositories",
+                Paths.get( getRegistry().getString( "appserver.base" ), "repositories",
                           repository.getLocation() );
         }
 
-        if ( !repositoryDirectory.exists() )
+        if ( !Files.exists(repositoryDirectory) )
         {
-            repositoryDirectory.mkdirs();
+            try {
+                Files.createDirectories(repositoryDirectory);
+            } catch (IOException e) {
+                log.error("Could not create directory {}", repositoryDirectory);
+            }
         }
 
         try
@@ -609,30 +606,30 @@ public class DefaultManagedRepositoryAdmin
             String indexDir = repository.getIndexDirectory();
             //File managedRepository = new File( repository.getLocation() );
 
-            File indexDirectory = null;
+            Path indexDirectory = null;
             if ( StringUtils.isNotBlank( indexDir ) )
             {
-                indexDirectory = new File( repository.getIndexDirectory() );
+                indexDirectory = Paths.get( repository.getIndexDirectory() );
                 // not absolute so create it in repository directory
                 if ( !indexDirectory.isAbsolute() )
                 {
-                    indexDirectory = new File( repositoryDirectory, repository.getIndexDirectory() );
+                    indexDirectory = repositoryDirectory.resolve(repository.getIndexDirectory() );
                 }
-                repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
+                repository.setIndexDirectory( indexDirectory.toAbsolutePath().toString() );
             }
             else
             {
-                indexDirectory = new File( repositoryDirectory, ".indexer" );
+                indexDirectory = repositoryDirectory.resolve(".indexer" );
                 if ( !repositoryDirectory.isAbsolute() )
                 {
-                    indexDirectory = new File( repositoryDirectory, ".indexer" );
+                    indexDirectory = repositoryDirectory.resolve( ".indexer" );
                 }
-                repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
+                repository.setIndexDirectory( indexDirectory.toAbsolutePath().toString() );
             }
 
-            if ( !indexDirectory.exists() )
+            if ( !Files.exists(indexDirectory) )
             {
-                indexDirectory.mkdirs();
+                Files.createDirectories(indexDirectory);
             }
 
             context = indexer.getIndexingContexts().get( repository.getId() );
@@ -641,10 +638,10 @@ public class DefaultManagedRepositoryAdmin
             {
                 try
                 {
-                    context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory,
-                                                          indexDirectory,
-                                                          repositoryDirectory.toURI().toURL().toExternalForm(),
-                                                          indexDirectory.toURI().toURL().toString(), indexCreators );
+                    context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory.toFile(),
+                                                          indexDirectory.toFile(),
+                                                          repositoryDirectory.toUri().toURL().toExternalForm(),
+                                                          indexDirectory.toUri().toURL().toString(), indexCreators );
 
                     context.setSearchable( repository.isScanned() );
                 }
@@ -654,11 +651,11 @@ public class DefaultManagedRepositoryAdmin
                     // delete it first then recreate it.
                     log.warn( "the index of repository {} is too old we have to delete and recreate it", //
                               repository.getId() );
-                    FileUtils.deleteDirectory( indexDirectory );
-                    context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory,
-                                                          indexDirectory,
-                                                          repositoryDirectory.toURI().toURL().toExternalForm(),
-                                                          indexDirectory.toURI().toURL().toString(), indexCreators );
+                    org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
+                    context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory.toFile(),
+                                                          indexDirectory.toFile(),
+                                                          repositoryDirectory.toUri().toURL().toExternalForm(),
+                                                          indexDirectory.toUri().toURL().toString(), indexCreators );
 
                     context.setSearchable( repository.isScanned() );
                 }
@@ -687,7 +684,7 @@ public class DefaultManagedRepositoryAdmin
 
         if ( StringUtils.isNotBlank( repository.getIndexDir() ) )
         {
-            File indexDir = new File( repository.getIndexDir() );
+            Path indexDir = Paths.get( repository.getIndexDir() );
             // in case of absolute dir do not use the same
             if ( indexDir.isAbsolute() )
             {
index d54c797b02f7d3dfab0dd4b8bcd7dc5b424febb5..12c4d0766a55a4f5cfd80783cf63a36fd5a5a3c8 100644 (file)
@@ -40,8 +40,10 @@ import org.springframework.stereotype.Service;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -274,42 +276,35 @@ public class DefaultRemoteRepositoryAdmin
                 return indexingContext;
             }
             // create remote repository path
-            File repoDir = new File( appServerBase, "data/remotes/" + remoteRepository.getId() );
-            if ( !repoDir.exists() )
+            Path repoDir = Paths.get( appServerBase, "data/remotes/" + remoteRepository.getId() );
+            if ( !Files.exists(repoDir) )
             {
-                repoDir.mkdirs();
+                Files.createDirectories(repoDir);
             }
 
-            File indexDirectory = null;
+            Path indexDirectory = null;
 
             // is there configured indexDirectory ?
             String indexDirectoryPath = remoteRepository.getIndexDirectory();
 
             if ( StringUtils.isNotBlank( indexDirectoryPath ) )
             {
-                if ( new File( indexDirectoryPath ).isAbsolute() )
-                {
-                    indexDirectory = new File( indexDirectoryPath );
-                }
-                else
-                {
-                    indexDirectory = new File( repoDir, indexDirectoryPath );
-                }
+                repoDir.resolve( indexDirectoryPath );
             }
             // if not configured use a default value
             if ( indexDirectory == null )
             {
-                indexDirectory = new File( repoDir, ".index" );
+                indexDirectory = repoDir.resolve(".index" );
             }
-            if ( !indexDirectory.exists() )
+            if ( !Files.exists(indexDirectory) )
             {
-                indexDirectory.mkdirs();
+                Files.createDirectories(indexDirectory);
             }
 
             try
             {
 
-                return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory,
+                return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir.toFile(), indexDirectory.toFile(),
                                                    remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
                                                    indexCreators );
             }
@@ -319,8 +314,8 @@ public class DefaultRemoteRepositoryAdmin
                 // delete it first then recreate it.
                 log.warn( "the index of repository {} is too old we have to delete and recreate it", //
                           remoteRepository.getId() );
-                FileUtils.deleteDirectory( indexDirectory );
-                return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory,
+                org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
+                return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir.toFile(), indexDirectory.toFile(),
                                                    remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
                                                    indexCreators );
 
index bfaa9c6916604bf649fa6989f3c8e98256dcde4d..d3389cf4ac840ff4130bb08d6ff436c89b72795f 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.archiva.redback.role.RoleManager;
 import org.apache.archiva.redback.users.User;
 import org.apache.archiva.redback.users.memory.SimpleUser;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -39,8 +38,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -110,15 +110,15 @@ public abstract class AbstractRepositoryAdminTest
                                       repoLocation + "/.index", false, 1, 2, true, false );
     }
 
-    protected File clearRepoLocation( String path )
+    protected Path clearRepoLocation(String path )
         throws Exception
     {
-        File repoDir = new File( path );
-        if ( repoDir.exists() )
+        Path repoDir = Paths.get( path );
+        if ( Files.exists(repoDir) )
         {
-            FileUtils.deleteDirectory( repoDir );
+            org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoDir );
         }
-        assertFalse( repoDir.exists() );
+        assertFalse( Files.exists(repoDir) );
         return repoDir;
     }
 
index faaaa0cca3f0084ee0d4c35c3b180d2b36785d10..c586f23c6db65e9b5ba51371d9e2e4d83df83d1d 100644 (file)
@@ -27,7 +27,7 @@ import org.apache.archiva.metadata.model.facets.AuditEvent;
 import org.junit.Test;
 
 import javax.inject.Inject;
-import java.io.File;
+import java.nio.file.Paths;
 import java.util.Arrays;
 
 /**
@@ -46,10 +46,10 @@ public class RepositoryGroupAdminTest
         try
         {
             ManagedRepository managedRepositoryOne =
-                getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+                getTestManagedRepository( "test-new-one", Paths.get(APPSERVER_BASE_PATH,"test-new-one" ).toString());
 
             ManagedRepository managedRepositoryTwo =
-                getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+                getTestManagedRepository( "test-new-two", Paths.get(APPSERVER_BASE_PATH, "test-new-two" ).toString());
 
             managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
 
@@ -96,10 +96,10 @@ public class RepositoryGroupAdminTest
         try
         {
             ManagedRepository managedRepositoryOne =
-                getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+                getTestManagedRepository( "test-new-one", Paths.get(APPSERVER_BASE_PATH,"test-new-one" ).toString());
 
             ManagedRepository managedRepositoryTwo =
-                getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+                getTestManagedRepository( "test-new-two", Paths.get(APPSERVER_BASE_PATH, "test-new-two" ).toString());
 
             managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
 
@@ -158,10 +158,10 @@ public class RepositoryGroupAdminTest
         try
         {
             ManagedRepository managedRepositoryOne =
-                getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+                getTestManagedRepository( "test-new-one", Paths.get(APPSERVER_BASE_PATH , "test-new-one" ).toString());
 
             ManagedRepository managedRepositoryTwo =
-                getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+                getTestManagedRepository( "test-new-two", Paths.get(APPSERVER_BASE_PATH ,"test-new-two" ).toString());
 
             managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
 
@@ -211,10 +211,10 @@ public class RepositoryGroupAdminTest
     public void testAddGroupWithInvalidMergedIndexTtl() throws Exception {
         try {
             ManagedRepository managedRepositoryOne =
-                    getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+                    getTestManagedRepository( "test-new-one", Paths.get(APPSERVER_BASE_PATH , "test-new-one" ).toString());
 
             ManagedRepository managedRepositoryTwo =
-                    getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+                    getTestManagedRepository( "test-new-two", Paths.get(APPSERVER_BASE_PATH , "test-new-two" ).toString());
 
             managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
 
@@ -240,10 +240,10 @@ public class RepositoryGroupAdminTest
     public void testAddAndUpdateGroupWithInvalidMergedIndexTtl() throws Exception {
         try {
             ManagedRepository managedRepositoryOne =
-                    getTestManagedRepository( "test-new-one", APPSERVER_BASE_PATH + File.separator + "test-new-one" );
+                    getTestManagedRepository( "test-new-one", Paths.get(APPSERVER_BASE_PATH , "test-new-one" ).toString());
 
             ManagedRepository managedRepositoryTwo =
-                    getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
+                    getTestManagedRepository( "test-new-two", Paths.get(APPSERVER_BASE_PATH , "test-new-two" ).toString());
 
             managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
 
index f2678290eeb165078cb9731f472fc80a79a91cd0..b131abc88bc3e25e1580f544ef7b17ca61b788c2 100644 (file)
@@ -24,7 +24,9 @@ import org.apache.archiva.metadata.model.facets.AuditEvent;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
 import org.junit.Test;
 
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 
 /**
@@ -38,7 +40,7 @@ public class ManagedRepositoryAdminTest
 
     String repoId = "test-new-one";
 
-    String repoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
+    String repoLocation = Paths.get(APPSERVER_BASE_PATH, repoId).toString();
 
     @Test
     public void getAllManagedRepos()
@@ -74,7 +76,7 @@ public class ManagedRepositoryAdminTest
     {
         mockAuditListener.clearEvents();
 
-        File repoDir = clearRepoLocation( repoLocation );
+        Path repoDir = clearRepoLocation( repoLocation );
 
         List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
         assertNotNull( repos );
@@ -105,7 +107,7 @@ public class ManagedRepositoryAdminTest
         managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), false );
 
         // deleteContents false
-        assertTrue( repoDir.exists() );
+        assertTrue( Files.exists(repoDir) );
 
         repos = managedRepositoryAdmin.getManagedRepositories();
         assertNotNull( repos );
@@ -125,7 +127,7 @@ public class ManagedRepositoryAdminTest
         throws Exception
     {
 
-        File repoDir = clearRepoLocation( repoLocation );
+        Path repoDir = clearRepoLocation( repoLocation );
 
         mockAuditListener.clearEvents();
         List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
@@ -164,8 +166,8 @@ public class ManagedRepositoryAdminTest
         repo = managedRepositoryAdmin.getManagedRepository( repoId );
         assertNotNull( repo );
         assertEquals( newName, repo.getName() );
-        assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
-        assertTrue( new File( repoLocation ).exists() );
+        assertEquals( Paths.get(repoLocation).normalize(), Paths.get(repo.getLocation() ).normalize() );
+        assertTrue( Files.exists( Paths.get(repoLocation )));
         assertEquals( description, repo.getDescription() );
         assertTrue( repo.isSkipPackedIndexCreation() );
 
@@ -174,7 +176,7 @@ public class ManagedRepositoryAdminTest
         managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
 
         // check deleteContents false
-        assertTrue( repoDir.exists() );
+        assertTrue( Files.exists(repoDir) );
 
         assertTemplateRoleNotExists( repoId );
 
@@ -190,7 +192,7 @@ public class ManagedRepositoryAdminTest
         throws Exception
     {
 
-        File repoDir = clearRepoLocation( repoLocation );
+        Path repoDir = clearRepoLocation( repoLocation );
 
         mockAuditListener.clearEvents();
         List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
@@ -212,19 +214,19 @@ public class ManagedRepositoryAdminTest
 
         assertTemplateRoleExists( repoId );
 
-        assertTrue( repoDir.exists() );
+        assertTrue( Files.exists(repoDir) );
 
         assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId + STAGE_REPO_ID_END ) );
 
         assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
 
-        assertTrue( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+        assertTrue( Files.exists(Paths.get( repoLocation + STAGE_REPO_ID_END )) );
 
         managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), true );
 
-        assertFalse( repoDir.exists() );
+        assertFalse( Files.exists(repoDir) );
 
-        assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+        assertFalse( Files.exists(Paths.get( repoLocation + STAGE_REPO_ID_END )) );
 
         assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
 
@@ -245,9 +247,9 @@ public class ManagedRepositoryAdminTest
         throws Exception
     {
 
-        String stageRepoLocation = APPSERVER_BASE_PATH + File.separator + repoId;
+        String stageRepoLocation = Paths.get(APPSERVER_BASE_PATH, repoId).toString();
 
-        File repoDir = clearRepoLocation( repoLocation );
+        Path repoDir = clearRepoLocation( repoLocation );
 
         mockAuditListener.clearEvents();
         List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
@@ -261,7 +263,7 @@ public class ManagedRepositoryAdminTest
 
         assertTemplateRoleExists( repoId );
 
-        assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+        assertFalse( Files.exists(Paths.get( repoLocation + STAGE_REPO_ID_END )) );
 
         assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
 
@@ -284,8 +286,8 @@ public class ManagedRepositoryAdminTest
         repo = managedRepositoryAdmin.getManagedRepository( repoId );
         assertNotNull( repo );
         assertEquals( newName, repo.getName() );
-        assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
-        assertTrue( new File( repoLocation ).exists() );
+        assertEquals( Paths.get( repoLocation ).normalize(), Paths.get( repo.getLocation() ).normalize() );
+        assertTrue( Files.exists( Paths.get(repoLocation )) );
         assertEquals( getTestManagedRepository( repoId, repoLocation ).getCronExpression(), repo.getCronExpression() );
         assertEquals( getTestManagedRepository( repoId, repoLocation ).getLayout(), repo.getLayout() );
         assertEquals( getTestManagedRepository( repoId, repoLocation ).getId(), repo.getId() );
@@ -298,18 +300,18 @@ public class ManagedRepositoryAdminTest
 
         assertTemplateRoleExists( repoId );
 
-        assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
+        assertTrue( Files.exists(Paths.get( stageRepoLocation + STAGE_REPO_ID_END )) );
 
         assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
 
         managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
 
         // check deleteContents false
-        assertTrue( repoDir.exists() );
+        assertTrue( Files.exists(repoDir) );
 
         assertTemplateRoleNotExists( repoId );
 
-        assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
+        assertTrue( Files.exists( Paths.get(stageRepoLocation + STAGE_REPO_ID_END )) );
 
         assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
 
@@ -317,8 +319,8 @@ public class ManagedRepositoryAdminTest
 
         mockAuditListener.clearEvents();
 
-        new File( repoLocation + STAGE_REPO_ID_END ).delete();
-        assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
+        Files.deleteIfExists(Paths.get( repoLocation + STAGE_REPO_ID_END ));
+        assertFalse( Files.exists(Paths.get( repoLocation + STAGE_REPO_ID_END )) );
     }
 
     //----------------------------------