use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class RelatePomStorageListener method onPomStorage.
public void onPomStorage(@Observes final FileStorageEvent event) {
final Logger logger = LoggerFactory.getLogger(getClass());
if (!config.isEnabled()) {
logger.debug("Relate Add-on is not enabled.");
return;
}
logger.debug("FILE STORAGE: {}", event);
final TransferOperation op = event.getType();
if (op != TransferOperation.UPLOAD && op != TransferOperation.DOWNLOAD) {
logger.debug("Not a download/upload transfer operation. No .rel generation.");
return;
}
ThreadContext threadContext = ThreadContext.getContext(false);
if (threadContext != null) {
Object obj = threadContext.get(REL_DIRECT_GENERATING);
if (obj != null) {
logger.debug("Direct .rel generation in progress. Ignore POM storage event. ");
return;
}
}
final Transfer transfer = event.getTransfer();
executor.execute(() -> {
relateGenerationManager.generateRelationshipFile(transfer, op);
});
}
use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.
the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
final String base = "2-snapshots-1-location/";
final String testResource = base + "two-snapshots.xml";
final String testPomResource = base + "two-snapshots-pom.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.102909-1").asPomArtifact()));
fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
System.out.println(result);
assertThat(result, notNullValue());
assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoFilesWithInterleavedVersions.
@Test
public void mergeTwoFilesWithInterleavedVersions() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-skip.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "simple-2.xml");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(3));
assertThat(versioning.getRelease(), equalTo("1.2"));
assertThat(versioning.getLatest(), equalTo("1.2"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
idx++;
assertThat(versions.get(idx), equalTo("1.2"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoSimpleVersionMetadataFiles.
@Test
public void mergeTwoSimpleVersionMetadataFiles() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "simple-2.xml");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
assertThat(versioning.getRelease(), equalTo("1.1"));
assertThat(versioning.getLatest(), equalTo("1.1"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeOneTransferWithProviderError.
@Test
public void mergeOneTransferWithProviderError() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Group g = new Group("test-group", h1.getKey());
List<Transfer> sources = Arrays.asList(t1);
TestMavenMetadataProvider testProvider = new TestMavenMetadataProvider(new IndyWorkflowException("Failed to get provider content"));
byte[] output = new MavenMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
assertThat(versioning.getRelease(), equalTo("1.0"));
assertThat(versioning.getLatest(), equalTo("1.0"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
}
Aggregations