Search in sources :

Example 11 with CatalogException

use of com.thinkbiganalytics.kylo.catalog.CatalogException in project kylo by Teradata.

the class DataSetController method createDataSet.

@POST
@ApiOperation("Creates a new data set")
@ApiResponses({ @ApiResponse(code = 200, message = "Data set created", response = DataSet.class), @ApiResponse(code = 400, message = "Invalid data source", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "Internal server error", response = RestResponseStatus.class) })
@Consumes(MediaType.APPLICATION_JSON)
public Response createDataSet(@Nonnull final DataSet source) {
    log.entry(source);
    final boolean encryptCredentials = true;
    DataSet dataSet;
    try {
        dataSet = dataSetService.findOrCreateDataSet(source, encryptCredentials);
    } catch (final CatalogException e) {
        log.debug("Cannot create data set from request: {}", source, e);
        throw new BadRequestException(getMessage(e));
    }
    return Response.ok(log.exit(dataSet)).build();
}
Also used : DataSet(com.thinkbiganalytics.kylo.catalog.rest.model.DataSet) CatalogException(com.thinkbiganalytics.kylo.catalog.CatalogException) BadRequestException(javax.ws.rs.BadRequestException) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

CatalogException (com.thinkbiganalytics.kylo.catalog.CatalogException)11 DataSource (com.thinkbiganalytics.kylo.catalog.rest.model.DataSource)5 Nonnull (javax.annotation.Nonnull)5 BadRequestException (javax.ws.rs.BadRequestException)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 Consumes (javax.ws.rs.Consumes)4 DataSet (com.thinkbiganalytics.kylo.catalog.rest.model.DataSet)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 PotentialControllerServiceConflictException (com.thinkbiganalytics.kylo.catalog.datasource.PotentialControllerServiceConflictException)2 ConnectorPluginDescriptor (com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor)2 DataSetFile (com.thinkbiganalytics.kylo.catalog.rest.model.DataSetFile)2 DataSourceAlreadyExistsException (com.thinkbiganalytics.metadata.api.catalog.DataSourceAlreadyExistsException)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 BasicAWSCredentialsProvider (org.apache.hadoop.fs.s3a.BasicAWSCredentialsProvider)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AWSCredentialsProviderChain (com.amazonaws.auth.AWSCredentialsProviderChain)1