use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class ArchivaIndexManagerMock method getIndexPath.
private StorageAsset getIndexPath(Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class);
Path repoDir = repo.getRoot().getFilePath();
URI indexDir = icf.getIndexPath();
String indexPath = indexDir.getPath();
Path indexDirectory = null;
FilesystemStorage filesystemStorage = (FilesystemStorage) repo.getRoot().getStorage();
if (!StringUtils.isEmpty(indexDir.toString())) {
indexDirectory = PathUtil.getPathFromUri(indexDir);
// not absolute so create it in repository directory
if (indexDirectory.isAbsolute()) {
indexPath = indexDirectory.getFileName().toString();
filesystemStorage = new FilesystemStorage(indexDirectory, new DefaultFileLockManager());
} else {
indexDirectory = repoDir.resolve(indexDirectory);
}
} else {
indexDirectory = repoDir.resolve(".index");
indexPath = ".index";
}
if (!Files.exists(indexDirectory)) {
Files.createDirectories(indexDirectory);
}
return new FilesystemAsset(filesystemStorage, indexPath, indexDirectory);
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemStorageTest method init.
@Before
public void init() throws IOException {
baseDir = Files.createTempDirectory("FsStorageTest");
DefaultFileLockManager fl = new DefaultFileLockManager();
fsStorage = new FilesystemStorage(baseDir, fl);
Files.createDirectories(baseDir.resolve("dir1"));
Files.createDirectories(baseDir.resolve("dir2"));
file1 = Files.createFile(baseDir.resolve("dir1/testfile1.dat"));
dir1 = Files.createDirectories(baseDir.resolve("dir1/testdir"));
file1Asset = new FilesystemAsset(fsStorage, "/dir1/testfile1.dat", file1);
dir1Asset = new FilesystemAsset(fsStorage, "/dir1/testdir", dir1);
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method getName.
@Test
public void getName() {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/" + assetPathFile.getFileName().toString(), assetPathFile);
Assert.assertEquals(assetPathFile.getFileName().toString(), asset.getName());
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method getSize.
@Test
public void getSize() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Assert.assertEquals(0, asset.getSize());
Files.write(assetPathFile, new String("abcdef").getBytes("ASCII"));
Assert.assertTrue(asset.getSize() >= 6);
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method isContainer.
@Test
public void isContainer() {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1323", assetPathFile);
Assert.assertFalse(asset.isContainer());
FilesystemAsset asset2 = new FilesystemAsset(filesystemStorage, "/test1234", assetPathDir);
Assert.assertTrue(asset2.isContainer());
}
Aggregations