use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class IngestServiceImpl method addCatalog.
/**
* {@inheritDoc}
*
* @see org.opencastproject.ingest.api.IngestService#addCatalog(java.io.InputStream, java.lang.String,
* org.opencastproject.mediapackage.MediaPackageElementFlavor, org.opencastproject.mediapackage.MediaPackage)
*/
@Override
public MediaPackage addCatalog(InputStream in, String fileName, MediaPackageElementFlavor flavor, String[] tags, MediaPackage mediaPackage) throws IOException, IngestException {
Job job = null;
try {
job = serviceRegistry.createJob(JOB_TYPE, INGEST_CATALOG, null, null, false, ingestFileJobLoad);
job.setStatus(Status.RUNNING);
job = serviceRegistry.updateJob(job);
String elementId = UUID.randomUUID().toString();
logger.info("Start adding catalog {} from input stream on mediapackage {}", elementId, mediaPackage);
URI newUrl = addContentToRepo(mediaPackage, elementId, fileName, in);
if (MediaPackageElements.SERIES.equals(flavor)) {
updateSeries(newUrl);
}
MediaPackage mp = addContentToMediaPackage(mediaPackage, elementId, newUrl, MediaPackageElement.Type.Catalog, flavor);
if (tags != null && tags.length > 0) {
MediaPackageElement trackElement = mp.getCatalog(elementId);
for (String tag : tags) {
logger.info("Adding Tag: " + tag + " to Element: " + elementId);
trackElement.addTag(tag);
}
}
job.setStatus(Job.Status.FINISHED);
logger.info("Successful added catalog {} on mediapackage {} at URL {}", elementId, mediaPackage, newUrl);
return mp;
} catch (ServiceRegistryException e) {
throw new IngestException(e);
} catch (NotFoundException e) {
throw new IngestException("Unable to update ingest job", e);
} finally {
finallyUpdateJob(job);
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class IngestServiceImpl method addTrack.
/**
* {@inheritDoc}
*
* @see org.opencastproject.ingest.api.IngestService#addTrack(java.net.URI,
* org.opencastproject.mediapackage.MediaPackageElementFlavor, String[] ,
* org.opencastproject.mediapackage.MediaPackage)
*/
@Override
public MediaPackage addTrack(URI uri, MediaPackageElementFlavor flavor, String[] tags, MediaPackage mediaPackage) throws IOException, IngestException {
Job job = null;
try {
job = serviceRegistry.createJob(JOB_TYPE, INGEST_TRACK_FROM_URI, Arrays.asList(uri.toString(), flavor == null ? null : flavor.toString(), MediaPackageParser.getAsXml(mediaPackage)), null, false, ingestFileJobLoad);
job.setStatus(Status.RUNNING);
job = serviceRegistry.updateJob(job);
String elementId = UUID.randomUUID().toString();
logger.info("Start adding track {} from URL {} on mediapackage {}", elementId, uri, mediaPackage);
URI newUrl = addContentToRepo(mediaPackage, elementId, uri);
MediaPackage mp = addContentToMediaPackage(mediaPackage, elementId, newUrl, MediaPackageElement.Type.Track, flavor);
if (tags != null && tags.length > 0) {
MediaPackageElement trackElement = mp.getTrack(elementId);
for (String tag : tags) {
logger.info("Adding Tag: " + tag + " to Element: " + elementId);
trackElement.addTag(tag);
}
}
job.setStatus(Job.Status.FINISHED);
logger.info("Successful added track {} on mediapackage {} at URL {}", elementId, mediaPackage, newUrl);
return mp;
} catch (IOException e) {
throw e;
} catch (ServiceRegistryException e) {
throw new IngestException(e);
} catch (NotFoundException e) {
throw new IngestException("Unable to update ingest job", e);
} finally {
finallyUpdateJob(job);
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class IngestServiceImpl method mergeScheduledMediaPackage.
/**
* Merges the ingested mediapackage with the scheduled mediapackage. The ingested mediapackage takes precedence over
* the scheduled mediapackage.
*
* @param mp
* the ingested mediapackage
* @return the merged mediapackage
*/
private MediaPackage mergeScheduledMediaPackage(MediaPackage mp) throws IngestException {
if (schedulerService == null) {
logger.warn("No scheduler service available to merge mediapackage!");
return mp;
}
try {
MediaPackage scheduledMp = schedulerService.getMediaPackage(mp.getIdentifier().compact());
logger.info("Found matching scheduled event for id '{}', merging mediapackage...", mp.getIdentifier().compact());
mergeMediaPackageElements(mp, scheduledMp);
mergeMediaPackageMetadata(mp, scheduledMp);
return mp;
} catch (NotFoundException e) {
logger.debug("No scheduler mediapackage found with id {}, skip merging", mp.getIdentifier().compact());
return mp;
} catch (Exception e) {
logger.error("Unable to get event mediapackage from scheduler event {}", mp.getIdentifier().compact(), e);
throw new IngestException(e);
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class IngestServiceImpl method updateSeries.
/**
* Updates the persistent representation of a series based on a potentially modified dublin core document.
*
* @param uri
* the URI to the dublin core document containing series metadata.
* @return
* true, if the series is created or overwritten, false if the existing series remains intact.
*/
protected boolean updateSeries(URI uri) throws IOException, IngestException {
HttpResponse response = null;
InputStream in = null;
boolean isUpdated = false;
try {
HttpGet getDc = new HttpGet(uri);
response = httpClient.execute(getDc);
in = response.getEntity().getContent();
DublinCoreCatalog dc = dublinCoreService.load(in);
String id = dc.getFirst(DublinCore.PROPERTY_IDENTIFIER);
if (id == null) {
logger.warn("Series dublin core document contains no identifier, rejecting ingested series cagtalog.");
} else {
try {
try {
seriesService.getSeries(id);
if (isOverwriteSeries) {
// Update existing series
seriesService.updateSeries(dc);
isUpdated = true;
logger.debug("Ingest is overwriting the existing series {} with the ingested series", id);
} else {
logger.debug("Series {} already exists. Ignoring series catalog from ingest.", id);
}
} catch (NotFoundException e) {
logger.info("Creating new series {} with default ACL", id);
seriesService.updateSeries(dc);
isUpdated = true;
String anonymousRole = securityService.getOrganization().getAnonymousRole();
AccessControlList acl = new AccessControlList(new AccessControlEntry(anonymousRole, "read", true));
seriesService.updateAccessControl(id, acl);
}
} catch (Exception e) {
throw new IngestException(e);
}
}
in.close();
} catch (IOException e) {
logger.error("Error updating series from DublinCoreCatalog: {}", e.getMessage());
} finally {
IOUtils.closeQuietly(in);
httpClient.close(response);
}
return isUpdated;
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class IngestServiceImpl method addPartialTrack.
@Override
public MediaPackage addPartialTrack(InputStream in, String fileName, MediaPackageElementFlavor flavor, long startTime, MediaPackage mediaPackage) throws IOException, IngestException {
Job job = null;
try {
job = serviceRegistry.createJob(JOB_TYPE, INGEST_TRACK, null, null, false);
job.setStatus(Status.RUNNING);
job = serviceRegistry.updateJob(job);
String elementId = UUID.randomUUID().toString();
logger.info("Start adding partial track {} from input stream on mediapackage {}", elementId, mediaPackage);
URI newUrl = addContentToRepo(mediaPackage, elementId, fileName, in);
MediaPackage mp = addContentToMediaPackage(mediaPackage, elementId, newUrl, MediaPackageElement.Type.Track, flavor);
job.setStatus(Job.Status.FINISHED);
// store startTime
partialTrackStartTimes.put(elementId, startTime);
logger.debug("Added start time {} for track {}", startTime, elementId);
logger.info("Successful added partial track {} on mediapackage {} at URL {}", elementId, mediaPackage, newUrl);
return mp;
} catch (ServiceRegistryException e) {
throw new IngestException(e);
} catch (NotFoundException e) {
throw new IngestException("Unable to update ingest job", e);
} finally {
finallyUpdateJob(job);
}
}
Aggregations