use of org.opencastproject.mediapackage.Catalog in project opencast by opencast.
the class TextAnalyzerServiceImpl method process.
/**
* {@inheritDoc}
*
* @see org.opencastproject.job.api.AbstractJobProducer#process(org.opencastproject.job.api.Job)
*/
@Override
protected String process(Job job) throws Exception {
Operation op = null;
String operation = job.getOperation();
List<String> arguments = job.getArguments();
try {
op = Operation.valueOf(operation);
switch(op) {
case Extract:
Attachment element = (Attachment) MediaPackageElementParser.getFromXml(arguments.get(0));
Catalog catalog = extract(job, element);
return MediaPackageElementParser.getAsXml(catalog);
default:
throw new IllegalStateException("Don't know how to handle operation '" + operation + "'");
}
} catch (IllegalArgumentException e) {
throw new ServiceRegistryException("This service can't handle operations of type '" + op + "'", e);
} catch (IndexOutOfBoundsException e) {
throw new ServiceRegistryException("This argument list for operation '" + op + "' does not meet expectations", e);
} catch (Exception e) {
throw new ServiceRegistryException("Error handling operation '" + op + "'", e);
}
}
use of org.opencastproject.mediapackage.Catalog in project opencast by opencast.
the class TextAnalysisWorkflowOperationHandler method start.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance,
* JobContext)
*/
@Override
public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException {
logger.debug("Running segments preview workflow operation on {}", workflowInstance);
// Check if there is an mpeg-7 catalog containing video segments
MediaPackage src = (MediaPackage) workflowInstance.getMediaPackage().clone();
Catalog[] segmentCatalogs = src.getCatalogs(MediaPackageElements.SEGMENTS);
if (segmentCatalogs.length == 0) {
logger.info("Media package {} does not contain segment information", src);
return createResult(Action.CONTINUE);
}
try {
return extractVideoText(src, workflowInstance.getCurrentOperation());
} catch (Exception e) {
throw new WorkflowOperationException(e);
}
}
use of org.opencastproject.mediapackage.Catalog in project opencast by opencast.
the class CatalogBuilderPlugin method newElement.
/**
* {@inheritDoc}
*
* @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#newElement(org.opencastproject.mediapackage.MediaPackageElement.Type,
* org.opencastproject.mediapackage.MediaPackageElementFlavor)
*/
@Override
public MediaPackageElement newElement(Type type, MediaPackageElementFlavor flavor) {
Catalog cat = CatalogImpl.newInstance();
cat.setFlavor(flavor);
return cat;
}
use of org.opencastproject.mediapackage.Catalog in project opencast by opencast.
the class CatalogBuilderPlugin method catalogFromManifest.
protected Catalog catalogFromManifest(String id, URI uri) {
Catalog cat = CatalogImpl.fromURI(uri);
cat.setIdentifier(id);
return cat;
}
use of org.opencastproject.mediapackage.Catalog in project opencast by opencast.
the class EmailTemplateServiceImpl method initCatalogs.
/**
* Initializes the map with all fields from the dublin core catalogs.
*/
private HashMap<String, HashMap<String, String>> initCatalogs(MediaPackage mediaPackage) {
HashMap<String, HashMap<String, String>> catalogs = new HashMap<String, HashMap<String, String>>();
Catalog[] dcs = mediaPackage.getCatalogs(DublinCoreCatalog.ANY_DUBLINCORE);
for (int i = 0; dcs != null && i < dcs.length; i++) {
DublinCoreCatalog dc = null;
InputStream in = null;
try {
File f = workspace.get(dcs[i].getURI());
in = new FileInputStream(f);
dc = DublinCores.read(in);
} catch (Exception e) {
logger.warn("Error when populating catalog data", e);
// Don't include the info
continue;
} finally {
IOUtils.closeQuietly(in);
}
if (dc != null) {
String catalogFlavor = dcs[i].getFlavor().getSubtype();
HashMap<String, String> catalogHash = new HashMap<String, String>();
for (EName ename : dc.getProperties()) {
String name = ename.getLocalName();
catalogHash.put(name, dc.getAsText(ename, DublinCore.LANGUAGE_ANY, DEFAULT_DELIMITER_FOR_MULTIPLE));
}
catalogs.put(catalogFlavor, catalogHash);
}
}
return catalogs;
}
Aggregations