Search in sources :

Example 1 with ClientCredentials

use of org.opencastproject.publication.youtube.auth.ClientCredentials in project opencast by opencast.

the class YouTubeV3PublicationServiceImpl method updated.

@Override
public void updated(final Dictionary props) throws ConfigurationException {
    properties.merge(props);
    enabled = Boolean.valueOf((String) properties.get(YOUTUBE_ENABLED_KEY));
    final String dataStore = YouTubeUtils.get(properties, YouTubeKey.credentialDatastore);
    try {
        if (enabled) {
            final ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.setCredentialDatastore(dataStore);
            final String path = YouTubeUtils.get(properties, YouTubeKey.clientSecretsV3);
            File secretsFile = new File(path);
            if (secretsFile.exists() && !secretsFile.isDirectory()) {
                clientCredentials.setClientSecrets(secretsFile);
                clientCredentials.setDataStoreDirectory(YouTubeUtils.get(properties, YouTubeKey.dataStore));
                // 
                youTubeService.initialize(clientCredentials);
                // 
                tags = StringUtils.split(YouTubeUtils.get(properties, YouTubeKey.keywords), ',');
                defaultPlaylist = YouTubeUtils.get(properties, YouTubeKey.defaultPlaylist);
                makeVideosPrivate = StringUtils.containsIgnoreCase(YouTubeUtils.get(properties, YouTubeKey.makeVideosPrivate), "true");
                defaultMaxFieldLength(YouTubeUtils.get(properties, YouTubeKey.maxFieldLength, false));
            } else {
                logger.warn("Client information file does not exist: " + path);
            }
        } else {
            logger.info("YouTube v3 publication service is disabled");
        }
    } catch (final Exception e) {
        throw new ConfigurationException("Failed to load YouTube v3 properties", dataStore, e);
    }
    youtubePublishJobLoad = LoadUtil.getConfiguredLoadValue(properties, YOUTUBE_PUBLISH_LOAD_KEY, DEFAULT_YOUTUBE_PUBLISH_JOB_LOAD, serviceRegistry);
    youtubeRetractJobLoad = LoadUtil.getConfiguredLoadValue(properties, YOUTUBE_RETRACT_LOAD_KEY, DEFAULT_YOUTUBE_RETRACT_JOB_LOAD, serviceRegistry);
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) ClientCredentials(org.opencastproject.publication.youtube.auth.ClientCredentials) File(java.io.File) PublicationException(org.opencastproject.publication.api.PublicationException) ConfigurationException(org.osgi.service.cm.ConfigurationException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException)

Aggregations

File (java.io.File)1 PublicationException (org.opencastproject.publication.api.PublicationException)1 ClientCredentials (org.opencastproject.publication.youtube.auth.ClientCredentials)1 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1