DataSetAPI extends APIService { @RequestMapping(value = "/api/datasets/{id}", method = DELETE) @ApiOperation(value = "Delete a data set by id", notes = "Delete a data set content based on provided id. Id should be a UUID returned by the list operation. Not valid or non existing data set id returns empty content.") @Timed public ResponseEntity<String> delete(@PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the data set to delete") String dataSetId) { if (LOG.isDebugEnabled()) { LOG.debug("Delete dataset #{} (pool: {})...", dataSetId, getConnectionStats()); } HystrixCommand<ResponseEntity<String>> deleteCommand = getCommand(DataSetDelete.class, dataSetId); try { return deleteCommand.execute(); } finally { if (LOG.isDebugEnabled()) { LOG.debug("Listing datasets (pool: {}) done.", getConnectionStats()); } } }  @RequestMapping(value = "/api/datasets", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Create a data set", produces = TEXT_PLAIN_VALUE, notes = "Create a new data set based on content provided in POST body. For documentation purposes, body is typed as 'text/plain' but operation accepts binary content too. Returns the id of the newly created data set.") @Timed Callable<String> create(
            @ApiParam(
                    value = "User readable name of the data set (e.g. 'Finance Report 2015', 'Test Data Set').") @RequestParam(
                            defaultValue = "", required = false) final String name,
            @ApiParam(value = "An optional tag to be added in data set metadata once created.") @RequestParam(
                    defaultValue = "", required = false) String tag,
            @ApiParam(value = "Size of the data set, in bytes.") @RequestParam(defaultValue = "0") long size,
            @RequestHeader(CONTENT_TYPE) String contentType, @ApiParam(value = "content") InputStream dataSetContent); @RequestMapping(value = "/api/datasets/{id}", method = PUT, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Update a data set by id.", produces = TEXT_PLAIN_VALUE, // notes = "Create or update a data set based on content provided in PUT body with given id. For documentation purposes, body is typed as 'text/plain' but operation accepts binary content too. Returns the id of the newly created data set.") @Timed Callable<String> createOrUpdateById(
            @ApiParam(
                    value = "User readable name of the data set (e.g. 'Finance Report 2015', 'Test Data Set').") @RequestParam(
                            defaultValue = "", required = false) String name,
            @ApiParam(value = "Id of the data set to update / create") @PathVariable(value = "id") String id,
            @ApiParam(value = "Size of the data set, in bytes.") @RequestParam(defaultValue = "0") long size,
            @ApiParam(value = "content") InputStream dataSetContent); @RequestMapping(value = "/api/datasets/{id}/copy", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Copy the dataset.", produces = TEXT_PLAIN_VALUE, notes = "Copy the dataset, returns the id of the copied created data set.") @Timed Callable<String> copy(@ApiParam(value = "Name of the copy") @RequestParam(required = false) String name,
            @ApiParam(value = "Id of the data set to update / create") @PathVariable(value = "id") String id); @RequestMapping(value = "/api/datasets/{id}/metadata", method = PUT, produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Update a data set metadata by id.", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE, // notes = "Update a data set metadata based on content provided in PUT body with given id. For documentation purposes. Returns the id of the updated data set metadata.") @Timed void updateMetadata(
            @ApiParam(value = "Id of the data set metadata to be updated") @PathVariable(value = "id") String id,
            @ApiParam(value = "content") InputStream dataSetContent); @RequestMapping(value = "/api/datasets/{datasetId}/column/{columnId}", method = POST, consumes = APPLICATION_JSON_VALUE) @ApiOperation(value = "Update a dataset.", consumes = APPLICATION_JSON_VALUE, // notes = "Update a data set based on content provided in POST body with given id. For documentation purposes, body is typed as 'text/plain' but operation accepts binary content too.") @Timed void updateColumn(
            @PathVariable(value = "datasetId") @ApiParam(value = "Id of the dataset to update") final String datasetId,
            @PathVariable(value = "columnId") @ApiParam(value = "Id of the column to update") final String columnId,
            @ApiParam(value = "content") final InputStream body); @RequestMapping(value = "/api/datasets/{id}", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a data set by id.", produces = APPLICATION_JSON_VALUE, notes = "Get a data set based on given id.") @Timed DataSet get(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id,
            @ApiParam(value = "Whether output should be the full data set (true) or not (false).") @RequestParam(
                    value = "fullContent", defaultValue = "false") boolean fullContent,
            @ApiParam(value = "Filter for retrieved content.") @RequestParam(value = "filter",
                    defaultValue = "") String filter,
            @ApiParam(value = "Whether to include internal technical properties (true) or not (false).") @RequestParam(
                    value = "includeTechnicalProperties", defaultValue = "false") boolean includeTechnicalProperties); @RequestMapping(value = "/api/datasets/{id}/metadata", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a data set metadata by id.", produces = APPLICATION_JSON_VALUE, notes = "Get a data set metadata based on given id.") @Timed DataSetMetadata getMetadata(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id); @RequestMapping(value = "/api/datasets/preview/{id}", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a data set by id.", produces = APPLICATION_JSON_VALUE, notes = "Get a data set based on given id.") @Timed ResponseEntity<StreamingResponseBody> preview(
            @ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id,
            @RequestParam(defaultValue = "true") @ApiParam(name = "metadata",
                    value = "Include metadata information in the response") boolean metadata,
            @RequestParam(defaultValue = "") @ApiParam(name = "sheetName",
                    value = "Sheet name to preview") String sheetName); @RequestMapping(value = "/api/datasets", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "List data sets.", produces = APPLICATION_JSON_VALUE, notes = "Returns a list of data sets the user can use.") @Timed Stream<DatasetDTO> list(
            @ApiParam(value = "Sort key (by name or date), defaults to 'date'.") @RequestParam(
                    defaultValue = "creationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(
                    defaultValue = "desc") Order order,
            @ApiParam(value = "Filter on name containing the specified name") @RequestParam(
                    defaultValue = "") String name,
            @ApiParam(value = "Filter on certified data sets") @RequestParam(defaultValue = "false") boolean certified,
            @ApiParam(value = "Filter on favorite data sets") @RequestParam(defaultValue = "false") boolean favorite,
            @ApiParam(value = "Filter on recent data sets") @RequestParam(defaultValue = "false") boolean limit); @RequestMapping(value = "/api/datasets/{id}/details", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get a data set detail by id.", produces = APPLICATION_JSON_VALUE, notes = "Get a data set metadata based on given id.") @Timed DatasetDetailsDTO getDetails(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id); @RequestMapping(value = "/api/datasets/{id}/preparations", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get the list of preparation using a dataset by the dataset id.", produces = APPLICATION_JSON_VALUE, notes = "Get the list of preparation using a dataset by the dataset id.") @Timed List<DatasetDetailsDTO.Preparation> getPreparation(@ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String id); @RequestMapping(value = "/api/datasets/summary", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "List data sets summary.", produces = APPLICATION_JSON_VALUE, notes = "Returns a list of data sets summary the user can use.") @Timed Stream<DatasetDTO> listSummary(
            @ApiParam(value = "Sort key (by name or date), defaults to 'date'.") @RequestParam(
                    defaultValue = "creationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(
                    defaultValue = "desc") Order order,
            @ApiParam(value = "Filter on name containing the specified name") @RequestParam(
                    defaultValue = "") String name,
            @ApiParam(value = "Filter on certified data sets") @RequestParam(defaultValue = "false") boolean certified,
            @ApiParam(value = "Filter on favorite data sets") @RequestParam(defaultValue = "false") boolean favorite,
            @ApiParam(value = "Filter on recent data sets") @RequestParam(defaultValue = "false") boolean limit); @RequestMapping(value = "/api/datasets/{id}/compatiblepreparations", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "List compatible preparations.", produces = APPLICATION_JSON_VALUE, notes = "Returns a list of data sets that are compatible with the specified one.") @Timed Stream<PreparationDTO> listCompatiblePreparations(
            @ApiParam(value = "Id of the data set to get") @PathVariable(value = "id") String dataSetId,
            @ApiParam(value = "Sort key (by name or date), defaults to 'modification'.") @RequestParam(
                    defaultValue = "lastModificationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(
                    defaultValue = "desc") Order order); @RequestMapping(value = "/api/datasets/{id}", method = DELETE) @ApiOperation(value = "Delete a data set by id", notes = "Delete a data set content based on provided id. Id should be a UUID returned by the list operation. Not valid or non existing data set id returns empty content.") @Timed ResponseEntity<String> delete(@PathVariable(value = "id") @ApiParam(name = "id",
            value = "Id of the data set to delete") String dataSetId); @RequestMapping(value = "/api/datasets/{id}/actions", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get suggested actions for a whole data set.", notes = "Returns the suggested actions for the given dataset in decreasing order of likeness.") @Timed @Deprecated Stream<ActionForm> suggestDatasetActions(@PathVariable(value = "id") @ApiParam(name = "id",
            value = "Data set id to get suggestions from.") String dataSetId); @RequestMapping(value = "/api/datasets/actions/lookup", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Get lookup actions for all data sets.", notes = "Returns the lookup actions for the datasets.") @Timed Stream<ActionForm> getDatasetsLookupActions(); @RequestMapping(value = "/api/datasets/favorite/{id}", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Set or Unset the dataset as favorite for the current user.", produces = TEXT_PLAIN_VALUE, // notes = "Specify if a dataset is or is not a favorite for the current user.") @Timed Callable<String> favorite(
            @ApiParam(value = "Id of the favorite data set ") @PathVariable(value = "id") String id,
            @RequestParam(defaultValue = "false") @ApiParam(name = "unset",
                    value = "When true, will remove the dataset from favorites, if false (default) this will set the dataset as favorite.") boolean unset); @RequestMapping(value = "/api/datasets/encodings", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "List supported dataset encodings.", notes = "Returns the supported dataset encodings.") @Timed @PublicAPI Stream<String> listEncodings(); @RequestMapping(value = "/api/datasets/imports/{import}/parameters", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Fetch the parameters needed to imports a dataset.", notes = "Returns the parameters needed to imports a dataset.") @Timed @PublicAPI ResponseEntity<StreamingResponseBody> getImportParameters(@PathVariable("import") final String importType); @RequestMapping(value = "/api/datasets/{datasetId}/columns/{columnId}/types", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "list the types of the wanted column", notes = "This list can be used by user to change the column type.") @Timed @PublicAPI Stream<SemanticDomain> getDataSetColumnSemanticCategories(
            @ApiParam(value = "The dataset id") @PathVariable String datasetId,
            @ApiParam(value = "The column id") @PathVariable String columnId);  }
@Test public void testDataSetDeleteMissing() throws Exception { when().delete("/api/datasets/dataset1234").then().statusCode(404); }