Search in sources :

Example 6 with HandlerException

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

the class DatasetInstanceHandler method create.

/**
   * Creates a new dataset instance.
   *
   * @param namespaceId namespace of the new dataset instance
   * @param name name of the new dataset instance
   */
@PUT
@Path("/data/datasets/{name}")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void create(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String name) throws Exception {
    DatasetInstanceConfiguration creationProperties = ConversionHelpers.getInstanceConfiguration(request);
    try {
        instanceService.create(namespaceId, name, creationProperties);
        responder.sendStatus(HttpResponseStatus.OK);
    } catch (DatasetAlreadyExistsException e) {
        responder.sendString(HttpResponseStatus.CONFLICT, e.getMessage());
    } catch (DatasetTypeNotFoundException e) {
        responder.sendString(HttpResponseStatus.NOT_FOUND, e.getMessage());
    } catch (HandlerException e) {
        responder.sendString(e.getFailureStatus(), e.getMessage());
    }
}
Also used : HandlerException(co.cask.cdap.common.HandlerException) DatasetAlreadyExistsException(co.cask.cdap.common.DatasetAlreadyExistsException) DatasetInstanceConfiguration(co.cask.cdap.proto.DatasetInstanceConfiguration) DatasetTypeNotFoundException(co.cask.cdap.common.DatasetTypeNotFoundException) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) PUT(javax.ws.rs.PUT)

Aggregations

HandlerException (co.cask.cdap.common.HandlerException)6 DatasetAdminOpResponse (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpResponse)2 Path (javax.ws.rs.Path)2 DatasetAlreadyExistsException (co.cask.cdap.common.DatasetAlreadyExistsException)1 DatasetNotFoundException (co.cask.cdap.common.DatasetNotFoundException)1 DatasetTypeNotFoundException (co.cask.cdap.common.DatasetTypeNotFoundException)1 EndpointStrategy (co.cask.cdap.common.discovery.EndpointStrategy)1 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)1 DatasetInstanceConfiguration (co.cask.cdap.proto.DatasetInstanceConfiguration)1 DatasetId (co.cask.cdap.proto.id.DatasetId)1 Principal (co.cask.cdap.proto.security.Principal)1 InetSocketAddress (java.net.InetSocketAddress)1 SSLContext (javax.net.ssl.SSLContext)1 SSLEngine (javax.net.ssl.SSLEngine)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Discoverable (org.apache.twill.discovery.Discoverable)1 Channel (org.jboss.netty.channel.Channel)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelFutureListener (org.jboss.netty.channel.ChannelFutureListener)1