use of org.opencastproject.mediapackage.Publication in project opencast by opencast.
the class RetractYouTubeWorkflowOperationHandler method start.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(WorkflowInstance, JobContext)
*/
public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException {
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
try {
logger.info("Retracting media package {} from youtube publication channel", mediaPackage);
// Wait for youtube retraction to finish
Job retractJob = publicationService.retract(mediaPackage);
if (!waitForStatus(retractJob).isSuccess())
throw new WorkflowOperationException("The youtube retract job did not complete successfully");
logger.debug("Retraction from youtube operation complete");
// Remove the retracted elements from the mediapackage
Job job = serviceRegistry.getJob(retractJob.getId());
if (job.getPayload() != null) {
logger.info("Removing youtube publication element from media package {}", mediaPackage);
Publication retractedElement = (Publication) MediaPackageElementParser.getFromXml(job.getPayload());
mediaPackage.remove(retractedElement);
logger.debug("Remove youtube publication element '{}' complete", retractedElement);
} else {
logger.info("No youtube publication found to retract in mediapackage {}!", mediaPackage);
return createResult(mediaPackage, Action.CONTINUE);
}
return createResult(mediaPackage, Action.CONTINUE);
} catch (Throwable t) {
throw new WorkflowOperationException(t);
}
}
use of org.opencastproject.mediapackage.Publication in project opencast by opencast.
the class AssetManagerUpdateHandler method execute.
@Override
protected void execute(MessageItem messageItem) {
AssetManagerItem item = (AssetManagerItem) messageItem;
String mpId = item.getId();
try {
logger.debug("Asset Manager message handler START for mp {} event type {} in thread {}", mpId, item.getType(), Thread.currentThread().getId());
switch(item.getType()) {
case Update:
if (item instanceof TakeSnapshot) {
// Check class just in case
TakeSnapshot snapshotItem = (TakeSnapshot) item;
// If no episopde dc, there's nothing to do.
if (snapshotItem.getEpisodeDublincore().isNone())
break;
// notifications, only when getting scheduler notifications
for (Publication pub : snapshotItem.getMediapackage().getPublications()) {
if (LiveScheduleService.CHANNEL_ID.equals(pub.getChannel()))
liveScheduleService.createOrUpdateLiveEvent(mpId, snapshotItem.getEpisodeDublincore().get());
}
}
break;
case Delete:
if (item instanceof DeleteEpisode)
// Episode is being deleted
liveScheduleService.deleteLiveEvent(mpId);
// No action needed when a snapshot is deleted
break;
default:
throw new IllegalArgumentException("Unhandled type of AssetManagerItem");
}
} catch (Exception e) {
logger.warn(String.format("Exception occurred for mp %s, event type %s", mpId, item.getType()), e);
} finally {
logger.debug("Asset Manager message handler END for mp {} event type {} in thread {}", mpId, item.getType(), Thread.currentThread().getId());
}
}
use of org.opencastproject.mediapackage.Publication in project opencast by opencast.
the class LiveScheduleServiceImplTest method testAddLivePublicationChannel.
@Test
public void testAddLivePublicationChannel() throws Exception {
URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp.xml").toURI();
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(mpURI.toURL().openStream());
replayServices();
service.addLivePublicationChannel(org, mp);
Publication[] publications = mp.getPublications();
Assert.assertEquals(1, publications.length);
Assert.assertEquals(LiveScheduleService.CHANNEL_ID, publications[0].getChannel());
Assert.assertEquals("text/html", publications[0].getMimeType().toString());
Assert.assertEquals(ENGAGE_URL + PATH_TO_PLAYER + "?id=" + MP_ID, publications[0].getURI().toString());
}
use of org.opencastproject.mediapackage.Publication in project opencast by opencast.
the class LiveScheduleServiceImplTest method testRemoveLivePublicationChannel.
@Test
public void testRemoveLivePublicationChannel() throws Exception {
URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp-with-live.xml").toURI();
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(mpURI.toURL().openStream());
replayServices();
service.removeLivePublicationChannel(mp);
Publication[] publications = mp.getPublications();
Assert.assertEquals(0, publications.length);
}
use of org.opencastproject.mediapackage.Publication in project opencast by opencast.
the class ToolsEndpoint method createSmilCuttingCatalog.
/**
* Creates a SMIL cutting catalog based on the passed editing information and the media package.
*
* @param editingInfo
* the editing information
* @param mediaPackage
* the media package
* @return a SMIL catalog
* @throws SmilException
* if creating the SMIL catalog failed
*/
Smil createSmilCuttingCatalog(final EditingInfo editingInfo, final MediaPackage mediaPackage) throws SmilException {
// Create initial SMIL catalog
SmilResponse smilResponse = smilService.createNewSmil(mediaPackage);
// Add tracks to the SMIL catalog
ArrayList<Track> tracks = new ArrayList<>();
for (final String trackId : editingInfo.getConcatTracks()) {
Track track = mediaPackage.getTrack(trackId);
if (track == null) {
Opt<Track> trackOpt = getInternalPublication(mediaPackage).toStream().bind(new Fn<Publication, List<Track>>() {
@Override
public List<Track> apply(Publication a) {
return Arrays.asList(a.getTracks());
}
}).filter(new Fn<Track, Boolean>() {
@Override
public Boolean apply(Track a) {
return trackId.equals(a.getIdentifier());
}
}).head();
if (trackOpt.isNone())
throw new IllegalStateException(format("The track '%s' doesn't exist in media package '%s'", trackId, mediaPackage));
track = trackOpt.get();
}
tracks.add(track);
}
for (Tuple<Long, Long> segment : editingInfo.getConcatSegments()) {
smilResponse = smilService.addParallel(smilResponse.getSmil());
final String parentId = smilResponse.getEntity().getId();
final Long duration = segment.getB() - segment.getA();
smilResponse = smilService.addClips(smilResponse.getSmil(), parentId, tracks.toArray(new Track[tracks.size()]), segment.getA(), duration);
}
return smilResponse.getSmil();
}
Aggregations