Package de.bitzeche.video.transcoding.zencoder.response

Examples of de.bitzeche.video.transcoding.zencoder.response.ZencoderErrorResponseException


      throws ZencoderErrorResponseException {
    if(currentConnectionAttempt > MAX_CONNECTION_ATTEMPTS) {
      resetConnectionCount();
      String message = "Reached maximum number of connection attempts for Zencoder, aborting creation of job";
      Document errorDocument = createDocumentForException(message);
      throw new ZencoderErrorResponseException(errorDocument);
    }
    Document data;
    try {
      data = job.createXML();
      if (data == null) {
        String message = "Got no XML from Job";
        LOGGER.error(message);
        resetConnectionCount();
        Document errorDocument = createDocumentForException(message);
        throw new ZencoderErrorResponseException(errorDocument);
      }
      Element apikey = data.createElement("api_key");
      apikey.setTextContent(zencoderAPIKey);
      data.getDocumentElement().appendChild(apikey);
      Document response = sendPostRequest(zencoderAPIBaseUrl
          + "jobs?format=xml", data);
      // a null response means the call did not get through
      // we should try again, since the job has not been started
      if(response == null) {
        currentConnectionAttempt++;
        // maybe delay this call by a few seconds?
        return createJob(job);
      }
      String id = (String) xPath.evaluate("/api-response/job/id",
          response, XPathConstants.STRING);
      if (StringUtils.isNotEmpty(id)) {
        job.setJobId(Integer.parseInt(id));
        resetConnectionCount();
        return response;
      }
      completeJobInfo(job, response);
      LOGGER.error("Error when sending request to Zencoder: ", response);
      resetConnectionCount();
      throw new ZencoderErrorResponseException(response);
    } catch (ParserConfigurationException e) {
      LOGGER.error("Parser threw Exception", e);
    } catch (XPathExpressionException e) {
      LOGGER.error("XPath threw Exception", e);
    }
View Full Code Here

TOP

Related Classes of de.bitzeche.video.transcoding.zencoder.response.ZencoderErrorResponseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.