List of usage examples for org.springframework.web.client HttpClientErrorException getResponseBodyAsString
public String getResponseBodyAsString()
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Sets whether or not your account should be in the limited integration mode. * Use 'true' to make your account limited to integration mode. * Use 'false' to make your account a regular account. * * @see https://app.zencoder.com/docs/api/accounts/integration * @param integration_mode Integration Mode setting. * @throws ZencoderClientException /*ww w .j a v a 2s. c om*/ */ public void setAccountIntegrationMode(boolean integration_mode) throws ZencoderClientException { String url = null; if (integration_mode) { url = api_url + "/account/integration"; } else { url = api_url + "/account/live"; } HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); try { rt.exchange(url, HttpMethod.PUT, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets details about an existing VOD transcode job. * //from ww w. ja v a 2s.com * @see https://app.zencoder.com/docs/api/jobs/show * @param id * @return * @throws ZencoderClientException */ public ZencoderJobDetail getZencoderJob(String id) throws ZencoderClientException { String url = api_url + "/jobs/" + id + ".json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderJobDetailResponse job_details = null; try { job_details = mapper.readValue(response.getBody(), ZencoderJobDetailResponse.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderCreateJobResponse as JSON", e); } return job_details.getJob(); }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets progress information about an existing VOD transcode job. * /* ww w .j a v a 2 s. co m*/ * @see https://app.zencoder.com/docs/api/jobs/progress * @param id * @return * @throws ZencoderClientException */ public ZencoderJobProgress getJobProgress(String id) throws ZencoderClientException { String url = api_url + "/jobs/" + id + "/progress.json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderJobProgress job_progress = null; try { job_progress = mapper.readValue(response.getBody(), ZencoderJobProgress.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderCreateJobResponse as JSON", e); } return job_progress; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets progress information about an existing VOD transcode input. * //from w w w.j av a 2s . co m * @see https://app.zencoder.com/docs/api/inputs/progress * @param id * @return * @throws ZencoderClientException */ public ZencoderInputOutputProgress getInputProgress(String id) throws ZencoderClientException { String url = api_url + "/inputs/" + id + "/progress.json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderInputOutputProgress input_progress = null; try { input_progress = mapper.readValue(response.getBody(), ZencoderInputOutputProgress.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderInputOutputProgress as JSON", e); } return input_progress; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets progress information about an existing VOD transcode output. * /*from w w w.ja va2 s .c o m*/ * @see https://app.zencoder.com/docs/api/outputs/progress * @param id * @return * @throws ZencoderClientException */ public ZencoderInputOutputProgress getOutputProgress(String id) throws ZencoderClientException { String url = api_url + "/outputs/" + id + "/progress.json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderInputOutputProgress output_progress = null; try { output_progress = mapper.readValue(response.getBody(), ZencoderInputOutputProgress.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderInputOutputProgress as JSON", e); } return output_progress; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets the details of a given input./*from ww w.j a v a2 s . c o m*/ * * @param id * @return * @throws ZencoderClientException */ public ZencoderMediaFile getInputDetails(String id) throws ZencoderClientException { String url = api_url + "/inputs/" + id + ".json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderMediaFile input_details = null; try { input_details = mapper.readValue(response.getBody(), ZencoderMediaFile.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderMediaFile as JSON", e); } return input_details; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Gets the details of a given output.//w w w . j ava 2 s .co m * * @see https://app.zencoder.com/docs/api/outputs/show * @param id * @return * @throws ZencoderClientException */ public ZencoderMediaFile getOutputDetails(String id) throws ZencoderClientException { String url = api_url + "/outputs/" + id + ".json"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderMediaFile output_details = null; try { output_details = mapper.readValue(response.getBody(), ZencoderMediaFile.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderMediaFile as JSON", e); } return output_details; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * Retrieve your Zencoder Account Details * * @see https://app.zencoder.com/docs/api/accounts/show * @return The status and billing details for this account. * @throws ZencoderClientException/*from w w w .j a va 2 s .c om*/ */ public ZencoderAccountDetails getAccountDetails() throws ZencoderClientException { String url = api_url + "/account"; HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderAccountDetails account_details = null; try { account_details = mapper.readValue(response.getBody(), ZencoderAccountDetails.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderAccountDetails as JSON", e); } return account_details; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * The VOD usage for the specified time period. * * NOTE: It's important to note that our service operates in the UTC time zone * (including billing periods). All dates and times reported will be in UTC. * * @see https://app.zencoder.com/docs/api/reports/vod * @see https://app.zencoder.com/docs/api/encoding/job/grouping * @param from//w w w. j ava 2 s . c om * (optional) Start date (default: 30 days ago). * @param to * (optional) End date (default: yesterday). * @param grouping * (optional) Minute usage for only one report grouping (default: none). * @return The VOD usage for the specified time period. * @throws ZencoderClientException */ public ZencoderVodUsage getUsageForVod(Date from, Date to, String grouping) throws ZencoderClientException { String url = api_url + "/reports/vod" + createUsageQueryArgString(from, to, grouping); HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderVodUsage usage = null; try { usage = mapper.readValue(response.getBody(), ZencoderVodUsage.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderVodUsage as JSON", e); } return usage; }
From source file:com.brightcove.zencoder.client.ZencoderClient.java
/** * The Live usage for the specified time period. * * NOTE: It's important to note that our service operates in the UTC time zone * (including billing periods). All dates and times reported will be in UTC. * * @see https://app.zencoder.com/docs/api/reports/live * @see https://app.zencoder.com/docs/api/encoding/job/grouping * @param from/*from ww w .java 2s .c o m*/ * (optional) Start date (default: 30 days ago). * @param to * (optional) End date (default: yesterday). * @param grouping * (optional) Minute usage for only one report grouping (default: none). * @return The Live usage for the specified time period. * @throws ZencoderClientException */ public ZencoderLiveUsage getUsageForLive(Date from, Date to, String grouping) throws ZencoderClientException { String url = api_url + "/reports/live" + createUsageQueryArgString(from, to, grouping); HttpHeaders headers = getHeaders(); @SuppressWarnings("rawtypes") HttpEntity entity = new HttpEntity<String>("", headers); ResponseEntity<String> response = null; try { response = rt.exchange(url, HttpMethod.GET, entity, String.class, new HashMap<String, Object>()); } catch (HttpClientErrorException hcee) { throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee); } ZencoderLiveUsage usage = null; try { usage = mapper.readValue(response.getBody(), ZencoderLiveUsage.class); } catch (Exception e) { throw new ZencoderClientException("Unable to deserialize ZencoderLiveUsage as JSON", e); } return usage; }