Search in sources :

Example 1 with RestServiceException

use of org.craftercms.commons.rest.RestServiceException in project profile by craftercms.

the class AbstractProfileRestClientBase method doPostForUpload.

protected <T> T doPostForUpload(String url, MultiValueMap<String, Object> request, Class<T> responseType, Object... uriVariables) throws ProfileException {
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(request, headers);
        return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables).getBody();
    } catch (RestServiceException e) {
        handleRestServiceException(e);
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
Also used : RestServiceException(org.craftercms.commons.rest.RestServiceException) ProfileRestServiceException(org.craftercms.profile.exceptions.ProfileRestServiceException) HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) RestServiceException(org.craftercms.commons.rest.RestServiceException) ProfileException(org.craftercms.profile.api.exceptions.ProfileException) ProfileRestServiceException(org.craftercms.profile.exceptions.ProfileRestServiceException)

Aggregations

RestServiceException (org.craftercms.commons.rest.RestServiceException)1 ProfileException (org.craftercms.profile.api.exceptions.ProfileException)1 ProfileRestServiceException (org.craftercms.profile.exceptions.ProfileRestServiceException)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1 MultiValueMap (org.springframework.util.MultiValueMap)1