Search in sources :

Example 1 with SubscriptionExistsException

use of ddf.catalog.event.SubscriptionExistsException in project ddf by codice.

the class ExceptionsTest method testSubscriptionExistsException.

@Test
public void testSubscriptionExistsException() {
    SubscriptionExistsException see = new SubscriptionExistsException();
    assertNotNull(see);
}
Also used : SubscriptionExistsException(ddf.catalog.event.SubscriptionExistsException) Test(org.junit.Test)

Example 2 with SubscriptionExistsException

use of ddf.catalog.event.SubscriptionExistsException in project ddf by codice.

the class EventProcessorImpl method createSubscription.

@Override
public void createSubscription(Subscription subscription, String subscriptionId) throws InvalidSubscriptionException, SubscriptionExistsException {
    String methodName = "createSubscription";
    LOGGER.debug("ENTERING: {}", methodName);
    LOGGER.debug("Creating Evaluation Criteria... ");
    try {
        for (PreSubscriptionPlugin plugin : preSubscription) {
            LOGGER.debug("Processing subscription with preSubscription plugin");
            subscription = plugin.process(subscription);
        }
        SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor();
        Predicate finalPredicate = (Predicate) subscription.accept(visitor, null);
        LOGGER.debug("predicate from filter visitor: {}", finalPredicate);
        String[] topics = new String[] { PubSubConstants.PUBLISHED_EVENT_TOPIC_NAME };
        Dictionary<String, String[]> props = new Hashtable<>(1, 1);
        props.put(EventConstants.EVENT_TOPIC, topics);
        ServiceRegistration serviceRegistration = bundleContext.registerService(EventHandler.class.getName(), new PublishedEventHandler(finalPredicate, subscription, preDelivery, catalog, threadPool), props);
        existingSubscriptions.put(subscriptionId, serviceRegistration);
        LOGGER.debug("Subscription {} created.", subscriptionId);
    } catch (Exception e) {
        LOGGER.info("Error while creating subscription predicate: ", e);
        throw new InvalidSubscriptionException(e);
    }
    LOGGER.debug("EXITING: {}", methodName);
}
Also used : InvalidSubscriptionException(ddf.catalog.event.InvalidSubscriptionException) SubscriptionFilterVisitor(ddf.catalog.pubsub.internal.SubscriptionFilterVisitor) Hashtable(java.util.Hashtable) PreSubscriptionPlugin(ddf.catalog.plugin.PreSubscriptionPlugin) EventHandler(org.osgi.service.event.EventHandler) SubscriptionNotFoundException(ddf.catalog.event.SubscriptionNotFoundException) SubscriptionExistsException(ddf.catalog.event.SubscriptionExistsException) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) InvalidSubscriptionException(ddf.catalog.event.InvalidSubscriptionException) Predicate(ddf.catalog.pubsub.predicate.Predicate) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

SubscriptionExistsException (ddf.catalog.event.SubscriptionExistsException)2 InvalidSubscriptionException (ddf.catalog.event.InvalidSubscriptionException)1 SubscriptionNotFoundException (ddf.catalog.event.SubscriptionNotFoundException)1 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 PreSubscriptionPlugin (ddf.catalog.plugin.PreSubscriptionPlugin)1 SubscriptionFilterVisitor (ddf.catalog.pubsub.internal.SubscriptionFilterVisitor)1 Predicate (ddf.catalog.pubsub.predicate.Predicate)1 Hashtable (java.util.Hashtable)1 Test (org.junit.Test)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 EventHandler (org.osgi.service.event.EventHandler)1