Search in sources :

Example 66 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresentConnectorOffline.

@Test
public void testGetDefaultLayoutNotPresentConnectorOffline() throws Exception {
    String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    // Ensure file isn't present first.
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ONCE, SnapshotsPolicy.ONCE, CachedFailuresPolicy.NO, true);
    // Attempt the proxy fetch.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNull("File should not have been downloaded", downloadedFile);
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 67 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class ManagedDefaultTransferTest method testNotFoundInAnyProxies.

@Test
public void testNotFoundInAnyProxies() throws Exception {
    String path = "org/apache/maven/test/does-not-exist/1.0/does-not-exist-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, false);
    // Attempt the proxy fetch.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNull("File returned was: " + downloadedFile + "; should have got a not found exception", downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 68 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresentPassthrough.

@Test
public void testGetDefaultLayoutNotPresentPassthrough() throws Exception {
    String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar.asc";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    // Ensure file isn't present first.
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ONCE, SnapshotsPolicy.ONCE, CachedFailuresPolicy.NO, false);
    // Attempt the proxy fetch.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), path);
    Path sourceFile = Paths.get(REPOPATH_PROXIED1, path);
    assertNotNull(downloadedFile);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), sourceFile);
    assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".sha1")));
    assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".md5")));
    assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".sha256")));
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.Test)

Example 69 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class MetadataTransferTest method assertFetchVersionedFailed.

/**
 * Transfer the metadata file, not expected to succeed.
 *
 * @param requestedResource the requested resource
 * @throws Exception
 */
private void assertFetchVersionedFailed(String requestedResource) throws Exception {
    Path expectedFile = managedDefaultDir.resolve(requestedResource);
    ContentItem item = managedDefaultRepository.toItem(requestedResource);
    assertNotNull(item);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Version version = layout.adaptItem(Version.class, item);
    assertNotNull(version);
    String metaPath = managedDefaultRepository.toPath(layout.getMetadataItem(version));
    assertNotNull(metaPath);
    StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository.getRepository(), metaPath).getFile();
    assertNull(downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) Version(org.apache.archiva.repository.content.Version) SnapshotVersion(org.apache.archiva.model.SnapshotVersion) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) ContentItem(org.apache.archiva.repository.content.ContentItem)

Example 70 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class MetadataTransferTest method assertFetchProjectOrGroup.

/**
 * Transfer the metadata file.
 *
 * @param requestedResource the requested resource
 * @throws Exception
 */
private void assertFetchProjectOrGroup(String requestedResource) throws Exception {
    Path expectedFile = managedDefaultDir.resolve(requestedResource);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    ContentItem metaItem = managedDefaultRepository.toItem(requestedResource);
    Project project = layout.adaptItem(Project.class, managedDefaultRepository.getParent(metaItem));
    assertNotNull(project);
    String metaPath = managedDefaultRepository.toPath(layout.getMetadataItem(project));
    StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository.getRepository(), metaPath).getFile();
    assertNotNull("Should have downloaded a file.", downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) Project(org.apache.archiva.repository.content.Project) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) ContentItem(org.apache.archiva.repository.content.ContentItem)

Aggregations

StorageAsset (org.apache.archiva.repository.storage.StorageAsset)191 Path (java.nio.file.Path)91 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)61 IOException (java.io.IOException)59 Test (org.junit.Test)59 Artifact (org.apache.archiva.repository.content.Artifact)54 ManagedRepository (org.apache.archiva.repository.ManagedRepository)27 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)22 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)22 List (java.util.List)20 Inject (javax.inject.Inject)20 RepositoryMetadataException (org.apache.archiva.repository.metadata.RepositoryMetadataException)20 Collectors (java.util.stream.Collectors)19 RemoteRepository (org.apache.archiva.repository.RemoteRepository)19 IndexingContext (org.apache.maven.index.context.IndexingContext)19 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)18 StringUtils (org.apache.commons.lang3.StringUtils)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Map (java.util.Map)17