db.custom_action_java_class

Background

This feature is deprecated. A plugin that implements a filter should be used instead.

This configuration parameter allows a class to be selected which will be given the opportunity to perform custom actions with each database record before they are written to disk. The default empty setting causes no such class to be used. If set, the value must be the fully qualified class name of the desired class.

The specified class must implement the com.funnelback.common.workflow.Workflow interface (included in the $SEARCH_HOME/lib/java/common/funnelback-common.jar), which defines a single process method which accepts a single org.w3c.dom.Document object, and returns a org.w3c.dom.Document to be indexed by Funnelback. The process method may return null rather than a Document object, which causes the record to be excluded from indexing entirely.

Custom action java class example

The ExampleWorkflow class below provides a simple example of a workflow class which performs the following two actions:

  • Adds a new 'example' element containing the text content of all children of the root node.

  • Excludes from indexing any records where the above text contains the string 'exclude-me'.

    package com.mycompany.workflows;

    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.funnelback.common.workflow.Workflow;

    public class ExampleWorkflow implements Workflow {

        public Document process(Document document) {
            if (document == null) {
                return document;
            }
            StringBuffer exampleContent = new StringBuffer();
            Node rootNode = document.getFirstChild();
            NodeList children = rootNode.getChildNodes();

            String separator = "";
            for (int i = 1; i < children.getLength(); i++) {
                Node child = children.item(i);

                if (child.getNodeType() == Node.ELEMENT_NODE) {
                    String content = child.getTextContent();

                    if (content.contains("exclude-me")) {
                        return null;
                    }

                    exampleContent.append(separator + content);
                    separator = ", ";
                }
            }

            Node exampleNode = document.createElement("example");
            exampleNode.setTextContent(exampleContent.toString());

            rootNode.appendChild(exampleNode);

            return document;
        }

    }

Installing your own class

Funnelback must be able to find your custom java class when gathering data from a database. If the driver is packaged in a jar file, it should be placed in [INSTALL_ROOT]/lib/java/dbgather. If a simple class file is used, it should be placed in an appropriate directory hierarchy under [INSTALL_ROOT]/lib/java/dbgather. For example, if the fully qualified class name is com.foocorp.funnelback.CustomWorkflow, the class file should be placed at [INSTALL_ROOT]/lib/java/dbgather/com/foocorp/funnelback/CustomWorkflow.class.

Where [INSTALL_ROOT] is the path where Funnelback is installed (default: `/opt/funnelback')

Setting the key

Set this configuration key in the search package or data source configuration.

Use the configuration key editor to add or edit the db.custom_action_java_class key, and set the value. This can be set to any valid String value.

Default value

(none)

Examples

db.custom_action_java_class=com.funnelback.dbgather.ExampleWorkflow

Notes

This is deprecated. Use the filter framework instead.