use of org.opencastproject.assetmanager.api.query.AResult in project opencast by opencast.
the class SchedulerServiceImpl method getAccessControlList.
@Override
public AccessControlList getAccessControlList(String mediaPackageId) throws NotFoundException, SchedulerException {
notEmpty(mediaPackageId, "mediaPackageId");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(query.snapshot()).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId)).and(withVersion(query)).and(query.hasPropertiesOf(p.namespace()))).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
throw new NotFoundException();
Opt<AccessControlList> acl = loadEpisodeAclFromAsset(record.get().getSnapshot().get());
if (acl.isNone())
return null;
return acl.get();
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to get access control list of event '{}': {}", mediaPackageId, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.assetmanager.api.query.AResult in project opencast by opencast.
the class SchedulerServiceImpl method hasActiveTransaction.
@Override
public boolean hasActiveTransaction(String mediaPackageId) throws NotFoundException, UnauthorizedException, SchedulerException {
notEmpty(mediaPackageId, "mediaPackageId");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
TrxProps trxP = new TrxProps(query);
AResult result = query.select(p.source().target(), trxP.source().target()).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId)).and(query.version().isLatest())).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
throw new NotFoundException();
// Check for active transactions
Opt<String> source = record.get().getProperties().apply(Properties.getStringOpt(SOURCE_CONFIG));
if (source.isSome() && persistence.hasTransaction(source.get()))
return true;
return false;
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to check for active transaction of event with mediapackage '{}': {}", mediaPackageId, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.assetmanager.api.query.AResult in project opencast by opencast.
the class SchedulerServiceImpl method getEventMediaPackage.
private Opt<MediaPackage> getEventMediaPackage(String mediaPackageId) {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(query.snapshot()).where(withOrganization(query).and(query.mediaPackageId(mediaPackageId)).and(withVersion(query)).and(query.hasPropertiesOf(p.namespace()))).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone())
return Opt.none();
return record.bind(recordToMp);
}
use of org.opencastproject.assetmanager.api.query.AResult 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.assetmanager.api.query.AResult 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);
}
}
Aggregations