org.wso2.registry.jdbc.handlers.filters
Class MediaTypeMatcher

java.lang.Object
  extended by org.wso2.registry.jdbc.handlers.filters.Filter
      extended by org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher

public class MediaTypeMatcher
extends Filter

This is a built-in Filter implementation that evaluates against the media type of the resources. This has to be initialized with a media type. For all filtering methods, this will evaluates to true if the media type of the currently processing resource (or the parent of the current resource in some cases) and the media type of this implementation are equal. Handler authors can use this as the filter, if the filtering requirement is only to match the media type of the resource.


Field Summary
 
Fields inherited from class org.wso2.registry.jdbc.handlers.filters.Filter
DELETE, GET, IMPORT, IMPORT_CHILD, PUT, PUT_CHILD
 
Constructor Summary
MediaTypeMatcher()
           
MediaTypeMatcher(java.lang.String mediaType)
           
 
Method Summary
 java.lang.String getMediaType()
           
 boolean handleDelete(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handleGet(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handleImportChild(RequestContext requestContext)
          Matches if the media type of the parent collection of the current resource is equal to the handler's media type.
 boolean handleImportResource(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handlePut(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handlePutChild(RequestContext requestContext)
          Matches if the media type of the parent collection of the current resource is equal to the handler's media type.
 void setMediaType(java.lang.String mediaType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaTypeMatcher

public MediaTypeMatcher()

MediaTypeMatcher

public MediaTypeMatcher(java.lang.String mediaType)
Method Detail

handleGet

public boolean handleGet(RequestContext requestContext)
                  throws RegistryException
Matches if the media type of the current resource is equal to the handler's media type. If a resource is not set in the RequestContext, this method will retrieve the resource for given path from the database and set it in the RequestContext. Media type matcher supports special case for generating UIs for creating new resources. URLs of the form ;new:;mediaType: For this URLs, media type matcher tries to match media type given in the URL, instead of trying to retrieve the resource from the repository. Handler associated with such media types should support this special case (e.g. Implementation of UIEnabledHandler).

Specified by:
handleGet in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the current resource is equal to the handler's media type.
Throws:
RegistryException

handlePut

public boolean handlePut(RequestContext requestContext)
                  throws RegistryException
Matches if the media type of the current resource is equal to the handler's media type.

Specified by:
handlePut in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the current resource is equal to the handler's media type.
Throws:
RegistryException

handleImportResource

public boolean handleImportResource(RequestContext requestContext)
                             throws RegistryException
Matches if the media type of the current resource is equal to the handler's media type.

Specified by:
handleImportResource in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the current resource is equal to the handler's media type.
Throws:
RegistryException

handleDelete

public boolean handleDelete(RequestContext requestContext)
                     throws RegistryException
Matches if the media type of the current resource is equal to the handler's media type.

Specified by:
handleDelete in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the current resource is equal to the handler's media type.
Throws:
RegistryException

handlePutChild

public boolean handlePutChild(RequestContext requestContext)
                       throws RegistryException
Matches if the media type of the parent collection of the current resource is equal to the handler's media type. If the parent collection is not set in the RequestContext, this method will retrieve the parent collection of the current resource from the database and set it in the RequestContext.

Specified by:
handlePutChild in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the parent collection of the current resource is equal to the handler's media type.
Throws:
RegistryException

handleImportChild

public boolean handleImportChild(RequestContext requestContext)
                          throws RegistryException
Matches if the media type of the parent collection of the current resource is equal to the handler's media type. If the parent collection is not set in the RequestContext, this method will retrieve the parent collection of the current resource from the database and set it in the RequestContext.

Specified by:
handleImportChild in class Filter
Parameters:
requestContext - RequestContext for the current request
Returns:
true if the media type of the parent collection of the current resource is equal to the handler's media type.
Throws:
RegistryException

getMediaType

public java.lang.String getMediaType()

setMediaType

public void setMediaType(java.lang.String mediaType)


Copyright © 2007 Apache Web Services Project. All Rights Reserved.