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());
}
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;
}
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;
}
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());
}
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());
}
Aggregations