use of io.cdap.cdap.common.NamespaceNotFoundException in project cdap by caskdata.
the class SchedulerQueueResolver method getQueue.
/**
* Get queue at namespace level if it is empty returns the default queue.
*
* @param namespaceId NamespaceId
* @return schedule queue at namespace level or default queue.
*/
@Nullable
public String getQueue(NamespaceId namespaceId) throws IOException, NamespaceNotFoundException {
if (namespaceId.equals(NamespaceId.SYSTEM)) {
return systemQueue;
}
NamespaceMeta meta;
try {
meta = namespaceQueryAdmin.get(namespaceId);
} catch (NamespaceNotFoundException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
if (meta != null) {
NamespaceConfig config = meta.getConfig();
String namespaceQueue = config.getSchedulerQueueName();
return Strings.isNullOrEmpty(namespaceQueue) ? getDefaultQueue() : namespaceQueue;
} else {
return getDefaultQueue();
}
}
use of io.cdap.cdap.common.NamespaceNotFoundException in project cdap by caskdata.
the class AppLifecycleHttpHandlerTest method testDeployNonExistingNamespace.
/**
* Tests deploying an application in a non-existing non-default namespace.
*/
@Test
public void testDeployNonExistingNamespace() throws Exception {
HttpResponse response = deploy(AllProgramsApp.class, 404, Constants.Gateway.API_VERSION_3_TOKEN, "random");
NotFoundException nfe = new NamespaceNotFoundException(new NamespaceId("random"));
Assert.assertEquals(nfe.getMessage(), response.getResponseBodyAsString());
}
use of io.cdap.cdap.common.NamespaceNotFoundException in project cdap by caskdata.
the class AppLifecycleHttpHandlerInternal method getAppDetailForVersion.
/**
* Get {@link ApplicationDetail} for a given application
*
* @param request {@link HttpRequest}
* @param responder {@link HttpResponse}
* @param namespace the namespace to get all application details
* @param application the id of the application to get its {@link ApplicationDetail}
* @throws Exception if either namespace or application doesn't exist, or failed to get {@link ApplicationDetail}
*/
@GET
@Path("/app/{app-id}/versions/{version-id}")
public void getAppDetailForVersion(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") final String namespace, @PathParam("app-id") final String application, @PathParam("version-id") final String version) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
ApplicationId appId = new ApplicationId(namespace, application, version);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(applicationLifecycleService.getAppDetail(appId)));
}
use of io.cdap.cdap.common.NamespaceNotFoundException in project cdap by caskdata.
the class AppLifecycleHttpHandlerInternal method getAppDetail.
/**
* Get {@link ApplicationDetail} for a given application
*
* @param request {@link HttpRequest}
* @param responder {@link HttpResponse}
* @param namespace the namespace to get all application details *
* @param application the id of the application to get its {@link ApplicationDetail}
* @throws Exception if either namespace or application doesn't exist, or failed to get {@link ApplicationDetail}
*/
@GET
@Path("/app/{app-id}")
public void getAppDetail(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("app-id") String application) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
ApplicationId appId = new ApplicationId(namespace, application);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(applicationLifecycleService.getAppDetail(appId)));
}
use of io.cdap.cdap.common.NamespaceNotFoundException in project cdap by caskdata.
the class ArtifactHttpHandlerInternal method getArtifactDetailForVersions.
@GET
@Path("/namespaces/{namespace-id}/artifacts/{artifact-name}/versions")
public void getArtifactDetailForVersions(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("artifact-name") String artifactName, @QueryParam("lower") String lower, @QueryParam("upper") String upper, @QueryParam("limit") @DefaultValue("1") int limit, @QueryParam("order") String order, @QueryParam("scope") @DefaultValue("user") String scope) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceId.equals(NamespaceId.SYSTEM)) {
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
}
ArtifactRange range = new ArtifactRange(namespaceId.getNamespace(), artifactName, new ArtifactVersionRange(new ArtifactVersion(lower), true, new ArtifactVersion(upper), true));
ArtifactSortOrder sortOrder = ArtifactSortOrder.valueOf(order);
List<ArtifactDetail> artifactDetailList = artifactRepository.getArtifactDetails(range, limit, sortOrder);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(artifactDetailList, ARTIFACT_DETAIL_LIST_TYPE));
}
Aggregations