use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class IndyPromoteClientModule method promoteByPath.
public PathsPromoteResult promoteByPath(final StoreType srcType, final String srcName, final StoreType targetType, final String targetName, final boolean purgeSource, final String... paths) throws IndyClientException {
final PathsPromoteRequest req = new PathsPromoteRequest(new StoreKey(srcType, srcName), new StoreKey(targetType, targetName), new HashSet<String>(Arrays.asList(paths))).setPurgeSource(purgeSource);
final PathsPromoteResult result = http.postWithResponse(PATHS_PROMOTE_PATH, req, PathsPromoteResult.class, HttpStatus.SC_OK);
return result;
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class ValidationRequest method getSourcePaths.
public synchronized Set<String> getSourcePaths(boolean includeMetadata, boolean includeChecksums) throws PromotionValidationException {
if (requestPaths == null) {
Set<String> paths = null;
if (promoteRequest instanceof PathsPromoteRequest) {
paths = ((PathsPromoteRequest) promoteRequest).getPaths();
}
if (paths == null) {
ArtifactStore store = null;
try {
store = tools.getArtifactStore(promoteRequest.getSource());
} catch (IndyDataException e) {
throw new PromotionValidationException("Failed to retrieve source ArtifactStore: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage());
}
if (store != null) {
try {
paths = new HashSet<>();
listRecursively(store, "/", paths);
} catch (IndyWorkflowException e) {
throw new PromotionValidationException("Failed to list paths in source: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage());
}
}
}
requestPaths = paths;
}
if (!includeMetadata || !includeChecksums) {
Predicate<String> filter = (path) -> (includeMetadata || !path.matches(".+/maven-metadata\\.xml(\\.(md5|sha[0-9]+))?")) && (includeChecksums || !path.matches(".+\\.(md5|sha[0-9]+)"));
return requestPaths.stream().filter(filter).collect(Collectors.toSet());
}
return requestPaths;
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class FoloTrackingAdjustListener method handlePathsPromoteComplete.
private void handlePathsPromoteComplete(PathsPromoteResult promoteResult) {
String error = promoteResult.getError();
if (error != null) {
logger.trace("Error in promoteResult, skip adjust");
return;
}
Set<String> paths = promoteResult.getCompletedPaths();
if (paths.isEmpty()) {
logger.trace("No completedPaths, skip adjust");
return;
}
PathsPromoteRequest req = promoteResult.getRequest();
StoreKey source = req.getSource();
StoreKey target = req.getTarget();
TrackingKey trackingKey = getTrackingKey(source);
if (trackingKey == null) {
logger.trace("No tracking key found to: {}", source);
return;
}
// Get the sealed record, client MUST seal the record before promote
TrackedContent trackedContent = recordManager.get(trackingKey);
if (trackedContent == null) {
logger.trace("No sealed record found, trackingKey: {}", trackingKey);
return;
}
adjustTrackedContent(trackedContent, source, target);
recordManager.replaceTrackingRecord(trackedContent);
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteDryRunAsyncTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(getAsyncRequest(new PathsPromoteRequest(source.getKey(), target.getKey()).setDryRun(true)));
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(PathsPromoteResult.class);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed == null || completed.isEmpty(), equalTo(true));
final Set<String> pending = result.getPendingPaths();
assertThat(pending, notNullValue());
assertThat(pending.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey(), first), equalTo(false));
assertThat(client.content().exists(target.getKey(), second), equalTo(false));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteIgnoreMissingNonDecoratableTest method run.
@Test
public void run() throws Exception {
final PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey(), first, second, nonDecoratablePath));
final Set<String> pending = result.getPendingPaths();
assertThat(pending.isEmpty(), equalTo(true));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
// the missing non-decoratable path should be skipped
final Set<String> skipped = result.getSkippedPaths();
assertThat(skipped, notNullValue());
assertThat(skipped.contains(nonDecoratablePath), equalTo(true));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey(), first), equalTo(true));
assertThat(client.content().exists(target.getKey(), second), equalTo(true));
}
Aggregations