use of org.commonjava.maven.galley.event.EventMetadata 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.event.EventMetadata in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "single-snapshot/single-snapshot.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
final ConcreteResource cr = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final TestDownload download = new TestDownload(ROOT + testResource);
fixture.getTransport().registerDownload(cr, download);
final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(ONE_LOCATION, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
assertThat(result, notNullValue());
assertThat(result.getVersionString(), equalTo("1.0-20140604.101244-1"));
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class ArchetypeCatalogGenerator method generateGroupFileContent.
@Override
public Transfer generateGroupFileContent(final Group group, final List<ArtifactStore> members, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
if (!canProcess(path)) {
return null;
}
final Transfer target = fileManager.getTransfer(group, path);
if (!target.exists()) {
String toMergePath = path;
if (!path.endsWith(ArchetypeCatalogMerger.CATALOG_NAME)) {
toMergePath = normalize(normalize(parentPath(toMergePath)), ArchetypeCatalogMerger.CATALOG_NAME);
}
final List<Transfer> sources = fileManager.retrieveAllRaw(members, toMergePath, new EventMetadata());
final byte[] merged = merger.merge(sources, group, toMergePath);
if (merged != null) {
OutputStream fos = null;
try {
fos = target.openOutputStream(TransferOperation.GENERATE, true, eventMetadata);
fos.write(merged);
} catch (final IOException e) {
throw new IndyWorkflowException("Failed to write merged archetype catalog to: {}.\nError: {}", e, target, e.getMessage());
} finally {
closeQuietly(fos);
}
// helper.writeChecksumsAndMergeInfo( merged, sources, group, toMergePath );
}
}
if (target.exists()) {
return target;
}
return null;
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getRemoteRepository.
private RemoteRepository getRemoteRepository(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
logger.debug("DECORATED (getRemoteRepository: {})", key);
RemoteRepository repo = (RemoteRepository) dataManager.getArtifactStore(key);
if (!catalog.isEnabled()) {
logger.debug("AutoProx decorator disabled; returning: {}", repo);
return repo;
}
logger.debug("AutoProx decorator active");
if (repo == null) {
logger.info("AutoProx: creating repository for: {}", key);
try {
repo = catalog.createRemoteRepository(key);
if (repo != null) {
if (!checkValidity(key)) {
return null;
}
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? repo.getKey() : impliedBy);
dataManager.storeArtifactStore(repo, new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating remote repository for: '" + key + "'"), false, true, eventMetadata);
}
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new remote repository from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
}
return repo;
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getGroup.
private Group getGroup(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
logger.debug("DECORATED (getGroup: {})", key);
Group g = (Group) dataManager.getArtifactStore(key);
if (!catalog.isEnabled()) {
logger.debug("AutoProx decorator disabled; returning: {}", g);
return g;
}
logger.debug("AutoProx decorator active");
if (g == null) {
logger.debug("AutoProx: creating repository for: {}", key);
if (!checkValidity(key)) {
return null;
}
try {
g = catalog.createGroup(key);
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new group from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
if (g != null) {
logger.info("Validating group: {}", g);
for (final StoreKey memberKey : new ArrayList<>(g.getConstituents())) {
final ArtifactStore store = getArtifactStore(memberKey, impliedBy == null ? g.getKey() : impliedBy);
if (store == null) {
g.removeConstituent(memberKey);
}
}
if (g.getConstituents().isEmpty()) {
return null;
}
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? g.getKey() : impliedBy);
dataManager.storeArtifactStore(g, new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating group for: '" + key + "'"), false, true, eventMetadata);
}
}
return g;
}
Aggregations