Example usage for org.springframework.web.client RestClientException toString

List of usage examples for org.springframework.web.client RestClientException toString

Introduction

In this page you can find the example usage for org.springframework.web.client RestClientException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.atwelm.aezwidget.data.ConfigurationServer.java

/**
 * Loads the layouts from the server and provides them in the callback if provided
 * @param callback Contains the layouts or error information
 *//*from  w  ww . j av  a  2 s .  c o m*/
public void loadLayouts(final LoadLayoutCallback callback) {
    final ConfigurationServer self = this;
    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                RestTemplate restTemplate = new RestTemplate();
                restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());

                ResponseEntity<AEZFetchLayoutResponseInterface> responseEntity = restTemplate
                        .getForEntity(mServerAddress, mServerType.getResponseClass());

                int returnStatus = responseEntity.getStatusCode().value();

                if (returnStatus <= 200 && returnStatus < 300) {
                    AEZFetchLayoutResponseInterface response = responseEntity.getBody();

                    List<AEZLayout> receivedLayouts = response.getLayouts();

                    callback.success(receivedLayouts);

                } else {
                    callback.failure(returnStatus, null);
                }

            } catch (HttpStatusCodeException rsce) {
                Log.e(LOG_IDENTIFIER, rsce.toString());
                callback.failure(rsce.getStatusCode().value(), rsce.toString());

            } catch (RestClientException rce) {
                Log.e(LOG_IDENTIFIER, rce.toString());
                callback.failure(-1, rce.toString());
            }
        }
    });
    t.start();
}