Search in sources :

Example 16 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class DownloadDistributionServiceImplTest method testPartialDistribution.

@Test
public void testPartialDistribution() throws Exception {
    // Distribute only some of the elements in the mediapackage
    Job job1 = service.distribute("engage-player", mp, "track-1");
    Job job2 = service.distribute("engage-player", mp, "catalog-1");
    Job job3 = service.distribute("oai-pmh", mp, "catalog-1");
    JobBarrier jobBarrier = new JobBarrier(null, serviceRegistry, 500, job1, job2, job3);
    jobBarrier.waitForJobs();
    File mpDir = new File(distributionRoot, PathSupport.path(defaultOrganization.getId(), "engage-player", mp.getIdentifier().compact()));
    Assert.assertTrue(mpDir.exists());
    File mediaDir = new File(mpDir, "track-1");
    File metadataDir = new File(mpDir, "catalog-1");
    File attachmentsDir = new File(mpDir, "notes");
    Assert.assertTrue(mediaDir.exists());
    Assert.assertTrue(metadataDir.exists());
    Assert.assertFalse(attachmentsDir.exists());
    // the filenames are changed to reflect the element ID
    Assert.assertTrue(new File(mediaDir, "media.mov").exists());
    Assert.assertTrue(new File(metadataDir, "dublincore.xml").exists());
    Assert.assertFalse(new File(metadataDir, "mpeg7.xml").exists());
    Assert.assertFalse(new File(attachmentsDir, "attachment.txt").exists());
}
Also used : Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) File(java.io.File) Test(org.junit.Test)

Example 17 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class SeriesUpdatedEventHandler method updateEpisodeCatalog.

private boolean updateEpisodeCatalog(MediaPackage mp) throws DistributionException, MediaPackageException, NotFoundException, ServiceRegistryException, IllegalArgumentException, IOException {
    // Update the episode catalog
    for (Catalog episodeCatalog : mp.getCatalogs(MediaPackageElements.EPISODE)) {
        DublinCoreCatalog episodeDublinCore = DublinCoreUtil.loadDublinCore(workspace, episodeCatalog);
        episodeDublinCore.remove(DublinCore.PROPERTY_IS_PART_OF);
        String filename = FilenameUtils.getName(episodeCatalog.getURI().toString());
        URI uri = workspace.put(mp.getIdentifier().toString(), episodeCatalog.getIdentifier(), filename, dublinCoreService.serialize(episodeDublinCore));
        episodeCatalog.setURI(uri);
        // setting the URI to a new source so the checksum will most like be invalid
        episodeCatalog.setChecksum(null);
        // Distribute the updated episode dublincore
        Job distributionJob = distributionService.distribute(CHANNEL_ID, mp, episodeCatalog.getIdentifier());
        JobBarrier barrier = new JobBarrier(null, serviceRegistry, distributionJob);
        Result jobResult = barrier.waitForJobs();
        if (jobResult.getStatus().get(distributionJob).equals(FINISHED)) {
            mp.remove(episodeCatalog);
            mp.add(getFromXml(serviceRegistry.getJob(distributionJob.getId()).getPayload()));
        } else {
            logger.error("Unable to distribute episode catalog {}", episodeCatalog.getIdentifier());
            return false;
        }
    }
    return true;
}
Also used : DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Job(org.opencastproject.job.api.Job) URI(java.net.URI) JobBarrier(org.opencastproject.job.api.JobBarrier) Catalog(org.opencastproject.mediapackage.Catalog) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Result(org.opencastproject.job.api.JobBarrier.Result) SearchResult(org.opencastproject.search.api.SearchResult)

Example 18 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class ComposerServiceImpl method inspect.

protected Job inspect(Job job, URI workspaceURI) throws EncoderException {
    Job inspectionJob;
    try {
        inspectionJob = inspectionService.inspect(workspaceURI);
    } catch (MediaInspectionException e) {
        incident().recordJobCreationIncident(job, e);
        throw new EncoderException("Media inspection of " + workspaceURI + " failed", e);
    }
    JobBarrier barrier = new JobBarrier(job, serviceRegistry, inspectionJob);
    if (!barrier.waitForJobs().isSuccess()) {
        throw new EncoderException("Media inspection of " + workspaceURI + " failed");
    }
    return inspectionJob;
}
Also used : EncoderException(org.opencastproject.composer.api.EncoderException) MediaInspectionException(org.opencastproject.inspection.api.MediaInspectionException) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier)

