Search in sources :

Example 31 with Catalog

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);
    }
}
Also used : Attachment(org.opencastproject.mediapackage.Attachment) Catalog(org.opencastproject.mediapackage.Catalog) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) TextExtractorException(org.opencastproject.textextractor.api.TextExtractorException) ConfigurationException(org.osgi.service.cm.ConfigurationException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) TextAnalyzerException(org.opencastproject.textanalyzer.api.TextAnalyzerException) NotFoundException(org.opencastproject.util.NotFoundException) IOException(java.io.IOException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException)

Example 32 with Catalog

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);
    }
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) Catalog(org.opencastproject.mediapackage.Catalog) Mpeg7Catalog(org.opencastproject.metadata.mpeg7.Mpeg7Catalog) ConfigurationException(org.osgi.service.cm.ConfigurationException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) TextAnalyzerException(org.opencastproject.textanalyzer.api.TextAnalyzerException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) NotFoundException(org.opencastproject.util.NotFoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) EncoderException(org.opencastproject.composer.api.EncoderException)

Example 33 with Catalog

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;
}
Also used : Catalog(org.opencastproject.mediapackage.Catalog)

Example 34 with Catalog

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;
}
Also used : Catalog(org.opencastproject.mediapackage.Catalog)

Example 35 with Catalog

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;
}
Also used : EName(org.opencastproject.mediapackage.EName) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Catalog(org.opencastproject.mediapackage.Catalog) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) FileInputStream(java.io.FileInputStream) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) File(java.io.File)

Aggregations

Catalog (org.opencastproject.mediapackage.Catalog)77 MediaPackage (org.opencastproject.mediapackage.MediaPackage)35 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)34 URI (java.net.URI)32 Test (org.junit.Test)24 InputStream (java.io.InputStream)21 IOException (java.io.IOException)18 Job (org.opencastproject.job.api.Job)17 NotFoundException (org.opencastproject.util.NotFoundException)17 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)16 Track (org.opencastproject.mediapackage.Track)15 Attachment (org.opencastproject.mediapackage.Attachment)14 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)11 Mpeg7Catalog (org.opencastproject.metadata.mpeg7.Mpeg7Catalog)11 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)11 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)10 File (java.io.File)9 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)9 ArrayList (java.util.ArrayList)8 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)8