use of co.cask.cdap.api.common.HttpErrorStatusProvider in project cdap by caskdata.
the class DatasetInstanceService method get.
/**
* Gets a dataset instance.
*
* @param instance instance to get
* @param owners the {@link EntityId entities} that will be using the dataset instance
* @return the dataset instance's {@link DatasetMeta}
* @throws NotFoundException if either the namespace or dataset instance is not found,
* @throws IOException if there is a problem in making an HTTP request to check if the namespace exists
* @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not
* have any privileges on the #instance
*/
DatasetMeta get(final DatasetId instance, List<? extends EntityId> owners) throws Exception {
// Application Deployment first makes a call to the dataset service to check if the instance already exists with
// a different type. To make sure that that call responds with the right exceptions if necessary, first fetch the
// meta from the cache and throw appropriate exceptions if necessary.
DatasetMeta datasetMeta;
try {
datasetMeta = metaCache.get(instance);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if ((cause instanceof Exception) && (cause instanceof HttpErrorStatusProvider)) {
throw (Exception) cause;
}
throw e;
}
// Only return the above datasetMeta if authorization succeeds
ensureAccess(instance);
return datasetMeta;
}
Aggregations