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