Example usage for org.springframework.http HttpStatus ACCEPTED

List of usage examples for org.springframework.http HttpStatus ACCEPTED

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus ACCEPTED.

Prototype

HttpStatus ACCEPTED

To view the source code for org.springframework.http HttpStatus ACCEPTED.

Click Source Link

Document

202 Accepted .

Usage

From source file:org.talend.dataprep.api.service.command.preparation.PreparationSearchByName.java

/**
 * Private constructor used to construct the generic command used to list of preparations matching name.
 *
 * @param name the specified name//from   ww w  .j  av a  2 s  . c o m
 * @param exactMatch the specified boolean
 */
private PreparationSearchByName(String name, boolean exactMatch) {
    super(GenericCommand.PREPARATION_GROUP);
    execute(() -> {
        try {
            URIBuilder uriBuilder = new URIBuilder(preparationServiceUrl + "/preparations/search");
            uriBuilder.addParameter("name", name);
            uriBuilder.addParameter("exactMatch", String.valueOf(exactMatch));
            return new HttpGet(uriBuilder.build());
        } catch (URISyntaxException e) {
            throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
        }
    });
    onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_RETRIEVE_PREPARATION_LIST, e));
    on(HttpStatus.NO_CONTENT, HttpStatus.ACCEPTED).then(emptyStream());
    on(HttpStatus.OK).then(pipeStream());
}

From source file:org.talend.dataprep.api.service.command.transformation.ColumnActions.java

/**
 * Constructor./*from  www  . jav a 2  s  . co m*/
 *
 * @param input the column metadata to get the actions for (in json).
 */
private ColumnActions(InputStream input) {
    super(GenericCommand.TRANSFORM_GROUP);
    execute(() -> {
        HttpPost post = new HttpPost(transformationServiceUrl + "/actions/column");
        post.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
        post.setEntity(new InputStreamEntity(input));
        return post;
    });
    onError((e) -> new TDPException(APIErrorCodes.UNABLE_TO_RETRIEVE_SUGGESTED_ACTIONS, e));
    on(HttpStatus.NO_CONTENT, HttpStatus.ACCEPTED).then(asNull());
    on(HttpStatus.OK).then(pipeStream());
}

From source file:org.talend.dataprep.api.service.command.transformation.SuggestColumnActions.java

/**
 * Constructor./*  w w w .j  a  v  a  2s. co  m*/
 *
 * @param input the column metadata to get the actions for (in json).
 */
private SuggestColumnActions(InputStream input) {
    super(GenericCommand.TRANSFORM_GROUP);
    execute(() -> {
        HttpPost post = new HttpPost(transformationServiceUrl + "/suggest/column");
        post.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
        post.setEntity(new InputStreamEntity(input));
        return post;
    });
    onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_RETRIEVE_SUGGESTED_ACTIONS, e));
    on(HttpStatus.NO_CONTENT, HttpStatus.ACCEPTED).then(asNull());
    on(HttpStatus.OK).then(pipeStream());
}

From source file:org.talend.dataprep.api.service.command.transformation.SuggestDataSetActions.java

/**
 * Constructor.//from   w  w  w .  ja  v a2s.  c  o m
 *
 * @param retrieveMetadata the previous command to execute.
 */
private SuggestDataSetActions(DataSetGetMetadata retrieveMetadata) {
    super(GenericCommand.TRANSFORM_GROUP, retrieveMetadata);
    execute(this::onExecute);
    onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_RETRIEVE_SUGGESTED_ACTIONS, e));
    on(HttpStatus.OK).then(onOk());
    on(HttpStatus.NO_CONTENT, HttpStatus.ACCEPTED).then(asNull());
}

From source file:org.talend.dataprep.command.GenericCommandTestService.java

@RequestMapping(value = "/command/test/success_with_unknown", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
public String success_with_unknown() throws IOException {
    HttpResponseContext.status(HttpStatus.ACCEPTED);
    return "success";
}

From source file:org.talend.dataprep.dataset.service.DataSetService.java

/**
 * Returns the data set {@link DataSetMetadata metadata} for given <code>dataSetId</code>.
 *
 * @param dataSetId A data set id. If <code>null</code> <b>or</b> if no data set with provided id exits, operation
 * returns {@link org.apache.commons.httpclient.HttpStatus#SC_NO_CONTENT} if metadata does not exist.
 *//*from www  . j av a2s.  c om*/
@RequestMapping(value = "/datasets/{id}/metadata", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get metadata information of a data set by id", notes = "Get metadata information of a data set by id. Not valid or non existing data set id returns empty content.")
@Timed
@ResponseBody
public DataSet getMetadata(
        @PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the data set metadata") String dataSetId) {
    if (dataSetId == null) {
        HttpResponseContext.status(HttpStatus.NO_CONTENT);
        return null;
    }

    LOG.debug("get dataset metadata for {}", dataSetId);

    DataSetMetadata metadata = dataSetMetadataRepository.get(dataSetId);
    if (metadata == null) {
        throw new TDPException(DataSetErrorCodes.DATASET_DOES_NOT_EXIST, build().put("id", dataSetId));
    }
    if (!metadata.getLifecycle().schemaAnalyzed()) {
        HttpResponseContext.status(HttpStatus.ACCEPTED);
        return DataSet.empty();
    }
    DataSet dataSet = new DataSet();
    dataSet.setMetadata(conversionService.convert(metadata, UserDataSetMetadata.class));
    LOG.info("found dataset {} for #{}", dataSet.getMetadata().getName(), dataSetId);
    return dataSet;
}