use of org.codice.ddf.log.sanitizer.LogSanitizer in project ddf by codice.
the class CswSubscriptionEndpoint method getSubscriptionConfiguration.
private Configuration getSubscriptionConfiguration(String subscriptionUuid) {
String methodName = "getSubscriptionConfiguration";
LOGGER.trace(ENTERING_STR, methodName);
String filterStr = getSubscriptionUuidFilter(subscriptionUuid);
LogSanitizer logSanitizedFilter = LogSanitizer.sanitize(filterStr);
LOGGER.debug("filterStr = {}", logSanitizedFilter);
Configuration config = null;
try {
org.osgi.framework.Filter filter = getBundleContext().createFilter(filterStr);
LOGGER.debug("filter.toString() = {}", filter);
ConfigurationAdmin configAdmin = getConfigAdmin();
if (configAdmin != null) {
Configuration[] configs = configAdmin.listConfigurations(filter.toString());
if (configs == null) {
LOGGER.debug("Did NOT find a configuration for filter {}", logSanitizedFilter);
} else if (configs.length != 1) {
LOGGER.debug("Found multiple configurations for filter {}", logSanitizedFilter);
} else {
LOGGER.debug("Found exactly one configuration for filter {}", logSanitizedFilter);
config = configs[0];
}
}
} catch (InvalidSyntaxException e) {
LOGGER.debug("Invalid syntax for filter used for searching configuration instances", e);
} catch (IOException e) {
LOGGER.debug("IOException trying to list configurations for filter {}", logSanitizedFilter, e);
}
LOGGER.trace(EXITING_STR, methodName);
return config;
}
use of org.codice.ddf.log.sanitizer.LogSanitizer in project ddf by codice.
the class CswSubscriptionEndpoint method deleteCswSubscription.
private synchronized CswSubscription deleteCswSubscription(String subscriptionId) throws CswException {
String methodName = "deleteCswSubscription";
LogSanitizer logSanitizedId = LogSanitizer.sanitize(subscriptionId);
LOGGER.trace(ENTERING_STR, methodName);
LOGGER.trace("subscriptionId = {}", logSanitizedId);
if (StringUtils.isEmpty(subscriptionId)) {
throw new CswException("Unable to delete subscription because subscription ID is null or empty");
}
CswSubscription subscription = getSubscription(subscriptionId);
try {
LOGGER.debug("Removing (unregistering) subscription: {}", logSanitizedId);
ServiceRegistration sr = registeredSubscriptions.remove(subscriptionId);
if (sr != null) {
sr.unregister();
} else {
LOGGER.debug("No ServiceRegistration found for subscription: {}", logSanitizedId);
}
Configuration subscriptionConfig = getSubscriptionConfiguration(subscriptionId);
try {
if (subscriptionConfig != null) {
LOGGER.debug("Deleting subscription for subscriptionId = {}", logSanitizedId);
subscriptionConfig.delete();
} else {
LOGGER.debug("subscriptionConfig is NULL for ID = {}", logSanitizedId);
}
} catch (IOException e) {
LOGGER.debug("IOException trying to delete subscription's configuration for subscription ID {}", subscriptionId, e);
}
LOGGER.debug("Subscription removal complete");
} catch (Exception e) {
LOGGER.debug("Could not delete subscription for {}", logSanitizedId, e);
}
LOGGER.trace("EXITING: {} (status = {})", methodName, false);
return subscription;
}
Aggregations