use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceImpl method getTechnicalMetadata.
@Override
public TechnicalMetadata getTechnicalMetadata(String mediaPackageId) throws NotFoundException, UnauthorizedException, SchedulerException {
notEmpty(mediaPackageId, "mediaPackageId");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(p.optOut().target(), p.agent().target(), p.start().target(), p.end().target(), p.presenters().target(), p.recordingStatus().target(), p.recordingLastHeard().target(), query.propertiesOf(CA_NAMESPACE), query.propertiesOf(WORKFLOW_NAMESPACE)).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId)).and(query.version().isLatest()).and(query.hasPropertiesOf(p.namespace()))).run();
final Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
throw new NotFoundException();
return getTechnicalMetadata(record.get(), p);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to get technical metadata of event '{}': {}", mediaPackageId, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceImpl method updateReviewStatus.
@Override
public void updateReviewStatus(String mediaPackageId, ReviewStatus reviewStatus) throws NotFoundException, SchedulerException {
notEmpty(mediaPackageId, "mediaPackageId");
notNull(reviewStatus, "reviewStatus");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(query.nothing()).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId).and(query.version().isLatest()).and(query.hasPropertiesOf(p.namespace())))).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
throw new NotFoundException();
Date now = new Date();
assetManager.setProperty(p.reviewDate().mk(mediaPackageId, now));
assetManager.setProperty(p.reviewStatus().mk(mediaPackageId, reviewStatus.toString()));
messageSender.sendObjectMessage(SchedulerItem.SCHEDULER_QUEUE, MessageSender.DestinationType.Queue, SchedulerItem.updateReviewStatus(mediaPackageId, reviewStatus, now));
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to update review status of event with mediapackage '{}': {}", mediaPackageId, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceImpl method getReviewStatus.
@Override
public ReviewStatus getReviewStatus(String mediaPackageId) throws NotFoundException, SchedulerException {
notEmpty(mediaPackageId, "mediaPackageId");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(p.reviewStatus().target()).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId).and(query.version().isLatest()).and(query.hasPropertiesOf(p.namespace())))).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
throw new NotFoundException();
return record.get().getProperties().apply(getStringOpt(REVIEW_STATUS_CONFIG)).map(toReviewStatus).getOr(UNSENT);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to get review status of event with mediapackage '{}': {}", mediaPackageId, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceImpl method verifyActive.
/**
* Verifies if existing event is found and has not already ended
*
* @param record
* the record
* @throws SchedulerException
* if event has ended or is not found
*/
private void verifyActive(String eventId, ARecord record) throws SchedulerException {
Date start = record.getProperties().apply(Properties.getDate(START_DATE_CONFIG));
Date end = record.getProperties().apply(Properties.getDate(END_DATE_CONFIG));
if (start == null || end == null) {
throw new IllegalArgumentException("Start and/or end date for event ID " + eventId + " is not set");
}
// TODO: Assumption of no TimeZone adjustment because catalog temporal is local to server
if (new Date().after(end)) {
logger.info("Event ID {} has already ended as its end time was {} and current time is {}", new Object[] { eventId, DateTimeSupport.toUTC(end.getTime()), DateTimeSupport.toUTC(new Date().getTime()) });
throw new SchedulerException("Event ID " + eventId + " has already ended at " + DateTimeSupport.toUTC(end.getTime()) + " and now is " + DateTimeSupport.toUTC(new Date().getTime()));
}
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method getDublinCore.
@Override
public DublinCoreCatalog getDublinCore(String eventId) throws NotFoundException, UnauthorizedException, SchedulerException {
HttpGet get = new HttpGet(eventId.concat("/dublincore.xml"));
HttpResponse response = getResponse(get, SC_OK, SC_NOT_FOUND, SC_UNAUTHORIZED);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Event catalog '" + eventId + "' not found on remote scheduler service!");
} else if (SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
logger.info("Unauthorized to get dublincore of the event {}.", eventId);
throw new UnauthorizedException("Unauthorized to get dublincore of the event " + eventId);
} else {
DublinCoreCatalog dublinCoreCatalog = DublinCores.read(response.getEntity().getContent());
logger.info("Successfully get event dublincore {} from the remote scheduler service", eventId);
return dublinCoreCatalog;
}
}
} catch (NotFoundException e) {
throw e;
} catch (UnauthorizedException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to parse event dublincore from remote scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to get event dublincore from remote scheduler service");
}
Aggregations