Example usage for org.springframework.web.client RestTemplate getMessageConverters

List of usage examples for org.springframework.web.client RestTemplate getMessageConverters

Introduction

In this page you can find the example usage for org.springframework.web.client RestTemplate getMessageConverters.

Prototype

public List<HttpMessageConverter<?>> getMessageConverters() 

Source Link

Document

Return the list of message body converters.

Usage

From source file:uy.edu.ort.fachada.FachadaOperaciones.java

public static void listarTrazas() {
    String url = ManejoPropiedades.obtenerInstancia().obtenerPropiedad("restService") + "resttrace/all.htm";

    RestTemplate restTemplate1 = new RestTemplate();
    restTemplate1.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate1.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    Trace[] trazas = null;/* w  w  w . ja  va2 s  .co m*/
    try {
        trazas = restTemplate1.getForObject(url, Trace[].class);
    } catch (Exception e) {
        System.out.println(e.getStackTrace().toString());
    }

    System.out.println("\tFecha \t\tDescripcion");
    for (Trace t : trazas) {
        String fechaString = new SimpleDateFormat("dd-MM-yyyy").format(t.getFecha());
        System.out.println("\t" + fechaString + "\t\t" + t.getDescripcion());
    }
}

From source file:uy.edu.ort.fachada.FachadaOperaciones.java

/**
 * Operaciones sobre la Entidad Arribo/* w  w w  .j  ava  2s . c om*/
 */

public static void generarReporteArribosMes(String mes) {
    String url = ManejoPropiedades.obtenerInstancia().obtenerPropiedad("restService")
            + "restarribo/arribos.htm?mes=" + mes;

    RestTemplate restTemplate1 = new RestTemplate();
    restTemplate1.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate1.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    Arribo[] arribosResultado = restTemplate1.getForObject(url, Arribo[].class);
    System.out.println("\tId \t\tOrigen \t\tFecha \t\tDescripcion \t\tBarco \t\tContenedores");
    for (Arribo arribo : arribosResultado) {
        String fechaString = new SimpleDateFormat("dd-MM-yyyy").format(arribo.getFecha());
        String codigoConts = "";
        for (Object c : arribo.getContenedores()) {
            codigoConts += " - " + ((LinkedHashMap) c).get("codigo");
        }
        codigoConts += " - ";
        System.out.println("\t" + arribo.getId() + "\t\t" + arribo.getOrigen() + " \t\t" + fechaString + " \t\t"
                + arribo.getDescripcion() + " \t\t" + arribo.getBarco().getCodigo() + " \t\t" + codigoConts);

    }
}

From source file:uy.edu.ort.fachada.FachadaOperaciones.java

/**
 * Operaciones sobre la Entidad Partida/*from   ww  w . j a v  a 2 s.co m*/
 */

public static void generarReportePartidasMes(String mes) {
    String url = ManejoPropiedades.obtenerInstancia().obtenerPropiedad("restService")
            + "restpartida/partidas.htm?mes=" + mes;

    RestTemplate restTemplate1 = new RestTemplate();
    restTemplate1.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate1.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    Partida[] partidasResultado = restTemplate1.getForObject(url, Partida[].class);
    System.out.println("\tId \t\tDestino \t\tFecha \t\tDescripcion \t\tBarco \t\tContenedores");
    for (Partida partida : partidasResultado) {
        String fechaString = new SimpleDateFormat("dd-MM-yyyy").format(partida.getFecha());
        String codigoConts = "";
        for (Object c : partida.getContenedores()) {
            codigoConts += " - " + ((LinkedHashMap) c).get("codigo");
        }
        codigoConts += " - ";
        System.out.println("\t" + partida.getId() + "\t\t" + partida.getDestino() + " \t\t" + fechaString
                + " \t\t" + partida.getDescripcion() + " \t\t" + partida.getBarco().getCodigo() + " \t\t"
                + codigoConts);

    }
}

From source file:uy.edu.ort.fachada.FachadaOperaciones.java

