use of org.opencastproject.message.broker.api.scheduler.SchedulerItem in project opencast by opencast.
the class SchedulerMessageReceiverImplTest method testUpdateCreator.
@Test
public void testUpdateCreator() throws Exception {
DublinCoreCatalog catalog = DublinCores.read(getClass().getResourceAsStream("/dublincore.xml"));
SchedulerItem schedulerItem = SchedulerItem.updateCatalog("uuid", catalog);
// Test initial set of creator
scheduler.execute(schedulerItem);
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);
scheduler.execute(schedulerItem);
event = index.getEventResult();
assertNotNull(event);
assertEquals("Creator has been updated", "Hans", event.getCreator());
}
use of org.opencastproject.message.broker.api.scheduler.SchedulerItem in project opencast by opencast.
the class SchedulerUpdateHandler method execute.
@Override
protected void execute(MessageItem messageItem) {
SchedulerItem schedulerItem = (SchedulerItem) messageItem;
String mpId = schedulerItem.getMediaPackageId();
try {
logger.debug("Scheduler message handler START for mp {} event type {} in thread {}", mpId, schedulerItem.getType(), Thread.currentThread().getId());
switch(schedulerItem.getType()) {
case UpdateCatalog:
if (isLive(mpId))
liveScheduleService.createOrUpdateLiveEvent(mpId, schedulerItem.getEvent());
break;
case UpdateAcl:
if (isLive(mpId))
liveScheduleService.updateLiveEventAcl(mpId, schedulerItem.getAcl());
break;
case UpdateProperties:
// Workflow properties may have been updated (publishLive configuration)
String publishLive = schedulerItem.getProperties().get(PUBLISH_LIVE_PROPERTY);
if (publishLive == null)
// Not specified so we do nothing. We don't want to delete if we got incomplete props.
return;
else if (BooleanUtils.toBoolean(publishLive)) {
DublinCoreCatalog episodeDC = schedulerService.getDublinCore(mpId);
liveScheduleService.createOrUpdateLiveEvent(mpId, episodeDC);
} else
liveScheduleService.deleteLiveEvent(mpId);
break;
case Delete:
case DeleteRecordingStatus:
if (isLive(mpId))
liveScheduleService.deleteLiveEvent(mpId);
break;
case UpdateAgentId:
case UpdateStart:
case UpdateEnd:
if (isLive(mpId)) {
DublinCoreCatalog episodeDC = schedulerService.getDublinCore(mpId);
liveScheduleService.createOrUpdateLiveEvent(mpId, episodeDC);
}
break;
case UpdateRecordingStatus:
String state = schedulerItem.getRecordingState();
if (RecordingState.CAPTURE_FINISHED.equals(state) || RecordingState.UPLOADING.equals(state) || RecordingState.UPLOADING.equals(state) || RecordingState.CAPTURE_ERROR.equals(state) || RecordingState.UPLOAD_ERROR.equals(state))
if (isLive(mpId))
liveScheduleService.deleteLiveEvent(mpId);
break;
case UpdateOptOut:
case UpdateBlacklist:
case UpdatePresenters:
case UpdateReviewStatus:
break;
default:
throw new IllegalArgumentException("Unhandled type of SchedulerItem");
}
} catch (Exception e) {
logger.warn(String.format("Exception occurred for mp %s, event type %s", mpId, schedulerItem.getType()), e);
} finally {
logger.debug("Scheduler message handler END for mp {} event type {} in thread {}", mpId, schedulerItem.getType(), Thread.currentThread().getId());
}
}
Aggregations