only those repositories which the user has an Obeserver role for). The first resource found for the requested artifact
would be returned.
- Prior to version 1.4-M2, Virtual repositories can return a Maven index in the path /.indexer path
+ Prior to version 1.4-M2, Virtual repositories can return a Maven index in the path .indexer path
* Configuring Virtual Repositories
return basedir;
}
+
+ /**
+ * This checks, if the given child is a absolute path. If this is the case
+ * the relative path is used.
+ *
+ * @param parent The parent directory
+ * @param child The child
+ * @return The path parent/child
+ */
+ public Path resolveNonAbsolute(Path parent, String child) {
+ Path childPath = Paths.get(child);
+ if (childPath.isAbsolute()) {
+ return parent.resolve(childPath.getNameCount()>0 ? childPath.subpath(0, childPath.getNameCount()) : Paths.get(""));
+ } else {
+ return parent.resolve(child);
+ }
+ }
}
<version>1.2.0+</version>
<type>String</type>
<required>false</required>
- <defaultValue>/.indexer</defaultValue>
+ <defaultValue>.indexer</defaultValue>
<description>The path of the merged index.</description>
</field>
<field>
* under the License.
*/
-import org.apache.commons.io.FileUtils;
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.commons.lang.time.StopWatch;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexCreator;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
-import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
stopWatch.reset();
stopWatch.start();
- File mergedIndexDirectory = indexMergerRequest.getMergedIndexDirectory();
+ Path mergedIndexDirectory = indexMergerRequest.getMergedIndexDirectory();
- String tempRepoId = mergedIndexDirectory.getName();
+ String tempRepoId = mergedIndexDirectory.getFileName().toString();
try
{
- File indexLocation = new File( mergedIndexDirectory, indexMergerRequest.getMergedIndexPath() );
+ Path indexLocation = mergedIndexDirectory.resolve( indexMergerRequest.getMergedIndexPath() );
IndexingContext indexingContext =
- indexer.addIndexingContext( tempRepoId, tempRepoId, mergedIndexDirectory, indexLocation, null, null,
+ indexer.addIndexingContext( tempRepoId, tempRepoId, mergedIndexDirectory.toFile(), indexLocation.toFile(), null, null,
indexCreators );
for ( String repoId : indexMergerRequest.getRepositoriesIds() )
{
IndexPackingRequest request = new IndexPackingRequest( indexingContext, //
indexingContext.acquireIndexSearcher().getIndexReader(), //
- indexLocation );
+ indexLocation.toFile() );
indexPacker.packIndex( request );
}
{
indexer.removeIndexingContext( indexingContext, true );
}
- File directory = temporaryGroupIndex.getDirectory();
- if ( directory != null && directory.exists() )
+ Path directory = temporaryGroupIndex.getDirectory();
+ if ( directory != null && Files.exists(directory) )
{
FileUtils.deleteDirectory( directory );
}
import javax.inject.Inject;
import javax.inject.Named;
-import java.io.File;
+import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
private Map<String, ScheduledFuture> scheduledFutureMap = new ConcurrentHashMap<>();
@Override
- public void schedule( RepositoryGroup repositoryGroup, File directory )
+ public void schedule( RepositoryGroup repositoryGroup, Path directory )
{
if ( StringUtils.isEmpty( repositoryGroup.getCronExpression() ) )
{
* under the License.
*/
-import java.io.File;
+import java.nio.file.Path;
import java.util.Collection;
/**
*/
private String groupId;
- private String mergedIndexPath = "/.indexer";
+ private String mergedIndexPath = ".indexer";
private int mergedIndexTtl;
- private File mergedIndexDirectory;
+ private Path mergedIndexDirectory;
private boolean temporary;
this.mergedIndexTtl = mergedIndexTtl;
}
- public File getMergedIndexDirectory()
+ public Path getMergedIndexDirectory()
{
return mergedIndexDirectory;
}
- public void setMergedIndexDirectory( File mergedIndexDirectory )
+ public void setMergedIndexDirectory( Path mergedIndexDirectory )
{
this.mergedIndexDirectory = mergedIndexDirectory;
}
- public IndexMergerRequest mergedIndexDirectory( File mergedIndexDirectory )
+ public IndexMergerRequest mergedIndexDirectory( Path mergedIndexDirectory )
{
this.mergedIndexDirectory = mergedIndexDirectory;
return this;
* under the License.
*/
-import java.io.File;
import java.io.Serializable;
+import java.nio.file.Path;
import java.util.Date;
/**
{
private long creationTime = new Date().getTime();
- private File directory;
+ private Path directory;
private String indexId;
private int mergedIndexTtl;
- public TemporaryGroupIndex(File directory, String indexId, String groupId, int mergedIndexTtl)
+ public TemporaryGroupIndex(Path directory, String indexId, String groupId, int mergedIndexTtl)
{
this.directory = directory;
this.indexId = indexId;
return this;
}
- public File getDirectory()
+ public Path getDirectory()
{
return directory;
}
- public TemporaryGroupIndex setDirectory( File directory )
+ public TemporaryGroupIndex setDirectory( Path directory )
{
this.directory = directory;
return this;
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.FileUtils;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
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.List;
/**
{
super.setUp();
- 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( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" ) );
+ assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer" )) );
- 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() );
+ FileUtils.deleteDirectory( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
+ assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" )) );
archivaConfigControl = EasyMock.createControl();
nexusIndexer.removeIndexingContext( indexingContext, true );
}
- 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( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 ) );
+ assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 )) );
- 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() );
+ FileUtils.deleteDirectory( Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 ) );
+ assertFalse( Files.exists(Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 )) );
super.tearDown();
}
ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
repositoryConfig.setId( repository );
repositoryConfig.setLocation( org.apache.archiva.common.utils.FileUtils.getBasedir() + "/target/repos/" + repository );
- File f = new File( repositoryConfig.getLocation() );
- if ( !f.exists() )
+ Path f = Paths.get( repositoryConfig.getLocation() );
+ if ( !Files.exists(f) )
{
- f.mkdirs();
+ try
+ {
+ Files.createDirectories( f );
+ }
+ catch ( IOException e )
+ {
+ log.error("Could not create directories for {}", f);
+ }
}
repositoryConfig.setLayout( "default" );
repositoryConfig.setName( repository );
return repositoryConfig;
}
- protected void createIndex( String repository, List<File> filesToBeIndexed, boolean scan )
+ protected void createIndex( String repository, List<Path> filesToBeIndexed, boolean scan )
throws Exception
{
nexusIndexer.removeIndexingContext( context, true );
}
- File indexerDirectory = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer" );
+ Path indexerDirectory = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer" );
- if ( indexerDirectory.exists() )
+ if ( Files.exists(indexerDirectory) )
{
FileUtils.deleteDirectory( indexerDirectory );
}
- assertFalse( indexerDirectory.exists() );
+ assertFalse( Files.exists(indexerDirectory) );
- File lockFile = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
- if ( lockFile.exists() )
+ Path lockFile = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
+ if ( Files.exists(lockFile) )
{
- lockFile.delete();
+ Files.delete(lockFile);
}
- assertFalse( lockFile.exists() );
+ assertFalse( Files.exists(lockFile) );
- File repo = new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + repository );
- assertTrue( repo.exists() );
- File indexDirectory =
- new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
- indexDirectory.deleteOnExit();
+ Path repo = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + repository );
+ assertTrue( Files.exists(repo) );
+ Path indexDirectory =
+ Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
+ indexDirectory.toFile().deleteOnExit();
FileUtils.deleteDirectory( indexDirectory );
- context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory,
- repo.toURI().toURL().toExternalForm(),
- indexDirectory.toURI().toURL().toString(), indexCreators );
+ context = nexusIndexer.addIndexingContext( repository, repository, repo.toFile(), indexDirectory.toFile(),
+ repo.toUri().toURL().toExternalForm(),
+ indexDirectory.toUri().toURL().toString(), indexCreators );
// minimize datas in memory
// context.getIndexWriter().setMaxBufferedDocs( -1 );
// context.getIndexWriter().setRAMBufferSizeMB( 1 );
- for ( File artifactFile : filesToBeIndexed )
+ for ( Path artifactFile : filesToBeIndexed )
{
- assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
- ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
+ assertTrue( "file not exists " + artifactFile, Files.exists(artifactFile) );
+ ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile.toFile() );
- if ( artifactFile.getPath().endsWith( ".pom" ) )
+ if ( artifactFile.toString().endsWith( ".pom" ) )
{
ac.getArtifactInfo().setFileExtension( "pom" );
ac.getArtifactInfo().setPackaging( "pom" );
import org.easymock.EasyMock;
import org.junit.Test;
-import java.io.File;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
throws Exception
{
- createIndex( TEST_REPO_1, Collections.<File>emptyList(), true );
+ createIndex( TEST_REPO_1, Collections.<Path>emptyList(), true );
List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
-import java.io.File;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
private void createSimpleIndex( boolean scan )
throws Exception
{
- List<File> files = new ArrayList<>();
+ List<Path> files = new ArrayList<>();
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() );
+ "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
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() );
+ "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ));
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() );
+ "org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ));
createIndex( TEST_REPO_1, files, scan );
}
private void createIndexContainingMoreArtifacts( boolean scan )
throws Exception
{
- List<File> files = new ArrayList<>();
- files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
+ List<Path> files = new ArrayList<>();
+ 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" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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-webapp/1.0/archiva-webapp-1.0.war" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(),
+ files.add( Paths.get( 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( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
+ files.add( Paths.get( 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( org.apache.archiva.common.utils.FileUtils.getBasedir(),
+ files.add( Paths.get( 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 );
private void createIndexContainingMultipleArtifactsSameVersion( boolean scan )
throws Exception
{
- List<File> files = new ArrayList<>();
+ List<Path> files = new ArrayList<>();
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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.pom" ) );
- files.add( new File( org.apache.archiva.common.utils.FileUtils.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-sources.jar" ) );
createIndex( TEST_REPO_1, files, scan );
{
createSimpleIndex( true );
- List<File> files = new ArrayList<>();
- files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
+ List<Path> files = new ArrayList<>();
+ files.add( Paths.get( 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( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
+ files.add( Paths.get( 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 );
public void testAdvancedSearch()
throws Exception
{
- List<File> files = new ArrayList<>();
- files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
+ List<Path> files = new ArrayList<>();
+ files.add( Paths.get( 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( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_2
+ files.add( Paths.get( 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 );
public void testAdvancedSearchArtifactIdHasNumericChar()
throws Exception
{
- List<File> files = new ArrayList<>();
- files.add( new File( org.apache.archiva.common.utils.FileUtils.getBasedir(),
+ List<Path> files = new ArrayList<>();
+ files.add( Paths.get( 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( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + TEST_REPO_1
+ files.add( Paths.get( 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 );
throws Exception
{
- File repo = new File( "target/repo-release" );
- File indexDirectory = new File( repo, ".index" );
- FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo );
+ Path repo = Paths.get( "target/repo-release" );
+ Path indexDirectory = repo.resolve(".index" );
+ FileUtils.copyDirectoryStructure( Paths.get( "src/test/repo-release" ).toFile(), repo.toFile() );
- IndexUpgrader.main( new String[]{ indexDirectory.getAbsolutePath() } );
+ IndexUpgrader.main( new String[]{ indexDirectory.toAbsolutePath().toString() } );
createIndex( "repo-release", Collections.emptyList(), false );
- nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory,
- repo.toURI().toURL().toExternalForm(),
- indexDirectory.toURI().toURL().toString(), indexCreators );
+ nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo.toFile(), indexDirectory.toFile(),
+ repo.toUri().toURL().toExternalForm(),
+ indexDirectory.toUri().toURL().toString(), indexCreators );
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
limits.setPageSize( 300 );
/**
* The path of the merged index.
*/
- private String mergedIndexPath = "/.indexer";
+ private String mergedIndexPath = ".indexer";
/**
* The TTL (time to live) of the repo group's merged index.
for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
{
mergedRemoteIndexesScheduler.schedule( repositoryGroup,
- getMergedIndexDirectory( repositoryGroup.getId() ) );
+ getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
// create the directory for each group if not exists
File groupPath = new File( groupsDirectory, repositoryGroup.getId() );
if ( !groupPath.exists() )
configuration.addRepositoryGroup( repositoryGroupConfiguration );
saveConfiguration( configuration );
triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation );
- mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) );
+ mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
return Boolean.TRUE;
}
triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation );
}
mergedRemoteIndexesScheduler.unschedule( repositoryGroup );
- mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) );
+ mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ).toPath() );
return Boolean.TRUE;
}
import org.springframework.stereotype.Service;
import java.io.File;
+import java.nio.file.Path;
/**
* @author Olivier Lamy
{
@Override
- public void schedule( RepositoryGroup repositoryGroup, File directory )
+ public void schedule( RepositoryGroup repositoryGroup, Path directory )
{
// no op
}
// verify if default values were saved
assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexTtl() );
- assertEquals("/.indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
+ assertEquals(".indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
repositoryGroupAdmin.deleteRepositoryGroup( "repo-group-one", getFakeAuditInformation() );
// verify if default values were saved
assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexTtl() );
- assertEquals("/.indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
+ assertEquals(".indexer", repositoryGroupAdmin.getRepositoriesGroups().get( 0 ).getMergedIndexPath() );
repositoryGroup = repositoryGroupAdmin.getRepositoryGroup( "repo-group-one" );
assertNotNull( repositoryGroup );
{
try(Stream<Path> substream = Files.list(p))
{
- return substream.anyMatch( f -> Files.isRegularFile( f ) && f.endsWith( ".pom" ));
+ return substream.anyMatch( f -> Files.isRegularFile( f ) && f.toString().endsWith( ".pom" ));
}
catch ( IOException e )
{
import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import java.io.File;
+import java.nio.file.Path;
/**
* @author Olivier Lamy
* remote indexes
* @param repositoryGroup
*/
- void schedule( RepositoryGroup repositoryGroup, File directory );
+ void schedule( RepositoryGroup repositoryGroup, Path directory );
void unschedule( RepositoryGroup repositoryGroup );
TemporaryGroupIndex tmp = temporaryGroupIndexMap.get( repositoryGroupConfiguration.getId() );
- if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists() )
+ if ( tmp != null && tmp.getDirectory() != null && Files.exists(tmp.getDirectory()))
{
if ( System.currentTimeMillis() - tmp.getCreationTime() > (
repositoryGroupConfiguration.getMergedIndexTtl() * 60 * 1000 ) )
{
log.debug( MarkerFactory.getMarker( "group.merged.index" ),
"merged index for group '{}' found in cache", repositoryGroupConfiguration.getId() );
- return tmp.getDirectory();
+ return tmp.getDirectory().toFile();
}
}
new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
repositoryGroupConfiguration.getMergedIndexPath(),
repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory(
- tempRepoFile ).temporary( true );
+ tempRepoFile.toPath() ).temporary( true );
MergedRemoteIndexesTaskRequest taskRequest =
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
File mergedRepoDir = indexingContext.getIndexDirectoryFile();
TemporaryGroupIndex temporaryGroupIndex =
- new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
+ new TemporaryGroupIndex( mergedRepoDir.toPath(), indexingContext.getId(), repositoryGroupConfiguration.getId(),
repositoryGroupConfiguration.getMergedIndexTtl() ) //
.setCreationTime( new Date().getTime() );
temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
for ( TemporaryGroupIndex temporaryGroupIndex : tempFilesPerKey.values() )
{
log.info( "cleanup temporaryGroupIndex {} directory {}", temporaryGroupIndex.getIndexId(),
- temporaryGroupIndex.getDirectory().getAbsolutePath() );
+ temporaryGroupIndex.getDirectory().toAbsolutePath() );
getIndexMerger( httpSessionEvent ).cleanTemporaryGroupIndex( temporaryGroupIndex );
}
}