use of io.cdap.cdap.common.NotFoundException in project cdap by caskdata.
the class PreferencesClient method deleteNamespacePreferences.
/**
* Deletes Preferences at the Namespace Level.
*
* @param namespace Namespace Id
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the requested namespace is not found
*/
public void deleteNamespacePreferences(NamespaceId namespace) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException {
URL url = config.resolveURLV3(String.format("namespaces/%s/preferences", namespace.getNamespace()));
HttpResponse response = restClient.execute(HttpMethod.DELETE, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(namespace);
}
}
use of io.cdap.cdap.common.NotFoundException in project cdap by caskdata.
the class PreferencesClient method getNamespacePreferences.
/**
* Returns the Preferences stored at the Namespace Level.
*
* @param namespace Namespace Id
* @param resolved Set to True if collapsed/resolved properties are desired
* @return map of key-value pairs
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the requested namespace is not found
*/
public Map<String, String> getNamespacePreferences(NamespaceId namespace, boolean resolved) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException {
String res = Boolean.toString(resolved);
URL url = config.resolveURLV3(String.format("namespaces/%s/preferences?resolved=%s", namespace.getNamespace(), res));
HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(namespace);
}
return ObjectResponse.fromJsonBody(response, new TypeToken<Map<String, String>>() {
}).getResponseObject();
}
use of io.cdap.cdap.common.NotFoundException in project cdap by caskdata.
the class PreferencesClient method setApplicationPreferences.
/**
* Sets Preferences at the Application Level.
*
* @param application Application Id
* @param preferences map of key-value pairs
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the requested application or namespace is not found
*/
public void setApplicationPreferences(ApplicationId application, Map<String, String> preferences) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException {
URL url = config.resolveNamespacedURLV3(application.getParent(), String.format("/apps/%s/preferences", application.getApplication()));
HttpResponse response = restClient.execute(HttpMethod.PUT, url, GSON.toJson(preferences), null, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(application);
}
}
use of io.cdap.cdap.common.NotFoundException in project cdap by caskdata.
the class PreferencesClient method setNamespacePreferences.
/**
* Sets Preferences at the Namespace Level.
*
* @param namespace Namespace Id
* @param preferences map of key-value pairs
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the requested namespace is not found
*/
public void setNamespacePreferences(NamespaceId namespace, Map<String, String> preferences) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException {
URL url = config.resolveURLV3(String.format("namespaces/%s/preferences", namespace.getNamespace()));
HttpResponse response = restClient.execute(HttpMethod.PUT, url, GSON.toJson(preferences), null, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(namespace);
}
}
use of io.cdap.cdap.common.NotFoundException in project cdap by caskdata.
the class ServiceClient method checkAvailability.
/**
* Checks whether the {@link Service} is active.
*
* @param service ID of the service
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the app or service could not be found
* @throws ServiceUnavailableException if the service is not available
*/
public void checkAvailability(ServiceId service) throws IOException, UnauthenticatedException, NotFoundException, ServiceUnavailableException, UnauthorizedException {
URL url = config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/versions/%s/services/%s/available", service.getApplication(), service.getVersion(), service.getProgram()));
HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_BAD_REQUEST, HttpURLConnection.HTTP_UNAVAILABLE);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(service);
}
if (response.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) {
throw new ServiceUnavailableException(service.getProgram());
}
}
Aggregations