Example 19 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class SearchServiceImplTest method testAddSeriesMediaPackage.

/**
 * Adds a media package with a dublin core catalog for episode and series. Verifies series catalog can be retrieved
 * via search service.
 */
@Test
public void testAddSeriesMediaPackage() throws Exception {
    String seriesId = "foobar-series";
    MediaPackage mediaPackage = getMediaPackage("/manifest-full.xml");
    mediaPackage.setSeries(seriesId);
    // Add the media package to the search index
    Job job = service.add(mediaPackage);
    JobBarrier barrier = new JobBarrier(null, serviceRegistry, 1000, job);
    barrier.waitForJobs();
    assertEquals("Job to add mediapckage did not finish", Job.Status.FINISHED, job.getStatus());
    User adminUser = new JaxbUser("admin", "test", defaultOrganization, new JaxbRole(defaultOrganization.getAdminRole(), defaultOrganization));
    userResponder.setResponse(adminUser);
    // Make sure it's properly indexed and returned
    SearchQuery q = new SearchQuery();
    q.includeEpisodes(false);
    q.includeSeries(true);
    SearchResult result = service.getByQuery(q);
    assertEquals(1, result.size());
    assertEquals(seriesId, result.getItems()[0].getId());
}
Also used : SearchQuery(org.opencastproject.search.api.SearchQuery) User(org.opencastproject.security.api.User) JaxbUser(org.opencastproject.security.api.JaxbUser) JaxbRole(org.opencastproject.security.api.JaxbRole) MediaPackage(org.opencastproject.mediapackage.MediaPackage) JaxbUser(org.opencastproject.security.api.JaxbUser) SearchResult(org.opencastproject.search.api.SearchResult) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Test(org.junit.Test)

Example 20 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class SearchServiceImplTest method testAddFullMediaPackage.

/**
 * Ads a simple media package that has a dublin core for the episode only.
 */
@Test
public void testAddFullMediaPackage() throws Exception {
    MediaPackage mediaPackage = getMediaPackage("/manifest-full.xml");
    // Make sure our mocked ACL has the read and write permission
    acl.getEntries().add(new AccessControlEntry(ROLE_STUDENT, READ.toString(), true));
    acl.getEntries().add(new AccessControlEntry(ROLE_STUDENT, WRITE.toString(), true));
    // Add the media package to the search index
    Job job = service.add(mediaPackage);
    JobBarrier barrier = new JobBarrier(null, serviceRegistry, 1000, job);
    barrier.waitForJobs();
    assertEquals("Job to add mediapckage did not finish", Job.Status.FINISHED, job.getStatus());
    // Make sure it's properly indexed and returned
    SearchQuery q = new SearchQuery();
    q.includeEpisodes(true);
    q.includeSeries(false);
    q.withId("10.0000/2");
    assertEquals(1, service.getByQuery(q).size());
    // Clear the ID requirement
    q.withId(null);
    assertEquals(1, service.getByQuery(q).size());
}
Also used : SearchQuery(org.opencastproject.search.api.SearchQuery) MediaPackage(org.opencastproject.mediapackage.MediaPackage) AccessControlEntry(org.opencastproject.security.api.AccessControlEntry) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Test(org.junit.Test)

Aggregations

Job (org.opencastproject.job.api.Job)30 JobBarrier (org.opencastproject.job.api.JobBarrier)30 Test (org.junit.Test)24 MediaPackage (org.opencastproject.mediapackage.MediaPackage)11 SearchQuery (org.opencastproject.search.api.SearchQuery)10 NotFoundException (org.opencastproject.util.NotFoundException)7 Catalog (org.opencastproject.mediapackage.Catalog)6 SearchResult (org.opencastproject.search.api.SearchResult)6 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)6 PropertyVetoException (java.beans.PropertyVetoException)5 File (java.io.File)5 Hashtable (java.util.Hashtable)5 AccessControlEntry (org.opencastproject.security.api.AccessControlEntry)5 TrustedHttpClientException (org.opencastproject.security.api.TrustedHttpClientException)5 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 MediaInspectionException (org.opencastproject.inspection.api.MediaInspectionException)3 Result (org.opencastproject.job.api.JobBarrier.Result)3 AudioStream (org.opencastproject.mediapackage.AudioStream)3