Search in sources :

Example 1 with ReadinessIndicator

use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.

the class EncodingProfileScanner method install.

/**
 * {@inheritDoc}
 *
 * @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
 */
@Override
public void install(File artifact) throws Exception {
    logger.info("Registering encoding profiles from {}", artifact);
    try {
        Map<String, EncodingProfile> profileMap = loadFromProperties(artifact);
        for (Map.Entry<String, EncodingProfile> entry : profileMap.entrySet()) {
            logger.info("Installed profile {}", entry.getValue().getIdentifier());
            profiles.put(entry.getKey(), entry.getValue());
        }
        sumInstalledFiles++;
    } catch (Exception e) {
        logger.error("Encoding profiles could not be read from {}: {}", artifact, e.getMessage());
    }
    // Determine the number of available profiles
    String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {

        public boolean accept(File arg0, String name) {
            return name.endsWith(".properties");
        }
    });
    // Once all profiles have been loaded, announce readiness
    if (filesInDirectory.length == sumInstalledFiles) {
        Dictionary<String, String> properties = new Hashtable<String, String>();
        properties.put(ARTIFACT, "encodingprofile");
        logger.debug("Indicating readiness of encoding profiles");
        bundleCtx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
        logger.info("All {} encoding profiles installed", filesInDirectory.length);
    } else {
        logger.debug("{} of {} encoding profiles installed", sumInstalledFiles, filesInDirectory.length);
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) ReadinessIndicator(org.opencastproject.util.ReadinessIndicator) Hashtable(java.util.Hashtable) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) ConfigurationException(org.opencastproject.util.ConfigurationException) IOException(java.io.IOException)

Example 2 with ReadinessIndicator

use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.

the class DictionaryServiceImpl method activate.

/**
 * OSGi callback on component activation.
 *
 * @param  ctx  the bundle context
 */
void activate(BundleContext ctx) {
    logger.info("Activating regexp based DictionaryService");
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put(ARTIFACT, "dictionary");
    ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
}
Also used : ReadinessIndicator(org.opencastproject.util.ReadinessIndicator) Hashtable(java.util.Hashtable)

Example 3 with ReadinessIndicator

use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.

the class DictionaryServiceImpl method activate.

/**
 * OSGi callback on component activation.
 *
 * @param  ctx  the bundle context
 */
void activate(BundleContext ctx) throws UnsupportedEncodingException {
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put(ARTIFACT, "dictionary");
    ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
    /* Get hunspell binary from config file */
    String binary = (String) ctx.getProperty(HUNSPELL_BINARY_CONFIG_KEY);
    if (binary != null) {
        /* Fix special characters */
        binary = new String(binary.getBytes("ISO-8859-1"), "UTF-8");
        logger.info("Setting hunspell binary to '{}'", binary);
        this.binary = binary;
    }
    /* Get hunspell command line options from config file */
    String command = (String) ctx.getProperty(HUNSPELL_COMMAND_CONFIG_KEY);
    if (command != null) {
        /* Fix special characters */
        command = new String(command.getBytes("ISO-8859-1"), "UTF-8");
        logger.info("Setting hunspell command line options to '{}'", command);
        this.command = command;
    }
}
Also used : ReadinessIndicator(org.opencastproject.util.ReadinessIndicator) Hashtable(java.util.Hashtable)

Example 4 with ReadinessIndicator

use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.

the class DictionaryServiceImpl method activate.

/**
 * OSGi callback on component activation.
 *
 * @param ctx
 *          the bundle context
 */
void activate(BundleContext ctx) {
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put(ARTIFACT, "dictionary");
    ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
}
Also used : ReadinessIndicator(org.opencastproject.util.ReadinessIndicator) Hashtable(java.util.Hashtable)

Example 5 with ReadinessIndicator

use of org.opencastproject.util.ReadinessIndicator in project opencast by opencast.

the class WorkflowDefinitionScanner method install.

/**
 * {@inheritDoc}
 *
 * @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
 */
public void install(File artifact) throws Exception {
    WorkflowDefinition def = currentWFD;
    // If the current workflow definition is null, it means this is a first install and not an update...
    if (def == null) {
        // ... so we have to load the definition first
        def = parseWorkflowDefinitionFile(artifact);
        if (def == null) {
            logger.warn("Unable to install workflow from '{}'", artifact.getName());
            artifactsWithError.add(artifact);
            return;
        }
    }
    logger.debug("Installing workflow from file '{}'", artifact.getName());
    artifactsWithError.remove(artifact);
    artifactIds.put(artifact, def.getId());
    putWorkflowDefinition(def.getId(), def);
    // Determine the number of available profiles
    String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {

        public boolean accept(File arg0, String name) {
            return name.endsWith(".xml");
        }
    });
    logger.info("Worfkflow definition '{}' from file '{}' installed", def.getId(), artifact.getName());
    // Once all profiles have been loaded, announce readiness
    if ((filesInDirectory.length - artifactsWithError.size()) == artifactIds.size() && !isWFSinitiliazed) {
        logger.info("{} Workflow definitions loaded, activating Workflow service", filesInDirectory.length - artifactsWithError.size());
        Dictionary<String, String> properties = new Hashtable<String, String>();
        properties.put(ARTIFACT, "workflowdefinition");
        logger.debug("Indicating readiness of workflow definitions");
        bundleCtx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
        isWFSinitiliazed = true;
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) ReadinessIndicator(org.opencastproject.util.ReadinessIndicator) Hashtable(java.util.Hashtable) WorkflowDefinition(org.opencastproject.workflow.api.WorkflowDefinition) File(java.io.File)

Aggregations

Hashtable (java.util.Hashtable)6 ReadinessIndicator (org.opencastproject.util.ReadinessIndicator)6 File (java.io.File)3 FilenameFilter (java.io.FilenameFilter)3 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 EncodingProfile (org.opencastproject.composer.api.EncodingProfile)1 FeedGenerator (org.opencastproject.feed.api.FeedGenerator)1 ConfigurationException (org.opencastproject.util.ConfigurationException)1 WorkflowDefinition (org.opencastproject.workflow.api.WorkflowDefinition)1