use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method publish.
void publish(MediaPackage mp) throws LiveScheduleException {
try {
// Add media package to the search index
logger.info("Publishing LIVE media package {} to search index", mp);
Job publishJob = searchService.add(mp);
if (!waitForStatus(publishJob).isSuccess())
throw new LiveScheduleException("Live media package " + mp.getIdentifier() + " could not be published");
} catch (LiveScheduleException e) {
throw e;
} catch (Exception e) {
throw new LiveScheduleException(e);
}
}
use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method retract.
void retract(MediaPackage mp) throws LiveScheduleException {
try {
List<Job> jobs = new ArrayList<Job>();
Set<String> elementIds = new HashSet<String>();
// Remove media package from the search index
String mpId = mp.getIdentifier().compact();
logger.info("Removing LIVE media package {} from the search index", mpId);
jobs.add(searchService.delete(mpId));
// Retract elements
for (MediaPackageElement mpe : mp.getElements()) {
if (!MediaPackageElement.Type.Publication.equals(mpe.getElementType()))
elementIds.add(mpe.getIdentifier());
}
jobs.add(downloadDistributionService.retract(CHANNEL_ID, mp, elementIds));
if (!waitForStatus(jobs.toArray(new Job[jobs.size()])).isSuccess())
throw new LiveScheduleException("Removing live media package from search did not complete successfully");
} catch (LiveScheduleException e) {
throw e;
} catch (Exception e) {
throw new LiveScheduleException(e);
}
}
use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method addLivePublicationChannel.
void addLivePublicationChannel(Organization currentOrg, MediaPackage mp) throws LiveScheduleException {
logger.debug("Adding live channel publication element to media package {}", mp);
String engageUrlString = null;
String playerPath = null;
if (currentOrg != null) {
engageUrlString = StringUtils.trimToNull(currentOrg.getProperties().get(ENGAGE_URL_PROPERTY));
playerPath = StringUtils.trimToNull(currentOrg.getProperties().get(PLAYER_PROPERTY));
}
if (engageUrlString == null) {
engageUrlString = serverUrl;
logger.info("Using 'server.url' as a fallback for the non-existing organization level key '{}' for the publication url", ENGAGE_URL_PROPERTY);
}
if (playerPath == null)
playerPath = DEFAULT_PLAYER_PATH;
try {
// Create new distribution element
URI engageUri = URIUtils.resolve(new URI(engageUrlString), playerPath + "?id=" + mp.getIdentifier().compact());
Publication publicationElement = PublicationImpl.publication(UUID.randomUUID().toString(), CHANNEL_ID, engageUri, MimeTypes.parseMimeType("text/html"));
mp.add(publicationElement);
} catch (URISyntaxException e) {
throw new LiveScheduleException(e);
}
}
use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method createLiveEvent.
boolean createLiveEvent(String mpId, DublinCoreCatalog episodeDC) throws LiveScheduleException {
try {
logger.info("Creating live media package {}", mpId);
// Get latest mp from the asset manager
Snapshot snapshot = getSnapshot(mpId);
// Temporary mp
MediaPackage tempMp = (MediaPackage) snapshot.getMediaPackage().clone();
// Set duration (used by live tracks)
setDuration(tempMp, episodeDC);
// Add live tracks to media package
addLiveTracks(tempMp, episodeDC.getFirst(DublinCore.PROPERTY_SPATIAL));
// Add and distribute catalogs/acl, this creates a new mp object
MediaPackage mp = addAndDistributeElements(snapshot);
// Add tracks from tempMp
for (Track t : tempMp.getTracks()) mp.add(t);
// Publish mp to engage search index
publish(mp);
// Add engage-live publication channel to archived mp
Organization currentOrg = null;
try {
currentOrg = organizationService.getOrganization(snapshot.getOrganizationId());
} catch (NotFoundException e) {
logger.warn("Organization in snapshot not found: {}", snapshot.getOrganizationId());
}
MediaPackage archivedMp = snapshot.getMediaPackage();
addLivePublicationChannel(currentOrg, archivedMp);
// Take a snapshot with the publication added and put its version in our local cache
// so that we ignore notifications for this snapshot version.
snapshotVersionCache.put(mpId, assetManager.takeSnapshot(archivedMp).getVersion());
return true;
} catch (Exception e) {
throw new LiveScheduleException(e);
}
}
use of org.opencastproject.liveschedule.api.LiveScheduleException in project opencast by opencast.
the class LiveScheduleServiceImpl method retractPreviousElements.
void retractPreviousElements(MediaPackage previousMp, MediaPackage newMp) throws LiveScheduleException {
try {
// Now can retract elements from previous publish. Before creating a retraction
// job, check if the element url is still used by the new media package.
Set<String> elementIds = new HashSet<String>();
for (MediaPackageElement element : previousMp.getElements()) {
// We don't retract tracks because they are just live links
if (!Track.TYPE.equals(element.getElementType())) {
boolean canBeDeleted = true;
for (MediaPackageElement newElement : newMp.getElements()) {
if (element.getURI().equals(newElement.getURI())) {
logger.debug("Not retracting element {} with URI {} from download distribution because it is still used by updated live media package", element.getIdentifier(), element.getURI());
canBeDeleted = false;
break;
}
}
if (canBeDeleted)
elementIds.add(element.getIdentifier());
}
}
if (elementIds.size() > 0) {
Job job = downloadDistributionService.retract(CHANNEL_ID, previousMp, elementIds);
// Wait for retraction to finish
if (!waitForStatus(job).isSuccess())
logger.warn("One of the download retract jobs did not complete successfully");
else
logger.debug("Retraction of previously published elements complete");
}
} catch (DistributionException e) {
throw new LiveScheduleException(e);
}
}
Aggregations