List of usage examples for org.springframework.http HttpHeaders setContentType
public void setContentType(@Nullable MediaType mediaType)
From source file:edu.fing.tagsi.db4o.business.TrackingController.java
public void Registrar(Envio envio) { RestTemplate restTemplate = new RestTemplate(); RequestTrackingAddPackage req = new RequestTrackingAddPackage(envio.getId().toString(), envio.getCliente().getId().toString(), envio.getDestino().getId().toString(), envio.getFechaEnvio(), false);/*from w w w . j a v a2 s . c o m*/ HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<RequestTrackingAddPackage> entity = new HttpEntity<>(req, headers); restTemplate.postForObject(ConfigController.getInstance().getURLAddTracking(), entity, void.class); }
From source file:com.abixen.platform.core.interfaces.web.common.ImageLibraryController.java
@RequestMapping(value = "layout/{fileName}/", method = RequestMethod.GET) public ResponseEntity<byte[]> getImage(@PathVariable String fileName) throws IOException { log.debug("fileName: " + fileName); InputStream in;/*from w ww.ja va 2 s . c o m*/ try { in = new FileInputStream(platformResourceConfigurationProperties.getImageLibraryDirectory() + "/layout-miniature/" + fileName); } catch (FileNotFoundException e) { in = new FileInputStream(platformResourceConfigurationProperties.getImageLibraryDirectory() + "/layout-miniature/default-layout-icon.png"); } byte[] b = IOUtils.toByteArray(in); in.close(); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); return new ResponseEntity<byte[]>(b, headers, HttpStatus.CREATED); }
From source file:com.bradley.musicapp.test.restapi.PersonRestControllerTest.java
private HttpHeaders getContentType() { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(new MediaType("application", "json")); return requestHeaders; }
From source file:org.awesomeagile.integrations.hackpad.RestTemplateHackpadClient.java
@Override public void updateHackpad(PadIdentity padIdentity, String content) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_HTML); HttpEntity<String> updateEntity = new HttpEntity<>(content, headers); HackpadStatus status = restTemplate.postForObject(fullUrl(UPDATE_URL), updateEntity, HackpadStatus.class, ImmutableMap.of("padId", padIdentity.getPadId())); if (!status.isSuccess()) { throw new RuntimeException("Failure to update a Hackpad."); }//ww w . j a v a 2s. c o m }
From source file:net.orpiske.tcs.service.rest.functional.DomainCreateTest.java
private HttpHeaders getHeaders(String auth) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); byte[] encodedAuthorisation = Base64.encodeBase64(auth.getBytes()); headers.add("Authorization", "Basic " + new String(encodedAuthorisation)); return headers; }
From source file:biz.c24.io.spring.http.C24HttpMessageConverterUnitTests.java
@Test public void readsXmlCorrectly() throws IOException { when(inputMessage.getBody()).thenReturn(new ByteArrayInputStream(TestConstants.SAMPLE_XML.getBytes())); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_XML); when(inputMessage.getHeaders()).thenReturn(headers); CustomerLocal result = (CustomerLocal) converter.read(CustomerLocal.class, inputMessage); assertThat(result, is(notNullValue())); assertThat(result.getFirstname(), is("Firstname")); }
From source file:org.intermine.app.net.request.JsonGetRequest.java
@Override public HttpHeaders getHeaders() { HttpHeaders headers = super.getHeaders(); headers.setContentType(new MediaType(CONTENT_TYPE, CONTENT_SUBTYPE)); return headers; }
From source file:controllers.ImageController.java
@RequestMapping("/") public ResponseEntity<byte[]> getImage(@RequestParam(value = "name", required = false) String name, @RequestParam(value = "id", required = false) String id) throws IOException { File file = new File("/usr/local/seller/preview/" + id + "/" + name); if (!file.exists()) { return null; }/* w ww. ja v a 2s .co m*/ InputStream in = new FileInputStream(file); //new File("/usr/local/seller/preview/"+id+"/"+name).; //servletContext.getResourceAsStream("/usr/local/seller/preview/"+id+"/"+name); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); return new ResponseEntity<>(IOUtils.toByteArray(in), headers, HttpStatus.CREATED); }
From source file:org.opentestsystem.ap.ivs.rest.ExceptionAdvice.java
private HttpHeaders jsonHeaders() { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(APPLICATION_JSON); return headers; }
From source file:org.sventon.web.ctrl.ConfigurationReloadController.java
@RequestMapping(method = GET) @ResponseBody/*from ww w .j a v a2 s . c o m*/ public ResponseEntity<String> reloadConfigAndReinitializeApplication() { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.TEXT_PLAIN); if (!application.isConfigurationReloadSupported()) { return new ResponseEntity<String>("Forbidden.", responseHeaders, FORBIDDEN); } try { application.reinit(); return new ResponseEntity<String>("Configuration reloaded.", responseHeaders, OK); } catch (Exception e) { logger.error("Failed to reload configuration files.", e); return new ResponseEntity<String>("Internal error.", responseHeaders, INTERNAL_SERVER_ERROR); } }