Example usage for org.springframework.http HttpEntity HttpEntity

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

Introduction

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

Prototype

public HttpEntity(MultiValueMap<String, String> headers) 

Source Link

Document

Create a new HttpEntity with the given headers and no body.

Usage

From source file:client.RestConnector.java

public Response send(Request request) {
    HttpEntity<Request> requestEntity = new HttpEntity<>(request);
    ResponseEntity<Response> response1 = restTemplate.exchange("http://" + host + ":" + port + "/graphdb",
            HttpMethod.POST, requestEntity, Response.class);

    return response1.getBody();
}

From source file:org.zalando.riptide.AsyncRest.java

public AsyncDispatcher execute(final HttpMethod method, final URI url, final HttpHeaders headers) {
    return execute(method, url, new HttpEntity<>(headers));
}

From source file:at.create.android.ffc.http.FetchContacts.java

/**
 * Fetches the contacts./*from  w ww .j a  v a 2 s . com*/
 */
public void fetch() {
    setAcceptHeaderApplicationXml();
    HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
    restTemplate.getMessageConverters().add(new SimpleXmlHttpMessageConverter());

    // Perform the HTTP GET request
    ResponseEntity<ContactList> responseEntity = restTemplate.exchange(getUrl(), HttpMethod.GET, requestEntity,
            ContactList.class);

    contactList = responseEntity.getBody();
}

From source file:org.openlmis.fulfillment.service.request.RequestHelper.java

/**
 * Creates an {@link HttpEntity} with the given headers.
 *///  www  .j  ava 2s.c  o  m
public static <E> HttpEntity<E> createEntity(RequestHeaders headers) {
    return new HttpEntity<>(headers.toHeaders());
}

From source file:edu.fing.tagsi.db4o.business.TrackingController.java

public List<Tracking> getTracking(UUID id) {
    RestTemplate restTemplate = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity entity = new HttpEntity(headers);

    ResponseEntity<RequestTrackingAddPackage[]> tracking = restTemplate.exchange(
            ConfigController.getInstance().getURLFindTracking() + "/" + id.toString(), GET, entity,
            RequestTrackingAddPackage[].class);

    if (tracking != null) {
        List<Tracking> resultado = new ArrayList<>(tracking.getBody().length);
        for (RequestTrackingAddPackage r : tracking.getBody()) {

            resultado.add(new Tracking(UUID.fromString(r.getIdpaquete()), UUID.fromString(r.getIdcliente()),
                    UUID.fromString(r.getIdlugar()), r.getFecha(), r.isEsdestino()));
        }// www .  j av  a  2  s  .  com
        return resultado;
    } else {
        return null;
    }

}

From source file:org.zalando.riptide.AsyncRest.java

public AsyncDispatcher execute(final HttpMethod method, final URI url, final Object body) {
    return execute(method, url, new HttpEntity<>(body));
}

From source file:org.openwms.common.comm.sysu.HttpSystemUpdateMessageHandler.java

@Override
public Void apply(SystemUpdateMessage msg) {
    restTemplate.exchange("http://routing-service/v1/sysu", HttpMethod.POST,
            new HttpEntity<>(new RequestVO(msg.getLocationGroupName(), msg.getErrorCode())), Void.class);
    return null;//from  www  .j  ava2s  . c o m
}

From source file:it.reply.orchestrator.service.CloudProviderRankerServiceImpl.java

@Override
public List<RankedCloudProvider> getProviderRanking(CloudProviderRankerRequest cloudProviderRankerRequest) {

    HttpEntity<CloudProviderRankerRequest> entity = new HttpEntity<CloudProviderRankerRequest>(
            cloudProviderRankerRequest);

    ResponseEntity<List<RankedCloudProvider>> response = restTemplate.exchange(url, HttpMethod.POST, entity,
            new ParameterizedTypeReference<List<RankedCloudProvider>>() {
            });//from   w  w  w. j  av  a  2 s. c  o m
    if (response.getStatusCode().is2xxSuccessful()) {
        return response.getBody();
    }

    throw new DeploymentException(
            "Error retrieving cloud provider ranking data for request <" + cloudProviderRankerRequest + ">");
}

From source file:org.openwms.common.comm.req.HttpRequestMessageHandler.java

@Override
public Void apply(RequestMessage msg) {
    restTemplate.exchange("http://routing-service/v1/req", HttpMethod.POST,
            new HttpEntity<>(new RequestVO(msg.getActualLocation(), msg.getBarcode())), Void.class);
    return null;//from   w  w w  . ja  v a 2s.  c  om
}

From source file:org.energyos.espi.thirdparty.repository.impl.ResourceRESTRepositoryImpl.java

public IdentifiedObject get(Authorization authorization, String url) {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("Authorization", "Bearer " + authorization.getAccessToken());
    @SuppressWarnings({ "rawtypes", "unchecked" })
    HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);

    HttpEntity<String> response = template.exchange(url, HttpMethod.GET, requestEntity, String.class);

    return (IdentifiedObject) marshaller.unmarshal(new StreamSource(response.getBody()));
}