public static void generarReporteArribosMesBarco(String mes, String idBarco) {
    String url = ManejoPropiedades.obtenerInstancia().obtenerPropiedad("restService")
            + "restarribo/arribos.htm?mes=" + mes + "&idBarco=" + idBarco;

    RestTemplate restTemplate1 = new RestTemplate();
    restTemplate1.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate1.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    Arribo[] arribosResultado = restTemplate1.getForObject(url, Arribo[].class);
    System.out.println("\tId \t\tOrigen \t\tFecha \t\tDescripcion \t\tBarco \t\tContenedores \t\tPeso Total");
    for (Arribo arribo : arribosResultado) {
        String fechaString = new SimpleDateFormat("dd-MM-yyyy").format(arribo.getFecha());
        String codigoConts = "";
        int peso = 0;
        for (Object c : arribo.getContenedores()) {
            codigoConts += " - " + ((LinkedHashMap) c).get("codigo");
            Object capacidad = ((LinkedHashMap) c).get("capacidad");
            peso += (Integer) capacidad;
        }//from w  w w . j  a v  a2 s.co  m
        codigoConts += " - ";
        System.out.println("\t" + arribo.getId() + "\t\t" + arribo.getOrigen() + " \t\t" + fechaString + " \t\t"
                + arribo.getDescripcion() + " \t\t" + arribo.getBarco().getCodigo() + " \t\t" + codigoConts
                + " \t\t" + peso);

    }
}

From source file:uy.edu.ort.fachada.FachadaOperaciones.java

public static void generarReportePartidasMesBarco(String mes, String idBarco) {
    String url = ManejoPropiedades.obtenerInstancia().obtenerPropiedad("restService")
            + "restpartida/partidas.htm?mes=" + mes + "&idBarco=" + idBarco;

    RestTemplate restTemplate1 = new RestTemplate();
    restTemplate1.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate1.getMessageConverters().add(new MappingJacksonHttpMessageConverter());

    Partida[] partidasResultado = restTemplate1.getForObject(url, Partida[].class);
    System.out.println("\tId \t\tDestino \t\tFecha \t\tDescripcion \t\tBarco \t\tContenedores \t\tPeso Total");
    for (Partida partida : partidasResultado) {
        String fechaString = new SimpleDateFormat("dd-MM-yyyy").format(partida.getFecha());
        String codigoConts = "";
        int peso = 0;
        for (Object c : partida.getContenedores()) {
            codigoConts += " - " + ((LinkedHashMap) c).get("codigo");
            Object capacidad = ((LinkedHashMap) c).get("capacidad");
            peso += (Integer) capacidad;
        }//  ww w  . j  a  va  2 s  .  c o m
        codigoConts += " - ";
        System.out.println("\t" + partida.getId() + "\t\t" + partida.getDestino() + " \t\t" + fechaString
                + " \t\t" + partida.getDescripcion() + " \t\t" + partida.getBarco().getCodigo() + " \t\t"
                + codigoConts + " \t\t" + peso);

    }
}

From source file:com.gooddata.GoodData.java

static RestTemplate createRestTemplate(GoodDataEndpoint endpoint, HttpClient httpClient) {
    notNull(endpoint, "endpoint");
    notNull(httpClient, "httpClient");

    final UriPrefixingClientHttpRequestFactory factory = new UriPrefixingClientHttpRequestFactory(
            new HttpComponentsClientHttpRequestFactory(httpClient), endpoint.toUri());
    final RestTemplate restTemplate = new RestTemplate(factory);
    restTemplate.setInterceptors(//from  w  w  w  .j a  va  2 s . c  om
            Arrays.asList(new HeaderSettingRequestInterceptor(singletonMap("Accept", getAcceptHeaderValue()))));

    restTemplate.setErrorHandler(new ResponseErrorHandler(restTemplate.getMessageConverters()));

    return restTemplate;
}

From source file:fi.helsinki.opintoni.config.PageMetadataConfiguration.java

@Bean
public RestTemplate metaDataRestTemplate() {
    RestTemplate template = new RestTemplate();
    template.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
    return template;
}

From source file:cr.ac.siua.tec.config.RestTemplateConfig.java

@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory httpRequestFactory) {
    RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    return restTemplate;
}

From source file:com.vinidsl.googleioextended.rest.BaseRequest.java

/**
 * Method that creates the restTemplate instance
 * @return a restTemplate instance to be used for the request.
 *//*from   w w  w.  j  a v a2s  . c  o m*/
public RestTemplate getRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    return restTemplate;
}

From source file:net.eledge.android.europeana.search.task.RecordTask.java

@Override
protected RecordObject doInBackground(String... params) {
    if (TextUtils.isEmpty(params[0])) {
        return null;
    }//from  w w  w.j  a v a  2  s  .c o  m
    recordId = params[0];
    String url = UriHelper.getRecordUrl(
            ((EuropeanaApplication) mActivity.getApplication()).getEuropeanaPublicKey(), recordId);
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
    return RecordObject.normalize(restTemplate.getForObject(url, Record.class).object);
}