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