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;
}
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);
}
Aggregations