Example usage for org.springframework.http MediaType MediaType

List of usage examples for org.springframework.http MediaType MediaType

Introduction

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

Prototype

public MediaType(MediaType other, @Nullable Map<String, String> parameters) 

Source Link

Document

Copy-constructor that copies the type and subtype of the given MediaType , and allows for different parameters.

Usage

From source file:com.apress.prospringintegration.web.MultipartHttpClient.java

public static void main(String[] args) {
    RestTemplate template = new RestTemplate();
    String uri = "http://localhost:8080/http-adapter-1.0.0/inboundMultipartAdapter.html";
    Resource picture = new ClassPathResource("com/apress/prospringintegration/web/test.png");
    MultiValueMap map = new LinkedMultiValueMap();
    map.add("name", "John Smith");
    map.add("picture", picture);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(new MediaType("multipart", "form-data"));
    HttpEntity request = new HttpEntity(map, headers);
    ResponseEntity<?> httpResponse = template.exchange(uri, HttpMethod.POST, request, null);
    System.out.println("Status: " + httpResponse.getStatusCode().name());
}

From source file:io.curly.tagger.TagHelper.java

public static MediaType jsonMediaType() {
    return new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype());
}

From source file:com.royclarkson.springagram.RestUtils.java

public static HttpEntity<Void> getRequestEntity() {
    if (requestEntity == null) {
        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "hal+json")));
        requestEntity = new HttpEntity<Void>(requestHeaders);
    }//from   w w  w.  j a v a 2 s  .  co m
    return requestEntity;
}

From source file:ca.weblite.contacts.webservice.CN1DataMapperMessageConverter.java

public CN1DataMapperMessageConverter() {
    super(new MediaType("application", "cn1"));
    for (DataMapper m : Mappers.getInstance().getContext().values()) {
        m.setOutputDatesAsLongs(true);// w  w  w .j  a v a 2  s .c  o  m
    }
}

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:org.cloudfoundry.caldecott.server.converter.ByteBufferHttpMessageConverter.java

public ByteBufferHttpMessageConverter() {
    super(new MediaType("application", "octet-stream"), MediaType.ALL);
}

From source file:org.urlshortener.core.converter.UrlShortenerMessageConverter.java

public List<MediaType> getSupportedMediaTypes() {
    return Collections.singletonList(new MediaType("text", "plain"));
}

From source file:org.obiba.onyx.core.service.impl.ParticipantHttpMessageConverter.java

public List<MediaType> getSupportedMediaTypes() {
    return Collections.singletonList(new MediaType("text", "xml"));
}

From source file:org.intermine.app.net.request.JsonPostRequest.java

@Override
public HttpHeaders getHeaders() {
    HttpHeaders headers = super.getHeaders();
    headers.setContentType(new MediaType(CONTENT_TYPE, "x-www-form-urlencoded"));

    return headers;
}

From source file:com.joseph.california.test.restapi.PersonRestControllerTest.java

private HttpEntity<?> getHttpEntity() {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "json")));
    HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    return requestEntity;
}