use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class MetadataUpdaterConsumer method processFile.
@Override
public void processFile(String path) throws ConsumerException {
// Ignore paths like .index etc
if (!path.startsWith(".")) {
try {
BaseRepositoryContentLayout layout = repository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
updateVersionMetadata(artifact, path);
updateProjectMetadata(artifact, path);
} catch (LayoutException e) {
log.info("Not processing path that is not an artifact: {} ({})", path, e.getMessage());
}
}
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class CacheFailuresTransferTest method testGetWhenInBothProxiedButFirstCacheFailure.
@Test
public void testGetWhenInBothProxiedButFirstCacheFailure() throws Exception {
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
Files.deleteIfExists(expectedFile);
assertFalse(Files.exists(expectedFile));
String url = PathUtil.toUrl(REPOPATH_PROXIED1 + "/" + path);
// Intentionally set failure on url in proxied1 (for test)
UrlFailureCache failurlCache = lookupUrlFailureCache();
failurlCache.cacheFailure(url);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false);
saveConnector(ID_DEFAULT_MANAGED, "proxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
// Validate that file actually came from proxied2 (as intended).
Path proxied2File = Paths.get(REPOPATH_PROXIED2, path);
assertNotNull(downloadedFile);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied2File);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class MetadataTransferTest method testGetProjectMetadataProxiedNotLocalOnRemoteConnectoDisabled.
@Test
public void testGetProjectMetadataProxiedNotLocalOnRemoteConnectoDisabled() throws Exception {
// New project metadata that does not exist locally but exists on remote.
String requestedResource = "org/apache/maven/test/get-found-in-proxy/maven-metadata.xml";
setupTestableManagedRepository(requestedResource);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true);
assertResourceNotFound(requestedResource);
assertNoRepoMetadata(ID_PROXIED1, requestedResource);
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();
assertNull("Should not have downloaded a file.", downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class SnapshotTransferTest method testOlderTimestampDrivenSnapshotOnFirstRepo.
@Test
public void testOlderTimestampDrivenSnapshotOnFirstRepo() throws Exception {
String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
setManagedNewerThanRemote(expectedFile, remoteFile);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
// Attempt to download.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
// Should not have downloaded as managed is newer than remote.
assertNotDownloaded(downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class SnapshotTransferTest method testTimestampDrivenSnapshotNotPresentAlready.
@Test
public void testTimestampDrivenSnapshotNotPresentAlready() throws Exception {
String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
Files.deleteIfExists(expectedFile);
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
assertNoTempFiles(expectedFile);
}
Aggregations