Search
Clear search
Close search
Google apps
Main menu

Document filter examples: alter connector-fed metadata

Summary: Metadata and content of connector-fed documents can be altered using the document filter mechanism by inserting appropriate rules in the documentFilters.xml configuration file or, for connector 3.0 and above, by adding these rules to the Advanced properties for the connector. The steps are explained below together with some examples.


Steps:

To add rules to documentFilters.xml, follow these steps, which are applicable to offboard connectors on version 3.0:

  1. Locate the document filter configuration file documentFilters.xml, which can be found under Tomcat\webapps\connector-manager\WEB-INF directory. By default the file contains an empty list.
  2. Edit the file to include the desired bean(s) in the list (see examples 1 and 2 below).
  3. After modifying the documentFilters.xml file, restart Tomcat.
  4. Reset the connector to re-traverse the documents and after re-traversal, the change will be reflected.

To add rules to the Advanced properties for the connector, follow these steps, which work for connector 3.0 and above, and for both onboard and offboard connectors:

  1. In the GSA Admin Console, navigate to Connector Administration > Connectors page and click the Edit link for the connector in question and the connector configuration page will be displayed.
  2. Under the Advanced properties section, click the Show/Hide link to show the advanced properties.
  3. Add the document filter bean (see example 3 below), then click Save Configuration.
  4. Reset the connector to re-traverse the documents and after re-traversal, the change will be reflected.

Note that changes to documentFilters.xml applies to all connector instances, while changes to the Advanced properties only apply to the affected connector instance.


Examples:

  1. The following is an example of documentFilters.xml that shows how to use the built-in MovePropertyFilter to change meta tag name from "Regions" to "gsaRegions" and from "Category" to "GSA Category":

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
      <bean id="DocumentFilters" class="com.google.enterprise.connector.util.filter.DocumentFilterChain">
        <constructor-arg>
          <list>
            <bean id="AlterMetaNames" class="com.google.enterprise.connector.util.filter.MovePropertyFilter">
              <property name="propertyNameMap">
                <map>
                  <entry key="Regions" value="gsaRegions"/> 
                  <entry key="Category" value="GSA Category"/>
                </map>
              </property>
              <property name="overwrite" value="true"/>
            </bean>
          </list>
        </constructor-arg>
      </bean>
    </beans>

  2. The following is another example of documentFilters.xml that shows how to append "@example.com" to each meta tag value where the meta tag name is "userPrincipal", using the built-in ModifyPropertyFilter:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
      <bean id="DocumentFilters" class="com.google.enterprise.connector.util.filter.DocumentFilterChain">
        <constructor-arg>
          <list>
             <bean id="FilterC" class="com.google.enterprise.connector.util.filter.ModifyPropertyFilter">
               <property name="propertyName" value="userPrincipal"/>
               <property name="pattern" value="$"/>
               <property name="replacement" value="@example.com"/>
               <property name="overwrite" value="true"/>
             </bean>
          </list>
        </constructor-arg>
      </bean>
    </beans>

  3. This example achieves the same goal as example 2 above; but instead of modifying documentFilters.xml, this example shows how the DocumentFilters bean can be inserted into the Advanced properties for the connector:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
      <bean id="sharepoint-connector" class="com.google.enterprise.connector.sharepoint.spiimpl.SharepointConnector" parent="sharepoint-connector-defaults" singleton="false" init-method="init">
      <!-- original properties-->
      </bean>
      <!-- Insert the DocumentFilters bean below-->
      <bean id="DocumentFilters" class="com.google.enterprise.connector.util.filter.DocumentFilterChain">
        <constructor-arg>
          <list>
             <bean id="FilterC" class="com.google.enterprise.connector.util.filter.ModifyPropertyFilter">
               <property name="propertyName" value="userPrincipal"/>
               <property name="pattern" value="$"/>
               <property name="replacement" value="@example.com"/>
               <property name="overwrite" value="true"/>
             </bean>
          </list>
        </constructor-arg>
      </bean>
    </beans>


Additional Information: See this page for more details about built-in filter classes.

Was this article helpful?
How can we improve it?