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

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

Introduction

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

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:com.appglu.impl.SavedQueriesTemplate.java

/**
 * {@inheritDoc}//from w  w  w.  j a v  a  2s . c om
 */
public QueryResult runQuery(String queryName, QueryParams params) throws AppGluRestClientException {
    try {
        return this.restOperations.postForObject(QUERY_RUN_URL, new QueryParamsBody(params), QueryResult.class,
                queryName);
    } catch (RestClientException e) {
        throw new AppGluRestClientException(e.getMessage(), e);
    }
}

From source file:com.appglu.impl.AnalyticsTemplate.java

/**
 * {@inheritDoc}/*from  w  w w  .jav a2  s  .c  om*/
 */
public void uploadSessions(List<AnalyticsSession> sessions) throws AppGluRestClientException {
    try {
        this.restOperations.postForObject(CREATE_SESSION_URL, new AnalyticsSessionsBody(sessions),
                String.class);
    } catch (RestClientException e) {
        throw new AppGluRestClientException(e.getMessage(), e);
    }
}

From source file:net.palacesoft.cngstation.client.loader.CountryLoader.java

@Override
protected List<StationDTO> doInBackground(String... urls) {
    StationDTO[] dtos = new StationDTO[0];
    try {//w  ww . j a  va  2  s .  c  o  m
        dtos = restTemplate.getForObject(urls[0], StationDTO[].class);
    } catch (RestClientException e) {
        Log.e(StationActivity.class.getName(), e.getMessage(), e);
    }
    return asList(dtos);
}

From source file:com.appglu.impl.PushTemplate.java

/**
 * {@inheritDoc}/*  ww w  .ja v  a 2 s.  c  o  m*/
 */
public void registerDevice(Device device) throws AppGluRestClientException {
    try {
        this.restOperations.put(DEVICE_REGISTRATION_URL, new DeviceBody(device));
    } catch (RestClientException e) {
        throw new AppGluRestClientException(e.getMessage(), e);
    }
}

From source file:net.palacesoft.cngstation.client.loader.CityLoader.java

@Override
protected List<String> doInBackground(String... urls) {
    StationDTO[] dtos = new StationDTO[0];
    try {//from   w w w  .ja va  2s  .  com
        dtos = restTemplate.getForObject(urls[0] + "{query}", StationDTO[].class, country);
    } catch (RestClientException e) {
        Log.e(StationActivity.class.getName(), e.getMessage(), e);
    }

    List<String> citiesList = new ArrayList<String>();
    for (StationDTO stationDTO : dtos) {
        citiesList.add(stationDTO.getCity());
    }
    return citiesList;
}

From source file:org.obiba.mica.user.UserProfileService.java

private synchronized Subject getProfileInternal(String serviceUrl) {
    try {//from  w ww .  j  a va2  s. c om
        return executeQuery(serviceUrl, Subject.class);
    } catch (RestClientException e) {
        log.error("Agate connection failure: {}", e.getMessage());
    }

    return null;
}

From source file:org.cloudfoundry.client.lib.rest.LoggingRestTemplate.java

@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
        final ResponseExtractor<T> responseExtractor) throws RestClientException {
    final String[] status = new String[1];
    final HttpStatus[] httpStatus = new HttpStatus[1];
    final Object[] headers = new Object[1];
    final String[] message = new String[1];
    T results = null;/*from   w ww  .ja  v  a  2 s .  c o  m*/
    RestClientException exception = null;
    try {
        results = super.doExecute(url, method, requestCallback, new ResponseExtractor<T>() {
            @SuppressWarnings("rawtypes")
            public T extractData(ClientHttpResponse response) throws IOException {
                httpStatus[0] = response.getStatusCode();
                headers[0] = response.getHeaders();
                T data = null;
                if (responseExtractor != null && (data = responseExtractor.extractData(response)) != null) {
                    if (data instanceof String) {
                        message[0] = ((String) data).length() + " bytes";
                    } else if (data instanceof Map) {
                        message[0] = ((Map) data).keySet().toString();
                    } else {
                        message[0] = data.getClass().getName();
                    }
                    return data;
                } else {
                    message[0] = "<no data>";
                    return null;
                }
            }
        });
        status[0] = "OK";
    } catch (RestClientException e) {
        status[0] = "ERROR";
        message[0] = e.getMessage();
        exception = e;
        if (e instanceof HttpStatusCodeException) {
            httpStatus[0] = ((HttpStatusCodeException) e).getStatusCode();
        }
    }
    addLogMessage(method, url, status[0], httpStatus[0], message[0]);
    if (exception != null) {
        throw exception;
    }
    return results;
}

From source file:com.oneops.amq.plugins.CMSClient.java

/**
 * _get zone ci./*from   ww  w  . ja v  a  2  s .  c  o m*/
 *
 * @param ns the ns
 * @param ciName the ci name
 * @return the cms ci simple
 */
public CmsCISimple _getZoneCi(String ns, String ciName) {

    try {
        CmsCISimple[] cis = restTemplate.getForObject(
                serviceUrl + "cm/simple/cis?nsPath={nsPath}&ciClassName={zoneClass}&ciName={ciName}",
                new CmsCISimple[0].getClass(), ns, zoneClass, ciName);
        if (cis.length > 0) {
            return cis[0];
        }
        ;
        return null;
    } catch (RestClientException ce) {
        logger.error("Broker can not connect to cms api to authenticate the user:" + ce.getMessage());
        throw ce;
    }
}

From source file:com.nbempire.dentalnavarra.dao.impl.RememberDaoImplSpring.java

@Override
public RemembersDTO findRemembers(String patientId) {
    RestTemplate restTemplate = new RestTemplate();

    // Add a JSON converter (use GSON instead of Jackson because is a smaller library)
    restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());

    String urlString = MainKeys.API_HOST + "/patients/" + patientId + "/notifications";
    Log.d(TAG, "Getting resource: " + urlString);

    RemembersDTO response = null;//from  w ww  .ja va2  s .c o m
    URI url = null;
    try {
        url = new URI(urlString);

        response = restTemplate.getForObject(url, RemembersDTO.class);
    } catch (URISyntaxException e) {
        Log.e(TAG, "There was an error creating the URI: " + urlString);
    } catch (RestClientException restClientException) {
        Log.e(TAG, "There was an error getting remembers from URL: " + url);
        Log.e(TAG, restClientException.getMessage());
    }

    return response != null ? response : new RemembersDTO();
}

From source file:org.obiba.mica.user.UserProfileService.java

public synchronized List<Subject> getProfilesByApplication(@NotNull String application,
        @Nullable String group) {

    Assert.notNull(application, "Application name cannot be null");

    try {//www  . ja  v a  2s . c  om

        String profileServiceUrl = getProfileServiceUrlByApp(null, application, group);
        return Arrays.asList(executeQuery(profileServiceUrl, Subject[].class));

    } catch (RestClientException e) {
        log.error("Agate connection failure: {}", e.getMessage());
    }

    return Lists.newArrayList();
}