Search in sources :

Example 1 with InvalidSubscriptionException

use of ddf.catalog.event.InvalidSubscriptionException 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)

Example 2 with InvalidSubscriptionException

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

the class ExceptionsTest method testInvalidSubscriptionException.

@Test
public void testInvalidSubscriptionException() {
    InvalidSubscriptionException ise = new InvalidSubscriptionException(msg);
    assertEquals(ise.getMessage(), msg);
    ise = new InvalidSubscriptionException(testCause);
    assertEquals(ise.getCause(), testCause);
    ise = new InvalidSubscriptionException(msg, testCause);
    assertEquals(ise.getMessage(), msg);
    assertEquals(ise.getCause(), testCause);
}
Also used : InvalidSubscriptionException(ddf.catalog.event.InvalidSubscriptionException) Test(org.junit.Test)

Aggregations

InvalidSubscriptionException (ddf.catalog.event.InvalidSubscriptionException)2 SubscriptionExistsException (ddf.catalog.event.SubscriptionExistsException)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