use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class BasicManagedRepositoryValidatorTest method createRepository.
protected EditableManagedRepository createRepository(String id, String name, Path location) throws IOException {
FileLockManager lockManager = new DefaultFileLockManager();
FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
BasicManagedRepository repo = new BasicManagedRepository(id, name, storage);
repo.setLocation(location.toAbsolutePath().toUri());
repo.setContent(new ManagedRepositoryContentMock());
return repo;
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class BasicRemoteRepositoryValidatorTest method createRepository.
protected EditableRemoteRepository createRepository(String id, String name, Path location) throws IOException {
FileLockManager lockManager = new DefaultFileLockManager();
FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
BasicRemoteRepository repo = new BasicRemoteRepository(id, name, storage);
repo.setLocation(location.toAbsolutePath().toUri());
repo.setContent(new RemoteRepositoryContentMock());
return repo;
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class MavenIndexContext method getPath.
@Override
public StorageAsset getPath() {
if (dir == null) {
StorageAsset repositoryDirAsset = repository.getRoot();
Path repositoryDir = repositoryDirAsset.getFilePath().toAbsolutePath();
Path indexDir = delegate.getIndexDirectoryFile().toPath();
if (indexDir.startsWith(repositoryDir)) {
dir = repository.getAsset(repositoryDir.relativize(indexDir).toString());
} else {
try {
FilesystemStorage storage = new FilesystemStorage(indexDir, new DefaultFileLockManager());
dir = storage.getRoot();
} catch (IOException e) {
log.error("Error occured while creating storage for index dir");
}
}
}
return dir;
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class FilesystemAssetTest method list.
@Test
public void list() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Assert.assertEquals(0, asset.list().size());
FilesystemAsset asset2 = new FilesystemAsset(filesystemStorage, "/test1235", assetPathDir);
Assert.assertEquals(1, asset2.list().size());
Path f1 = Files.createTempFile(assetPathDir, "testfile", "dat");
Path f2 = Files.createTempFile(assetPathDir, "testfile", "dat");
Path d1 = Files.createTempDirectory(assetPathDir, "testdir");
Assert.assertEquals(4, asset2.list().size());
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f1.getFileName().toString())));
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f2.getFileName().toString())));
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(d1.getFileName().toString())));
Files.deleteIfExists(f1);
Files.deleteIfExists(f2);
Files.deleteIfExists(d1);
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class FilesystemAssetTest method init.
@Before
public void init() throws IOException {
assetPathDir = Files.createTempDirectory("assetDir");
assetPathFile = Files.createTempFile(assetPathDir, "assetFile", "dat");
filesystemStorage = new FilesystemStorage(assetPathDir, new DefaultFileLockManager());
}
Aggregations