Search in sources :

Example 1 with LogSanitizer

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;
}
Also used : Configuration(org.osgi.service.cm.Configuration) LogSanitizer(org.codice.ddf.log.sanitizer.LogSanitizer) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) IOException(java.io.IOException) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin)

Example 2 with LogSanitizer

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;
}
Also used : Configuration(org.osgi.service.cm.Configuration) LogSanitizer(org.codice.ddf.log.sanitizer.LogSanitizer) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) IOException(java.io.IOException) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) JAXBException(javax.xml.bind.JAXBException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) IOException(java.io.IOException) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

IOException (java.io.IOException)2 LogSanitizer (org.codice.ddf.log.sanitizer.LogSanitizer)2 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)2 Configuration (org.osgi.service.cm.Configuration)2 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 JAXBException (javax.xml.bind.JAXBException)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)1 CswSubscription (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1