use of org.osgi.service.cm.ConfigurationException in project opencast by opencast.
the class CaptureAgentStateServiceImpl method updated.
/**
* {@inheritDoc}
*
* @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
*/
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
// Get the agent properties
String nameConfig = (String) properties.get("id");
if (isBlank(nameConfig))
throw new ConfigurationException("id", "must be specified");
nameConfig = nameConfig.trim();
String urlConfig = (String) properties.get("url");
if (isBlank(urlConfig))
throw new ConfigurationException("url", "must be specified");
urlConfig = urlConfig.trim();
String orgConfig = (String) properties.get("organization");
if (isBlank(orgConfig))
throw new ConfigurationException("organization", "must be specified");
orgConfig = orgConfig.trim();
String schedulerRolesConfig = (String) properties.get("schedulerRoles");
if (isBlank(schedulerRolesConfig))
throw new ConfigurationException("schedulerRoles", "must be specified");
String[] schedulerRoles = schedulerRolesConfig.trim().split(",");
// If we don't already have a mapping for this PID, create one
if (!pidMap.containsKey(pid)) {
pidMap.put(pid, nameConfig);
}
AgentImpl agent;
try {
agent = getAgent(nameConfig, orgConfig);
agent.setUrl(urlConfig);
agent.setState(UNKNOWN);
} catch (NotFoundException e) {
agent = new AgentImpl(nameConfig, orgConfig, UNKNOWN, urlConfig, new Properties());
}
for (String role : schedulerRoles) {
agent.schedulerRoles.add(role.trim());
}
// Update the database
logger.info("Roles '{}' may schedule '{}'", schedulerRolesConfig, agent.name);
updateAgentInDatabase(agent);
}
use of org.osgi.service.cm.ConfigurationException in project opencast by opencast.
the class RedirectingMediaPackageSerializer method updated.
/**
* {@inheritDoc}
*
* @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
*/
@SuppressWarnings("rawtypes")
@Override
public void updated(Dictionary properties) throws ConfigurationException {
if (properties == null) {
logger.warn("Mediapackage serializer is unconfigured");
return;
}
// Clear the current set of redirects
redirects.clear();
String sourceKey = null;
String destinationKey = null;
int i = 1;
while (true) {
// Create the configuration keys
sourceKey = new StringBuilder(OPT_SOURCE_PREFIX).append(".").append(i).toString();
destinationKey = new StringBuilder(OPT_DESINATION_PREFIX).append(".").append(i).toString();
logger.debug("Looking for configuration of {} and {}", sourceKey, destinationKey);
// Read the source and destination prefixes
String sourcePrefixOpt = StringUtils.trimToNull((String) properties.get(sourceKey));
String destinationPrefixOpt = StringUtils.trimToNull((String) properties.get(destinationKey));
// Has the rewriter been fully configured
if (sourcePrefixOpt == null || destinationPrefixOpt == null) {
logger.info("Mediapackage serializer configured to transparent mode");
break;
}
URI sourcePrefix = null;
URI destinationPrefix = null;
try {
sourcePrefix = new URI(sourcePrefixOpt);
} catch (URISyntaxException e) {
throw new ConfigurationException(sourceKey, e.getMessage());
}
// Read the source prefix
try {
destinationPrefix = new URI(destinationPrefixOpt);
} catch (URISyntaxException e) {
throw new ConfigurationException(destinationKey, e.getMessage());
}
// Store the redirect
try {
addRedirect(destinationPrefix, sourcePrefix);
logger.info("Mediapackage serializer will rewrite element uris from starting with '{}' to start with '{}'", destinationPrefix, sourcePrefix);
} catch (IllegalStateException e) {
throw new ConfigurationException(sourceKey, e.getMessage());
}
i++;
}
// Has the rewriter been fully configured
if (redirects.size() == 0) {
logger.info("Mediapackage serializer configured to transparent mode");
return;
}
}
use of org.osgi.service.cm.ConfigurationException in project opencast by opencast.
the class CaptureNowProlongingService method updated.
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
// Read configuration for the default initial duration
try {
initialTime = Integer.parseInt(StringUtils.defaultIfBlank((String) properties.get(CFG_KEY_INITIAL_TIME), "300"));
} catch (NumberFormatException e) {
throw new ConfigurationException(CFG_KEY_INITIAL_TIME, "Not an integer", e);
}
initialTime = Math.max(initialTime, 90) * 1000;
// Read configuration for the prolonging time
try {
prolongingTime = Integer.parseInt(StringUtils.defaultIfBlank((String) properties.get(CFG_KEY_PROLONGING_TIME), "300"));
} catch (NumberFormatException e) {
throw new ConfigurationException(CFG_KEY_PROLONGING_TIME, "Not an integer", e);
}
prolongingTime = Math.max(prolongingTime, 90) * 1000;
}
use of org.osgi.service.cm.ConfigurationException 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);
}
use of org.osgi.service.cm.ConfigurationException in project opencast by opencast.
the class WorkflowServiceImpl method updated.
/**
* {@inheritDoc}
*
* @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
*/
@Override
@SuppressWarnings("rawtypes")
public void updated(Dictionary properties) throws ConfigurationException {
String workflowStatsConfiguration = StringUtils.trimToNull((String) properties.get(STATS_COLLECT_CONFIG_KEY));
if (StringUtils.isNotEmpty(workflowStatsConfiguration)) {
try {
workflowStatsCollect = Boolean.parseBoolean(workflowStatsConfiguration);
logger.info("Workflow statistics collection is set to %s", workflowStatsConfiguration);
} catch (Exception e) {
logger.warn("Workflow statistics collection flag '%s' is malformed, setting to %s", workflowStatsConfiguration, DEFAULT_STATS_COLLECT_CONFIG.toString());
workflowStatsCollect = DEFAULT_STATS_COLLECT_CONFIG;
}
}
}
Aggregations