Search in sources :

Example 1 with MethodNotAllowedException

use of co.cask.cdap.common.MethodNotAllowedException in project cdap by caskdata.

the class ProgramLifecycleHttpHandler method programSpecification.

@GET
@Path("/apps/{app-name}/versions/{app-version}/{program-type}/{program-name}")
public void programSpecification(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-name") String appName, @PathParam("app-version") String appVersion, @PathParam("program-type") String type, @PathParam("program-name") String programName) throws Exception {
    ProgramType programType = getProgramType(type);
    if (programType == null) {
        throw new MethodNotAllowedException(request.getMethod(), request.getUri());
    }
    ApplicationId application = new ApplicationId(namespaceId, appName, appVersion);
    ProgramId programId = application.program(programType, programName);
    ProgramSpecification specification = lifecycleService.getProgramSpecification(programId);
    if (specification == null) {
        throw new NotFoundException(programId);
    }
    responder.sendJson(HttpResponseStatus.OK, specification);
}
Also used : MethodNotAllowedException(co.cask.cdap.common.MethodNotAllowedException) ProgramSpecification(co.cask.cdap.api.ProgramSpecification) NamespaceNotFoundException(co.cask.cdap.common.NamespaceNotFoundException) NotFoundException(co.cask.cdap.common.NotFoundException) ProgramType(co.cask.cdap.proto.ProgramType) ApplicationId(co.cask.cdap.proto.id.ApplicationId) ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 MethodNotAllowedException (co.cask.cdap.common.MethodNotAllowedException)1 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)1 NotFoundException (co.cask.cdap.common.NotFoundException)1 ProgramType (co.cask.cdap.proto.ProgramType)1 ApplicationId (co.cask.cdap.proto.id.ApplicationId)1 ProgramId (co.cask.cdap.proto.id.ProgramId)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1