use of co.cask.cdap.common.ArtifactNotFoundException in project cdap by caskdata.
the class ArtifactClient method listVersions.
/**
* Lists all versions of the given artifact in the given namespace.
*
* @param namespace the namespace to list artifact versions in
* @param artifactName the name of the artifact
* @param scope the scope of artifacts to get. If none is given, the scope defaults to the user scope
* @return list of {@link ArtifactSummary}
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws ArtifactNotFoundException if the given artifact does not exist
*/
public List<ArtifactSummary> listVersions(NamespaceId namespace, String artifactName, @Nullable ArtifactScope scope) throws UnauthenticatedException, IOException, ArtifactNotFoundException, UnauthorizedException {
URL url = scope == null ? config.resolveNamespacedURLV3(namespace, String.format("artifacts/%s", artifactName)) : config.resolveNamespacedURLV3(namespace, String.format("artifacts/%s?scope=%s", artifactName, scope.name()));
HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new ArtifactNotFoundException(namespace, artifactName);
}
return ObjectResponse.<List<ArtifactSummary>>fromJsonBody(response, ARTIFACT_SUMMARIES_TYPE).getResponseObject();
}
Aggregations