Search in sources :

Example 1 with DeleteEpisode

use of org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.DeleteEpisode 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());
    }
}
Also used : TakeSnapshot(org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot) AssetManagerItem(org.opencastproject.message.broker.api.assetmanager.AssetManagerItem) Publication(org.opencastproject.mediapackage.Publication) DeleteEpisode(org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.DeleteEpisode)

Aggregations

Publication (org.opencastproject.mediapackage.Publication)1 AssetManagerItem (org.opencastproject.message.broker.api.assetmanager.AssetManagerItem)1 DeleteEpisode (org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.DeleteEpisode)1 TakeSnapshot (org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot)1