use of org.apache.archiva.repository.content.base.ArchivaNamespace in project archiva by apache.
the class ManagedRepositoryContentMock method getArtifact.
@Override
public Artifact getArtifact(ItemSelector selector) throws ContentAccessException {
StringBuilder path = new StringBuilder(selector.getNamespace().replace(".", "/"));
path.append("/").append(selector.getProjectId()).append("/").append(selector.getVersion());
path.append("/").append(selector.getArtifactId()).append("-").append(selector.getArtifactVersion()).append(".").append(selector.getType());
StorageAsset asset = fsStorage.getAsset(path.toString());
ArchivaNamespace ns = ArchivaNamespace.withRepository(repository.getContent()).withAsset(asset.getParent().getParent().getParent()).withNamespace(selector.getNamespace()).build();
ArchivaProject project = ArchivaProject.withRepository(repository.getContent()).withAsset(asset.getParent().getParent()).withNamespace(ns).withId(selector.getProjectId()).build();
ArchivaVersion version = ArchivaVersion.withRepository(repository.getContent()).withAsset(asset.getParent()).withProject(project).withVersion(selector.getVersion()).build();
ArchivaArtifact artifact = ArchivaArtifact.withAsset(asset).withVersion(version).withId(selector.getArtifactId()).withArtifactVersion(selector.getArtifactVersion()).withType(selector.getType()).build();
return artifact;
}
use of org.apache.archiva.repository.content.base.ArchivaNamespace in project archiva by apache.
the class ManagedRepositoryContentMock method getArtifact.
@Override
public Artifact getArtifact(String path) throws LayoutException, ContentAccessException {
StorageAsset asset = fsStorage.getAsset(path.toString());
String artifactId = asset.getName();
StorageAsset namespacePath = asset.getParent().getParent().getParent();
String namespaceId = namespacePath.getPath().replace("/", ".");
StorageAsset projectPath = asset.getParent().getParent();
String projectId = projectPath.getName();
StorageAsset versionPath = asset.getParent();
String versionId = versionPath.getName();
ArchivaNamespace ns = ArchivaNamespace.withRepository(repository.getContent()).withAsset(namespacePath).withNamespace(namespaceId).build();
ArchivaProject project = ArchivaProject.withRepository(repository.getContent()).withAsset(projectPath).withNamespace(ns).withId(projectId).build();
ArchivaVersion version = ArchivaVersion.withRepository(repository.getContent()).withAsset(versionPath).withProject(project).withVersion(versionId).build();
ArchivaArtifact artifact = ArchivaArtifact.withAsset(asset).withVersion(version).withId(projectId).withArtifactVersion(versionId).build();
return artifact;
}
Aggregations