use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class MavenRepositoryProvider method createRemoteInstance.
public MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir) {
FilesystemStorage storage;
try {
storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
} catch (IOException e) {
log.error("Could not initialize filesystem for repository {}: '{}'", id, e.getMessage());
throw new RuntimeException(e);
}
MavenRemoteRepository repo = new MavenRemoteRepository(id, name, storage);
registerEventHandler(repo);
return repo;
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class MavenRepositoryProvider method createManagedInstance.
public MavenManagedRepository createManagedInstance(String id, String name, Path baseDir) {
FilesystemStorage storage;
try {
storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
} catch (IOException e) {
log.error("Could not initialize fileystem for repository {}", id);
throw new RuntimeException(e);
}
MavenManagedRepository repo = new MavenManagedRepository(id, name, storage);
registerEventHandler(repo);
return repo;
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class MavenRepositoryProvider method updateRepositoryGroupInstance.
@Override
public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException {
repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), configuration.getName());
repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl());
repositoryGroup.setSchedulingDefinition(configuration.getCronExpression());
if (repositoryGroup.supportsFeature(IndexCreationFeature.class)) {
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature(IndexCreationFeature.class);
indexCreationFeature.setIndexPath(getURIFromString(configuration.getMergedIndexPath()));
Path localPath = Paths.get(configuration.getMergedIndexPath());
Path repoGroupPath = repositoryGroup.getRoot().getFilePath().toAbsolutePath();
if (localPath.isAbsolute() && !localPath.startsWith(repoGroupPath)) {
try {
FilesystemStorage storage = new FilesystemStorage(localPath.getParent(), fileLockManager);
indexCreationFeature.setLocalIndexPath(storage.getAsset(localPath.getFileName().toString()));
} catch (IOException e) {
throw new RepositoryException("Could not initialize storage for index path " + localPath);
}
} else if (localPath.isAbsolute()) {
indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(repoGroupPath.relativize(localPath).toString()));
} else {
indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(localPath.toString()));
}
}
// References to other repositories are set filled by the registry
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage 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 fsStorage = (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();
fsStorage = new FilesystemStorage(indexDirectory.getParent(), new DefaultFileLockManager());
} else {
indexDirectory = repoDir.resolve(indexDirectory);
}
} else {
indexDirectory = repoDir.resolve(".index");
indexPath = ".index";
}
if (!Files.exists(indexDirectory)) {
Files.createDirectories(indexDirectory);
}
return new FilesystemAsset(fsStorage, indexPath, indexDirectory);
}
use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.
the class ArtifactContentEntriesTests method readArtifactContentEntriesRootPathNull.
@Test
public void readArtifactContentEntriesRootPathNull() throws Exception {
FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(new FilesystemAsset(filesystemStorage, file.toString(), file), null, "foo");
log.info("artifactContentEntries: {}", artifactContentEntries);
assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(2).contains(new ArtifactContentEntry("org", false, 0, "foo"), new ArtifactContentEntry("META-INF", false, 0, "foo"));
}
Aggregations