JBoss.orgCommunity Documentation

Built-in XMLProcessor Plugins

In Social, there are the following built-in XMLProcessor plugins (also known as filters) that filter the input texts of users.

Filters Description
DOMContentEscapeFilter Process the DOM tree input and escape all text nodes.
DOMLineBreakerFilter Process the DOM tree input and add <br /> to all text nodes which contain \n.
DOMXMLTagFilter Process the DOM tree input and convert all tag nodes which do not exist in the allowed tags list into text Node.
LineBreakerFilter Process the String input and replace \n to <br />.
XMLBalancer Process the String input and add missing close tags to input.
XMLTagFilter Process the String input and convert all tags which do not exist in the allowed tags list into the escapsed String.

The following is the general Class diagram of XMLProcesscor in Social:

All of these filters implements the Filter interface as follows:



package org.exoplatform.social.common.xmlprocessor;
public interface Filter {
  /**
   * Filters the input data.
   *
   * @param input the input data
   * @return an Object with the result after filtered
   */
  public Object doFilter(Object input);
}

These filters will process the input texts in the doFilter(Object input) method and return the result to XMLProcessor. They are declared in the configuration files found in the /demo/war/src/main/webapp/WEB-INF/conf/socialdemo/social/component-plugins-configuration.xml path.



<external-component-plugins>
    <target-component>org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy</target-component>
      <component-plugin>
        <name>setAllowedTagPlugin</name>
        <set-method>setAllowedTagPlugin</set-method>
        <type>org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTagPlugin</type>
        <init-params>
          <object-param>
            <name>b tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>b</string></field>
            </object>
          </object-param>
          <object-param>
            <name>i tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>i</string></field>
            </object>
          </object-param>
          <object-param>
            <name>a tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>a</string></field>
              <field name="tagAttributes">
                <collection item-type="java.lang.String" type="java.util.HashSet">
                  <value><string>href</string></value>
                </collection>
              </field>
            </object>
          </object-param>
          <object-param>
            <name>span tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>span</string></field>
            </object>
          </object-param>
          <object-param>
            <name>em tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>em</string></field>
            </object>
          </object-param>
          <object-param>
            <name>strong tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>strong</string></field>
            </object>
          </object-param>
          <object-param>
            <name>p tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>p</string></field>
            </object>
          </object-param>
          <object-param>
            <name>ol tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>ol</string></field>
            </object>
          </object-param>
          <object-param>
            <name>ul tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>ul</string></field>
            </object>
          </object-param>
          <object-param>
            <name>li tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>li</string></field>
            </object>
          </object-param>
          <object-param>
            <name>br tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>br</string></field>
            </object>
          </object-param>
          <object-param>
            <name>img tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>img</string></field>
              <field name="tagAttributes">
                <collection item-type="java.lang.String" type="java.util.HashSet">
                  <value><string>src</string></value>
                </collection>
              </field>
            </object>
          </object-param>
          <object-param>
            <name>blockquote tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>blockquote</string></field>
            </object>
          </object-param>
          <object-param>
            <name>q tag</name>
            <object type="org.exoplatform.social.common.xmlprocessor.model.XMLTagFilterPolicy$AllowedTag">
              <field name="tagName"><string>q</string></field>
            </object>
          </object-param>
        </init-params>
      </component-plugin>
  </external-component-plugins>  

You can write your own filter by implementing the Filter interface and add it to XMLProcessor as the sample code in the XMLProccessor Component section.