use of co.cask.cdap.common.NotFoundException in project cdap by caskdata.
the class StreamViewClient method get.
/**
* Gets detailed information about a view.
*
* @param id the view
* @return the detailed information about the view
* @throws NotFoundException if the view was not found
*/
public ViewDetail get(StreamViewId id) throws NotFoundException, IOException, UnauthenticatedException, UnauthorizedException {
URL url = config.resolveNamespacedURLV3(id.getParent().getParent(), String.format("streams/%s/views/%s", id.getStream(), id.getView()));
HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(id);
}
return ObjectResponse.fromJsonBody(response, ViewDetail.class, GSON).getResponseObject();
}
use of co.cask.cdap.common.NotFoundException in project cdap by caskdata.
the class WorkflowClient method getWorkflowNodeStates.
/**
* Get node states associated with the Workflow run.
* @param workflowRunId run id for the Workflow
* @return the map of node id to the {@link WorkflowNodeStateDetail}
* @throws IOException if the error occurred during executing the http request
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
* @throws NotFoundException if the workflow with given runid not found
*/
public Map<String, WorkflowNodeStateDetail> getWorkflowNodeStates(ProgramRunId workflowRunId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException {
String path = String.format("apps/%s/workflows/%s/runs/%s/nodes/state", workflowRunId.getApplication(), workflowRunId.getProgram(), workflowRunId.getRun());
NamespaceId namespaceId = workflowRunId.getNamespaceId();
URL urlPath = config.resolveNamespacedURLV3(namespaceId, path);
HttpResponse response = restClient.execute(HttpMethod.GET, urlPath, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new NotFoundException(workflowRunId);
}
return ObjectResponse.fromJsonBody(response, new TypeToken<Map<String, WorkflowNodeStateDetail>>() {
}).getResponseObject();
}
use of co.cask.cdap.common.NotFoundException 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;
}
use of co.cask.cdap.common.NotFoundException in project cdap by caskdata.
the class DatasetInstanceService method getFromMds.
/**
* Read the dataset meta data (instance and type) from MDS.
*/
private DatasetMeta getFromMds(DatasetId instance) throws Exception {
// TODO: CDAP-3901 add back namespace existence check
DatasetSpecification spec = instanceManager.get(instance);
if (spec == null) {
throw new NotFoundException(instance);
}
spec = DatasetsUtil.fixOriginalProperties(spec);
DatasetTypeId datasetTypeId = instance.getParent().datasetType(spec.getType());
DatasetTypeMeta typeMeta = getTypeInfo(instance.getParent(), spec.getType());
if (typeMeta == null) {
// TODO: This shouldn't happen unless CDAP is in an invalid state - maybe give different error
throw new NotFoundException(datasetTypeId);
}
// for system dataset do not look up owner information in store as we know that it will be null.
// Also, this is required for CDAP to start, because initially we don't want to look up owner admin
// (causing its own lookup) as the SystemDatasetInitiator.getDataset is called when CDAP starts
String ownerPrincipal = null;
if (!NamespaceId.SYSTEM.equals(instance.getNamespaceId())) {
ownerPrincipal = ownerAdmin.getOwnerPrincipal(instance);
}
return new DatasetMeta(spec, typeMeta, null, ownerPrincipal);
}
use of co.cask.cdap.common.NotFoundException in project cdap by caskdata.
the class DatasetInstanceService method getOriginalProperties.
/**
* Return the original properties of a dataset instance, that is, the properties with which the dataset was
* created or last reconfigured.
* @param instance the id of the dataset
* @return The original properties as stored in the dataset's spec, or if they are not available, a best effort
* to derive the original properties from the top-level properties of the spec
* @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not
* have any privileges on the #instance
*/
Map<String, String> getOriginalProperties(DatasetId instance) throws Exception {
DatasetSpecification spec = instanceManager.get(instance);
if (spec == null) {
throw new NotFoundException(instance);
}
// Only return the properties if authorization succeeds
ensureAccess(instance);
return DatasetsUtil.fixOriginalProperties(spec).getOriginalProperties();
}
Aggregations