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

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter
      extended by org.wso2.carbon.registry.core.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.carbon.registry.core.jdbc.handlers.filters.Filter
ADD_ASSOCIATION, ADD_COMMENT, APPLY_TAG, COPY, CREATE_LINK, CREATE_VERSION, DELETE, DUMP, EDIT_COMMENT, EXECUTE_QUERY, GET, GET_ALL_ASSOCIATIONS, GET_ASSOCIATIONS, GET_AVERAGE_RATING, GET_COMMENTS, GET_RATING, GET_REGISTRY_CONTEXT, GET_RESOURCE_PATHS_WITH_TAG, GET_TAGS, GET_VERSIONS, IMPORT, IMPORT_CHILD, invert, INVOKE_ASPECT, MOVE, PUT, PUT_CHILD, RATE_RESOURCE, REMOVE_ASSOCIATION, REMOVE_COMMENT, REMOVE_LINK, REMOVE_TAG, RENAME, RESOURCE_EXISTS, RESTORE, RESTORE_VERSION, SEARCH_CONTENT
 
Constructor Summary
MediaTypeMatcher()
          Default constructor.
MediaTypeMatcher(java.lang.String mediaType)
          Constructor that accepts a media type.
 
Method Summary
 boolean equals(java.lang.Object other)
          Compares this MediaTypeMatcher to the specified object.
 java.lang.String getMediaType()
          Method to obtain media type.
 boolean handleCopy(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handleCreateLink(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 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 handleInvokeAspect(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handleMove(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.
 boolean handleRemoveLink(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 boolean handleRename(RequestContext requestContext)
          Matches if the media type of the current resource is equal to the handler's media type.
 int hashCode()
          This overrides the default hash code implementation for filter objects, to make sure that each filter of the same type will have identical hash codes unless otherwise it has its own extension.
 void setMediaType(java.lang.String mediaType)
          Method to set media type.
 
Methods inherited from class org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter
getInvert, handleAddAssociation, handleAddComment, handleApplyTag, handleCreateVersion, handleDump, handleEditComment, handleExecuteQuery, handleGetAllAssociations, handleGetAssociations, handleGetAverageRating, handleGetComments, handleGetRating, handleGetRegistryContext, handleGetResourcePathsWithTag, handleGetTags, handleGetVersions, handleRateResource, handleRemoveAssociation, handleRemoveComment, handleRemoveTag, handleResourceExists, handleRestore, handleRestoreVersion, handleSearchContent, setInvert
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaTypeMatcher

public MediaTypeMatcher()
Default constructor.


MediaTypeMatcher

public MediaTypeMatcher(java.lang.String mediaType)
Constructor that accepts a media type.

Parameters:
mediaType - the media type.
Method Detail

hashCode

public int hashCode()
Description copied from class: Filter
This overrides the default hash code implementation for filter objects, to make sure that each filter of the same type will have identical hash codes unless otherwise it has its own extension.

Overrides:
hashCode in class Filter
Returns:
hash code for this filter type.

equals

public boolean equals(java.lang.Object other)
Compares this MediaTypeMatcher to the specified object. The result is true if and only if the argument is not null and is a MediaTypeMatcher object that contains the same values for the fields as this object.

Overrides:
equals in class Filter
Parameters:
other - The object to compare the MediaTypeMatcher against
Returns:
true if the given object represents a MediaTypeMatcher equivalent to this instance, false otherwise.

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

handleRemoveLink

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

Overrides:
handleRemoveLink 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

handleCreateLink

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

Overrides:
handleCreateLink 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

handleCopy

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

Overrides:
handleCopy 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

handleMove

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

Overrides:
handleMove 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

handleRename

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

Overrides:
handleRename 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

handleInvokeAspect

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

Overrides:
handleInvokeAspect 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()
Method to obtain media type.

Returns:
the media type.

setMediaType

public void setMediaType(java.lang.String mediaType)
Method to set media type.

Parameters:
mediaType - the media type.


Copyright © 2011 WSO2 Inc. All Rights Reserved.