Improve Response message on dependents resolution API when a revision is not found
@@ -152,6 +152,7 @@ public class ResolutionApi {
case Constants.mvnForge: {
var groupId = packageName.split(Constants.mvnCoordinateSeparator)[0];
var artifactId = packageName.split(Constants.mvnCoordinateSeparator)[1];
+ try {
var depSet = this.graphMavenResolver.resolveDependents(groupId,
artifactId, packageVersion, timestamp, transitive);
depSet.stream().map(eu.fasten.core.maven.data.Revision::toJSON).peek(json -> {
@@ -162,10 +163,13 @@ public class ResolutionApi {
artifact.charAt(0), artifact, artifact, group, ver);
json.put("url", url);
}).forEach(jsonArray::put);
+ } catch (RuntimeException e) {
+ return new ResponseEntity<>("Failed to resolve dependents for revision "+packageName+":"+ packageVersion , HttpStatus.NOT_FOUND);
+ }
break;
}
case Constants.pypiForge: {
- timestamp = ((timestamp == -1) ? this.graphResolver.getCreatedAt(packageName,packageVersion, KnowledgeBaseConnector.dbContext): timestamp);
+ try {
var depSet = this.graphResolver.resolveDependents(packageName,
packageVersion, timestamp, transitive);
depSet.stream().map(eu.fasten.core.dependents.data.Revision::toJSON).peek(json -> {
@@ -175,10 +179,13 @@ public class ResolutionApi {
dep_name.charAt(0), dep_name, ver);
json.put("url", url);
}).forEach(jsonArray::put);
+ } catch (RuntimeException e) {
+ return new ResponseEntity<>("Failed to resolve dependents for revision "+packageName+":"+ packageVersion , HttpStatus.NOT_FOUND);
+ }
break;
}
case Constants.debianForge: {
- timestamp = ((timestamp == -1) ? this.graphResolver.getCreatedAt(packageName,packageVersion, KnowledgeBaseConnector.dbContext): timestamp);
+ try {
var depSet = this.graphResolver.resolveDependents(packageName,
packageVersion, timestamp, transitive);
depSet.stream().map(eu.fasten.core.dependents.data.Revision::toJSON).peek(json -> {
@@ -188,6 +195,9 @@ public class ResolutionApi {
dep_name.charAt(0), dep_name, ver);
json.put("url", url);
}).forEach(jsonArray::put);
+ } catch (RuntimeException e) {
+ return new ResponseEntity<>("Failed to resolve dependents for revision "+packageName+":"+ packageVersion , HttpStatus.NOT_FOUND);
+ }
break;
}
default:
