Search in sources :

Example 1 with PreDeliveryPlugin

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);
}
Also used : UpdateImpl(ddf.catalog.operation.impl.UpdateImpl) Metacard(ddf.catalog.data.Metacard) PreDeliveryPlugin(ddf.catalog.plugin.PreDeliveryPlugin) StopProcessingException(ddf.catalog.plugin.StopProcessingException) Update(ddf.catalog.operation.Update) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException)

Aggregations

Metacard (ddf.catalog.data.Metacard)1 Update (ddf.catalog.operation.Update)1 UpdateImpl (ddf.catalog.operation.impl.UpdateImpl)1 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 PreDeliveryPlugin (ddf.catalog.plugin.PreDeliveryPlugin)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1