use of org.opencastproject.assetmanager.impl.persistence.SnapshotDto in project opencast by opencast.
the class AbstractAssetManager method addInternal.
/**
* Mutates mp and its elements, so make sure to work on a copy.
*/
private SnapshotDto addInternal(String owner, final MediaPackage mp) throws Exception {
final Date now = new Date();
// claim a new version for the media package
final String mpId = mp.getIdentifier().toString();
final VersionImpl version = getDb().claimVersion(mpId);
logger.info("Creating new version {} of media package {}", version, mp);
final PartialMediaPackage pmp = assetsOnly(mp);
// make sure they have a checksum
calcChecksumsForMediaPackageElements(pmp);
// download and archive elements
storeAssets(pmp, version);
// store mediapackage in db
final SnapshotDto snapshotDto;
try {
rewriteUrisForArchival(pmp, version);
snapshotDto = getDb().saveSnapshot(getCurrentOrgId(), pmp, now, version, Availability.ONLINE, owner);
} catch (AssetManagerException e) {
logger.error("Could not take snapshot {}: {}", mpId, e);
throw new AssetManagerException(e);
}
// save manifest to element store
// this is done at the end after the media package element ids have been rewritten to neutral URNs
storeManifest(pmp, version);
return snapshotDto;
}
use of org.opencastproject.assetmanager.impl.persistence.SnapshotDto in project opencast by opencast.
the class AbstractASelectQuery method toARecord.
/**
* Transform a Querydsl result {@link Tuple} into an {@link ARecord}.
* To do the transformation I need to know what targets have been selected.
*/
private Fn<Tuple, ARecordImpl> toARecord(final SelectQueryContribution c) {
return new Fn<Tuple, ARecordImpl>() {
@Override
public ARecordImpl apply(Tuple tuple) {
final String mediaPackageId;
SnapshotDto snapshotDto = null;
final long id;
// Only fetch the snapshot if it is in the fetch list.
if (c.fetch.exists(Booleans.<Expression<?>>eq(Q_SNAPSHOT))) {
snapshotDto = RequireUtil.notNull(tuple.get(Q_SNAPSHOT), "[BUG] snapshot table data");
id = snapshotDto.getId();
mediaPackageId = snapshotDto.getMediaPackageId();
} else {
// The media package ID and the snapshot's database ID must always be fetched.
id = RequireUtil.notNull(tuple.get(Q_SNAPSHOT.id), "[BUG] snapshot table id");
mediaPackageId = RequireUtil.notNull(tuple.get(Q_SNAPSHOT.mediaPackageId), "[BUG] snapshot table media package id");
}
return new ARecordImpl(id, mediaPackageId, Stream.<Property>empty(), snapshotDto);
}
};
}
Aggregations