use of ddf.catalog.plugin.PreDeliveryPlugin in project ddf by codice.
the class DeliveryProcessor method process.
public void process(Event event) {
String methodName = "process";
LOGGER.debug("ENTERING: {}", methodName);
Metacard entry = (Metacard) event.getProperty(PubSubConstants.HEADER_ENTRY_KEY);
String operation = event.getProperty(PubSubConstants.HEADER_OPERATION_KEY).toString();
LOGGER.debug("Delivering catalog entry.");
if (subscription != null) {
if (entry != null) {
if (operation.equalsIgnoreCase(PubSubConstants.CREATE)) {
try {
for (PreDeliveryPlugin plugin : preDelivery) {
LOGGER.debug("Processing 'created' entry with preDelivery plugin");
entry = plugin.processCreate(entry);
}
subscription.getDeliveryMethod().created(entry);
} catch (PluginExecutionException e) {
LOGGER.debug("Plugin had exception during execution - still delivering the entry", e);
subscription.getDeliveryMethod().created(entry);
} catch (StopProcessingException e) {
LOGGER.info("Pre-delivery plugin determined entry cannot be delivered", e);
}
} else if (operation.equalsIgnoreCase(PubSubConstants.UPDATE)) {
// TODO: Handle hit or miss
try {
for (PreDeliveryPlugin plugin : preDelivery) {
LOGGER.debug("Processing 'updated' entry with preDelivery plugin");
Update updatedEntry = plugin.processUpdateHit(new UpdateImpl(entry, null));
entry = updatedEntry.getNewMetacard();
}
subscription.getDeliveryMethod().updatedHit(entry, entry);
} catch (PluginExecutionException e) {
LOGGER.debug("Plugin had exception during execution - still delivering the entry", e);
subscription.getDeliveryMethod().updatedHit(entry, entry);
} catch (StopProcessingException e) {
LOGGER.info("Pre-delivery plugin determined entry cannot be delivered", e);
}
} else if (operation.equalsIgnoreCase(PubSubConstants.DELETE)) {
try {
for (PreDeliveryPlugin plugin : preDelivery) {
LOGGER.debug("Processing 'deleted' entry with preDelivery plugin");
entry = plugin.processCreate(entry);
}
subscription.getDeliveryMethod().deleted(entry);
} catch (PluginExecutionException e) {
LOGGER.debug("Plugin had exception during execution - still delivering the entry", e);
subscription.getDeliveryMethod().deleted(entry);
} catch (StopProcessingException e) {
LOGGER.info("Pre-delivery plugin determined entry cannot be delivered", e);
}
} else {
LOGGER.debug("Could not deliver hit for subscription.");
}
} else {
LOGGER.debug("Could not deliver hit for subscription. Catalog entry is null.");
}
} else {
LOGGER.debug("Could not deliver hit for subscription. Subscription is null.");
}
LOGGER.debug("EXITING: {}", methodName);
}
Aggregations