use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AssetManagerSnapshotWorkflowOperationHandler method start.
@Override
public WorkflowOperationResult start(WorkflowInstance wi, JobContext ctx) throws WorkflowOperationException {
final MediaPackage mpWorkflow = wi.getMediaPackage();
final WorkflowOperationInstance currentOperation = wi.getCurrentOperation();
// Check which tags have been configured
final String tags = StringUtils.trimToNull(currentOperation.getConfiguration("source-tags"));
final String sourceFlavorsString = StringUtils.trimToEmpty(currentOperation.getConfiguration("source-flavors"));
final String[] sourceFlavors = StringUtils.split(sourceFlavorsString, ",");
if (sourceFlavors.length < 1 && tags == null)
logger.debug("No source tags have been specified, so everything will be added to the AssetManager");
final List<String> tagSet;
// If a set of tags has been specified, use it
if (tags != null) {
tagSet = asList(tags);
} else {
tagSet = new ArrayList<>();
}
try {
final MediaPackage mpAssetManager = getMediaPackageForArchival(mpWorkflow, tagSet, sourceFlavors);
if (mpAssetManager != null) {
logger.info("Take snapshot of media package {}", mpAssetManager);
// adding media package to the episode service
assetManager.takeSnapshot(DEFAULT_OWNER, mpAssetManager);
logger.debug("Snapshot operation complete");
return createResult(mpWorkflow, Action.CONTINUE);
} else {
return createResult(mpWorkflow, Action.CONTINUE);
}
} catch (Throwable t) {
throw new WorkflowOperationException(t);
}
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AclServiceImpl method getFromAssetManagerByMpId.
/**
* Return media package with id <code>mpId</code> from asset manager.
*
* @return single element list or empty list
*/
private Option<MediaPackage> getFromAssetManagerByMpId(String mpId) {
final AQueryBuilder q = assetManager.createQuery();
final Opt<MediaPackage> mp = enrich(q.select(q.snapshot()).where(q.mediaPackageId(mpId).and(q.version().isLatest())).run()).getSnapshots().head().map(Snapshots.getMediaPackage);
return Option.fromOpt(mp);
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AclServiceImpl method applyAclToEpisode.
@Override
public boolean applyAclToEpisode(String episodeId, AccessControlList acl, Option<ConfiguredWorkflowRef> workflow) throws AclServiceException {
try {
Option<MediaPackage> mediaPackage = Option.none();
if (assetManager != null)
mediaPackage = getFromAssetManagerByMpId(episodeId);
Option<AccessControlList> aclOpt = Option.option(acl);
// the episode service is the source of authority for the retrieval of media packages
for (final MediaPackage episodeSvcMp : mediaPackage) {
aclOpt.fold(new Option.EMatch<AccessControlList>() {
// set the new episode ACL
@Override
public void esome(final AccessControlList acl) {
// update in episode service
MediaPackage mp = authorizationService.setAcl(episodeSvcMp, AclScope.Episode, acl).getA();
if (assetManager != null)
assetManager.takeSnapshot(mp);
}
// if none EpisodeACLTransition#isDelete returns true so delete the episode ACL
@Override
public void enone() {
// update in episode service
MediaPackage mp = authorizationService.removeAcl(episodeSvcMp, AclScope.Episode);
if (assetManager != null)
assetManager.takeSnapshot(mp);
}
});
// apply optional workflow
for (ConfiguredWorkflowRef workflowRef : workflow) applyWorkflow(list(episodeSvcMp), workflowRef);
return true;
}
// not found
return false;
} catch (Exception e) {
logger.error("Error applying episode ACL", e);
throw new AclServiceException(e);
}
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerBasicTest method testSetAvailability.
@Test
public void testSetAvailability() throws Exception {
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
final Version v1 = am.takeSnapshot(OWNER, mp).getVersion();
am.setAvailability(v1, mp.getIdentifier().toString(), Availability.OFFLINE);
assertEquals("One offline snapshot should be found", 1, q.select(q.snapshot()).where(q.availability(Availability.OFFLINE)).run().getSize());
assertEquals("No online snapshot should be found", 0, q.select(q.snapshot()).where(q.availability(Availability.ONLINE)).run().getSize());
}
use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.
the class AbstractAssetManagerBasicTest method testVersioning.
@Test
public void testVersioning() throws Exception {
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
final Version v1 = am.takeSnapshot(OWNER, mp).getVersion();
final Version v2 = am.takeSnapshot(OWNER, mp).getVersion();
assertTrue("First version must be older", v1.isOlder(v2));
assertTrue("Second version must be younger", v2.isYounger(v1));
assertTrue(v1.equals(v1));
assertFalse(v1.equals(v2));
}
Aggregations