Search in sources :

Example 1 with TakeSnapshot

use of org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot in project opencast by opencast.

the class AssetManagerMessageReceiverImplTest method testUpdateCreator.

@Test
public void testUpdateCreator() throws Exception {
    MediaPackage mediaPackage = new MediaPackageBuilderImpl().loadFromXml(getClass().getResourceAsStream("/jobs_mediapackage1.xml"));
    TakeSnapshot takeSnapshot = AssetManagerItem.add(workspace, mediaPackage, new AccessControlList(), 0, new Date());
    // Test initial set of creator
    assetManager.execute(takeSnapshot);
    Event event = index.getEventResult();
    assertNotNull(event);
    assertEquals("Current user is expected to be creator as no other creator has been set explicitly", "Creator", event.getCreator());
    // Test updating creator
    event.setCreator("Hans");
    index.setInitialEvent(event);
    assetManager.execute(takeSnapshot);
    event = index.getEventResult();
    assertNotNull(event);
    assertEquals("Creator has been updated", "Hans", event.getCreator());
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) TakeSnapshot(org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot) MediaPackageBuilderImpl(org.opencastproject.mediapackage.MediaPackageBuilderImpl) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Event(org.opencastproject.index.service.impl.index.event.Event) Date(java.util.Date) Test(org.junit.Test)

Example 2 with TakeSnapshot

use of org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot in project opencast by opencast.

the class AssetManagerWithMessaging method takeSnapshot.

@Override
public Snapshot takeSnapshot(String owner, MediaPackage mp) {
    final Snapshot snapshot = super.takeSnapshot(owner, mp);
    notifyTakeSnapshot(snapshot);
    return snapshot;
}
Also used : TakeSnapshot(org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot) Snapshot(org.opencastproject.assetmanager.api.Snapshot)

Example 3 with TakeSnapshot

use of org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot 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

TakeSnapshot (org.opencastproject.message.broker.api.assetmanager.AssetManagerItem.TakeSnapshot)3 Date (java.util.Date)1 Test (org.junit.Test)1 Snapshot (org.opencastproject.assetmanager.api.Snapshot)1 Event (org.opencastproject.index.service.impl.index.event.Event)1 MediaPackage (org.opencastproject.mediapackage.MediaPackage)1 MediaPackageBuilderImpl (org.opencastproject.mediapackage.MediaPackageBuilderImpl)1 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 AccessControlList (org.opencastproject.security.api.AccessControlList)1