Search in sources :

Example 6 with ProcessFailedException

use of org.opencastproject.videoeditor.api.ProcessFailedException in project opencast by opencast.

the class VideoEditorServiceRemote method processSmil.

@Override
public List<Job> processSmil(Smil smil) throws ProcessFailedException {
    HttpPost post = new HttpPost("/process-smil");
    List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    try {
        params.add(new BasicNameValuePair("smil", smil.toXML()));
        post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
    } catch (Exception e) {
        throw new ProcessFailedException("Unable to assemble a remote videoeditor request for smil " + smil.getId());
    }
    HttpResponse response = null;
    try {
        response = getResponse(post);
        if (response != null) {
            String entity = EntityUtils.toString(response.getEntity());
            if (StringUtils.isNotEmpty(entity)) {
                List<Job> jobs = new LinkedList<Job>();
                for (JaxbJob job : JobParser.parseJobList(entity).getJobs()) {
                    jobs.add(job.toJob());
                }
                logger.info("Start proccessing smil '{}' on remote videoeditor service", smil.getId());
                return jobs;
            }
        }
    } catch (Exception e) {
        throw new ProcessFailedException("Unable to proccess smil " + smil.getId() + " using a remote videoeditor service", e);
    } finally {
        closeConnection(response);
    }
    throw new ProcessFailedException("Unable to proccess smil " + smil.getId() + " using a remote videoeditor service.");
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) JaxbJob(org.opencastproject.job.api.JaxbJob) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) ProcessFailedException(org.opencastproject.videoeditor.api.ProcessFailedException) LinkedList(java.util.LinkedList) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ProcessFailedException(org.opencastproject.videoeditor.api.ProcessFailedException) JaxbJob(org.opencastproject.job.api.JaxbJob) Job(org.opencastproject.job.api.Job)

Aggregations

ProcessFailedException (org.opencastproject.videoeditor.api.ProcessFailedException)6 Job (org.opencastproject.job.api.Job)5 File (java.io.File)3 InputStream (java.io.InputStream)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 MediaInspectionException (org.opencastproject.inspection.api.MediaInspectionException)3 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)3 Track (org.opencastproject.mediapackage.Track)3 IOException (java.io.IOException)2 JAXBException (javax.xml.bind.JAXBException)2 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)2 SmilException (org.opencastproject.smil.api.SmilException)2 Smil (org.opencastproject.smil.entity.api.Smil)2 SmilMediaObject (org.opencastproject.smil.entity.media.api.SmilMediaObject)2 SmilMediaContainer (org.opencastproject.smil.entity.media.container.api.SmilMediaContainer)2 SmilMediaElement (org.opencastproject.smil.entity.media.element.api.SmilMediaElement)2 NotFoundException (org.opencastproject.util.NotFoundException)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1