+

Search Tips   |   Advanced Search

Create a content page resolution filter class

A content page resolution filter is used to customize the behavior of the content page resolution filter chain. This can enable you to tailor the response to a web content request in several ways, including overriding the content item displayed or the portal page used to display a content item in the web content viewer.

The content page resolution filter chain is composed of filters that are based on the Intercepting Filter design pattern, which provides a mechanism for intercepting a request and manipulating the request and its response. When used with requests for web content, the content page resolution filter chain has default filters that process any URL parameters contained in the web content request and then determine which portal page has a matching web content association. The default filters occur at the end of the filter chain.

We can customize the content page resolution filter chain by creating custom filters that are registered with the portal through the Eclipse plug-in framework with the extension ID com.ibm.workplace.wcm.api.ContentPageResolutionFilter. The sequence of filters in the filter chain is specified by a weight value associated with each filter. To insert custom filters into the filter chain before the default filters, we can use the weight attribute in the plugin.xml file. If the weight attribute is not present, filter sequence is determined by the getFilterChainWeight method of each custom filter.

Custom filters can perform various actions:

To use a content page resolution filter, create a content page resolution filter class and then register the filter by deploying it on the server.

  1. Create a java class that implements the interface com.ibm.workplace.wcm.api.extensions.resolution.ContentPageResolutionFilter. This class must implement the following methods:

      public int getFilterChainWeight() {}

      This method returns the weight applied to the content page resolution filter elements in the filter chain. The lower the weight, the earlier the filter is inserted into the chain. If the weight parameter is defined in the plugin.xml file, that value overrides the value returned by this method.

      public void resolve(ContentPageResolutionRequest request, ContentPageResolutionResponse response, ContentPageResolutionFilterChain chain) {}

      This method is invoked during ContentPageResolution processing. The response parameter enables you to modify the content item displayed, the portal page where the content is displayed, and the presentation template used to render the content item. The request extends the resolver interface with an additional method that gets the content item that has been addressed. The filter chain contains the subsequent filters that can be invoked if needed.

    See the Javadoc documentation for further information.

  2. A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deploying with an application in a WAR or EAR, include the plugin.xml file in the application's "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
    <?xml version="1.0" encoding="UTF-8"?>
    <plugin id="com.example"
           name="Sample Content Page Resolution Filter"
           version="1.0.0"
           provider-name="IBM">
           
     <extension
        point="com.ibm.workplace.wcm.api.ContentPageResolutionFilter"
        id="SampleContentPageResolutionFilter">
        <provider class="com.example.SampleContentPageResolutionFilter"
                  weight="1"/>
     </extension>
    
    </plugin>
    

    When creating plug-ins, note the following:

    • Each plug-in is represented by a single <extension> tag.

    • The value of the extension point attribute must be com.ibm.workplace.wcm.api.ContentPageResolutionFilter.

    • Provide an ID value of the choice.

    • Specify the filter class for the plug-in.

    • The weight parameter overrides the value of the getFilterChainWeight method

    Naming conventions:

    If you create a new plug-in application with the same names and IDs as an existing plug-in, the new plug-in may override the first. When creating plug-in applications ensure that the following are unique across the system:

    • The plug-in ID, plug-in name and extension ID of the plugin.xml file.

    • The fully qualified class name and path of all classes within the application.

    • The file path of any files within the application.


Examples


Parent: Create custom plug-ins

Related:

Intercepting Filter design pattern