Search in sources :

Example 1 with ArchivaProject

use of org.apache.archiva.repository.content.base.ArchivaProject 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;
}
Also used : ArchivaProject(org.apache.archiva.repository.content.base.ArchivaProject) ArchivaArtifact(org.apache.archiva.repository.content.base.ArchivaArtifact) ArchivaNamespace(org.apache.archiva.repository.content.base.ArchivaNamespace) ArchivaVersion(org.apache.archiva.repository.content.base.ArchivaVersion) StorageAsset(org.apache.archiva.repository.storage.StorageAsset)

Example 2 with ArchivaProject

use of org.apache.archiva.repository.content.base.ArchivaProject 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;
}
Also used : ArchivaProject(org.apache.archiva.repository.content.base.ArchivaProject) ArchivaArtifact(org.apache.archiva.repository.content.base.ArchivaArtifact) ArchivaNamespace(org.apache.archiva.repository.content.base.ArchivaNamespace) ArchivaVersion(org.apache.archiva.repository.content.base.ArchivaVersion) StorageAsset(org.apache.archiva.repository.storage.StorageAsset)

Aggregations

ArchivaArtifact (org.apache.archiva.repository.content.base.ArchivaArtifact)2 ArchivaNamespace (org.apache.archiva.repository.content.base.ArchivaNamespace)2 ArchivaProject (org.apache.archiva.repository.content.base.ArchivaProject)2 ArchivaVersion (org.apache.archiva.repository.content.base.ArchivaVersion)2 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)2