use of com.artipie.maven.metadata.ArtifactsMetadata in project maven-adapter by artipie.
the class AstoValidUpload method validateMetadata.
/**
* Validates uploaded and existing metadata by comparing group and artifact ids.
* @param upload Uploaded artifacts location
* @param artifact Artifact location
* @return Completable validation action: true if group and artifact ids are equal,
* false otherwise.
*/
private CompletionStage<Boolean> validateMetadata(final Key upload, final Key artifact) {
final ArtifactsMetadata metadata = new ArtifactsMetadata(this.storage);
final String meta = "maven-metadata.xml";
return this.storage.exists(new Key.From(artifact, meta)).thenCompose(exists -> {
final CompletionStage<Boolean> res;
if (exists) {
res = metadata.groupAndArtifact(new Key.From(upload, PutMetadataSlice.SUB_META)).thenCompose(existing -> metadata.groupAndArtifact(artifact).thenApply(uploaded -> uploaded.equals(existing)));
} else {
res = CompletableFuture.completedStage(true);
}
return res;
}).thenCompose(same -> {
final CompletionStage<Boolean> res;
if (same) {
res = this.validateArtifactChecksums(new Key.From(upload, meta)).to(SingleInterop.get());
} else {
res = CompletableFuture.completedStage(false);
}
return res;
});
}
Aggregations