use of org.springframework.http.ResponseEntity in project java-chassis by ServiceComb.
the class SpringmvcConsumerResponseMapper method mapResponse.
@Override
public Object mapResponse(Response response) {
HttpStatus status = HttpStatus.valueOf(response.getStatusCode());
HttpHeaders httpHeaders = null;
Map<String, List<Object>> headers = response.getHeaders().getHeaderMap();
if (headers != null) {
httpHeaders = new HttpHeaders();
for (Entry<String, List<Object>> entry : headers.entrySet()) {
for (Object value : entry.getValue()) {
httpHeaders.add(entry.getKey(), String.valueOf(value));
}
}
}
return new ResponseEntity<Object>(response.getResult(), httpHeaders, status);
}
use of org.springframework.http.ResponseEntity in project java-chassis by ServiceComb.
the class SpringmvcProducerResponseMapper method mapResponse.
@SuppressWarnings("unchecked")
@Override
public Response mapResponse(StatusType status, Object response) {
ResponseEntity<Object> springmvcResponse = (ResponseEntity<Object>) response;
StatusType responseStatus = new HttpStatus(springmvcResponse.getStatusCode().value(), springmvcResponse.getStatusCode().getReasonPhrase());
Response cseResponse = Response.status(responseStatus).entity(springmvcResponse.getBody());
HttpHeaders headers = springmvcResponse.getHeaders();
Headers cseHeaders = cseResponse.getHeaders();
for (Entry<String, List<String>> entry : headers.entrySet()) {
if (entry.getValue() == null || entry.getValue().isEmpty()) {
continue;
}
for (String value : entry.getValue()) {
cseHeaders.addHeader(entry.getKey(), value);
}
}
return cseResponse;
}
use of org.springframework.http.ResponseEntity in project rhino by PLOS.
the class ArticleCrudController method deleteRevision.
@Transactional(readOnly = false)
@RequestMapping(value = "/articles/{doi}/revisions/{revision}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteRevision(@PathVariable("doi") String doi, @PathVariable("revision") int revisionNumber) {
ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
articleRevisionWriteService.deleteRevision(revisionId);
return new ResponseEntity<>(HttpStatus.OK);
}
use of org.springframework.http.ResponseEntity in project rhino by PLOS.
the class ArticleCrudController method updateSolrIndex.
@RequestMapping(value = "/articles/{doi:.+}", params = { "solrIndex" }, method = RequestMethod.POST)
public ResponseEntity<?> updateSolrIndex(@PathVariable("doi") String doi) {
ArticleIdentifier identifier = ArticleIdentifier.create(DoiEscaping.unescape(doi));
solrIndexService.updateSolrIndex(identifier);
return new ResponseEntity<>(HttpStatus.OK);
}
use of org.springframework.http.ResponseEntity in project rhino by PLOS.
the class ArticleCrudController method getRawCategoriesAndText.
/**
* Retrieves the raw taxonomy categories associated with the article along with the text that is sent to the taxonomy
* server for classification
*
* @param request
* @return a String containing the text and raw categories in the form of <text> \n\n <categories>
* @throws IOException
*/
// TODO: Get rid of this?
@Transactional(readOnly = true)
@RequestMapping(value = "/articles/{doi}/categories", method = RequestMethod.GET, params = "rawCategoriesAndText")
public ResponseEntity<String> getRawCategoriesAndText(HttpServletRequest request, @PathVariable("doi") String doi) throws IOException {
ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(doi));
String categoriesAndText = articleCrudService.getRawCategoriesAndText(articleId);
HttpHeaders responseHeader = new HttpHeaders();
responseHeader.setContentType(MediaType.TEXT_HTML);
return new ResponseEntity<>(categoriesAndText, responseHeader, HttpStatus.OK);
}
Aggregations