2009/10/12
12 Oct, 2009

Configuring Built-in Filters in WSO2 Governance Registry

  • Senaka Fernando
  • Director Solutions Architecture - WSO2

WSO2 Governance Registry can be extended in several ways. A Registry Handler which is a pluggable component, can be used to customize processing logic for resources stored on the repository. Resource operations can be intercepted by engaging a handler along with a filter, which will be evaluated to determine whether the handler will be invoked or not. In this brief article, Senaka explains how to configure the two built-in filters of the WSO2 Governance Registry that can be used to control the engaging of handlers at runtime. These are:

1. The Media Type Matcher

2. The URL Matcher

The Media Type Matcher

This filter will determine whether a given handler is invoked based on the media type of the resource (or collection) on which the registry operation is performed. Configuration of a Media Type Matcher includes a single media type for which a handler baring this filter will be executed.

<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
    <property name="mediaType">application/xml</property>
</filter>

The definition above ensures that the handler in concern is executed against all XML files.

The URL Matcher

This filter can be used to invoke handlers based on the path of the resource (or collection) on which the registry operation is performed. Unlike the Media Type Matcher, the URL Matcher allows you to configure the target resource path per registry operation. The accepted value is a regular expression and therefore, can easily be written to match more than one resource (or collection) stored on the repository. The configuration for a URL Matcher can have one or more properties, as follows:

<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
    <property name="putPattern">/a/b/.*</property>
</filter>

The definition above ensures that the handler in concern is executed against all the resource within the collection /a/b/. This includes children as well as grand children. You can have more than one such pattern property.

<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
    <property name="putPattern">/a/b/.*</property>
    <property name="getPattern">/a/.*</property>
</filter>

The URL Matcher defines a list of possible properties that can used which includes, getPattern, putPattern, importPattern, deletePattern, putChildPattern, importChildPattern, invokeAspectPattern, movePattern, copyPattern, renamePattern, createLinkPattern, removeLinkPattern, resourceExistsPattern, addAssociationPattern, removeAssociationPattern, getAllAssociationsPattern, getAssociationsPattern, applyTagPattern, getTagsPattern, removeTagPattern, addCommentPattern, editCommentPattern, getCommentsPattern, rateResourcePattern, getAverageRatingPattern, getRatingPattern, createVersionPattern, getVersionsPattern, restoreVersionPattern, dumpPattern, restorePattern.

Support for Inverse Operations

WSO2 Governance Registry also supports inversion of filter operations. This can be done by setting the invert property to true.

<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
    <property name="putPattern">/a/b/.*</property>
    <property name="invert">true</property>
</filter>

Setting this property for a Media Type Matcher will cause the handler to execute for all other media types than the specified. Setting this property for a URL Matcher will cause the handler to execute for each operation configured using the pattern property but for all paths that don't match the given regular expression.

Applies To:- WSO2 Governance Registry-3.0.0 or later.

Author

Senaka Fernando, Software Engineer, WSO2, [email protected]

 

About Author

  • Senaka Fernando
  • Director Solutions Architecture
  • WSO2