Search in sources :

Example 16 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class CswSubscriptionEndpoint method addOrUpdateSubscription.

public synchronized String addOrUpdateSubscription(GetRecordsType request, boolean persistSubscription) throws CswException {
    String methodName = "createSubscription";
    LOGGER.trace("ENTERING: {}    (persistSubscription = {})", methodName, persistSubscription);
    if (request.getResponseHandler() == null || request.getResponseHandler().isEmpty() || StringUtils.isEmpty(request.getResponseHandler().get(0))) {
        throw new CswException("Unable to create subscription because deliveryMethodUrl is null or empty");
    }
    String deliveryMethodUrl = request.getResponseHandler().get(0);
    String subscriptionUuid = getSubscriptionUuid(request.getRequestId());
    LOGGER.debug("subscriptionUuid = {}", subscriptionUuid);
    request.setRequestId(subscriptionUuid);
    // to registry
    if (registeredSubscriptions.containsKey(subscriptionUuid)) {
        LOGGER.debug("Delete existing subscription {} for re-creation", subscriptionUuid);
        deleteCswSubscription(subscriptionUuid);
    }
    CswSubscription sub = createSubscription(request);
    Dictionary<String, String> props = new DictionaryMap<>();
    props.put("subscription-id", subscriptionUuid);
    props.put("event-endpoint", request.getResponseHandler().get(0));
    LOGGER.debug("Registering Subscription");
    ServiceRegistration serviceRegistration = getBundleContext().registerService(Subscription.class.getName(), sub, props);
    if (serviceRegistration != null) {
        LOGGER.debug("Subscription registered with bundle ID = {} ", serviceRegistration.getReference().getBundle().getBundleId());
        registeredSubscriptions.put(subscriptionUuid, serviceRegistration);
        // client originally provided.
        if (persistSubscription) {
            persistSubscription(sub, deliveryMethodUrl, subscriptionUuid);
        }
    } else {
        LOGGER.debug("Subscription registration failed");
    }
    LOGGER.trace(EXITING_STR, methodName);
    return subscriptionUuid;
}
Also used : CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) Subscription(ddf.catalog.event.Subscription) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 17 with DictionaryMap

use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.

the class InputTransformerBootServiceFlag method publishService.

private void publishService(Bundle bundle) {
    BundleContext bundleContext = bundle.getBundleContext();
    if (bundleContext == null) {
        String name = bundle.getSymbolicName();
        LOGGER.debug("Failed to get the bundle context for bundle {}", name);
        throw new IllegalStateException(String.format("No bundle context available for %s", name));
    }
    Dictionary<String, String> props = new DictionaryMap<>();
    props.put("id", "inputTransformerBootFlag");
    bundleContext.registerService(BootServiceFlag.class, this, props);
}
Also used : BundleContext(org.osgi.framework.BundleContext) DictionaryMap(org.codice.ddf.configuration.DictionaryMap)

Aggregations

DictionaryMap (org.codice.ddf.configuration.DictionaryMap)17 Configuration (org.osgi.service.cm.Configuration)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 BundleContext (org.osgi.framework.BundleContext)3 ServiceRegistration (org.osgi.framework.ServiceRegistration)3 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)2 StringWriter (java.io.StringWriter)2 JAXBException (javax.xml.bind.JAXBException)2 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)2 JsonObject (com.google.gson.JsonObject)1 ActionProvider (ddf.action.ActionProvider)1 Constants (ddf.catalog.Constants)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 ContentType (ddf.catalog.data.ContentType)1 Metacard (ddf.catalog.data.Metacard)1 MetacardType (ddf.catalog.data.MetacardType)1 Result (ddf.catalog.data.Result)1