org.wso2.registry.jdbc.urlhandlers
Class URLHandler

java.lang.Object
  extended by org.wso2.registry.jdbc.urlhandlers.URLHandler
Direct Known Subclasses:
CommentCollectionURLHandler, CommentURLHandler, RatingsCollectionURLHandler, RatingURLHandler, TagURLHandler

public abstract class URLHandler
extends java.lang.Object

Base class for URL handlers. URL handlers are used support virtual resources. JDBC registry allows users to access some none-resource entities in the same way they access normal resources (e.g. comments, tags, ratings). These entities can be accessed by providing a special URL to identify the virtual resource.

For example tags for the resource at path /projects/mybank/design can be accessed by the URL /projects/mybank/design?tags. URL handlers are used to support that behavior. That is, we can register URL handlers to handle each type of virtual resource. Then those URL handlers are responsible for interpreting the special URL and generating the virtual resource referred by that URL.


Field Summary
protected  javax.sql.DataSource dataSource
          Datasource of the registry database.
protected  org.wso2.usermanager.Realm realm
          Default realm of the user manager used in the registry.
 
Constructor Summary
protected URLHandler()
           
  URLHandler(javax.sql.DataSource dataSource, org.wso2.usermanager.Realm realm)
           
 
Method Summary
 boolean delete(java.lang.String path)
          Determine if delete(...) on the given url can be handled.
 Resource get(java.lang.String url)
          Determine if get(...) on the given url can be handled.
 java.lang.String put(java.lang.String suggestPath, Resource resource)
          Determine if put(...) on the given url can be handled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected javax.sql.DataSource dataSource
Datasource of the registry database. URL handlers can access this to contruct resources by combining various tables (e.g. comments).


realm

protected org.wso2.usermanager.Realm realm
Default realm of the user manager used in the registry. This can be used by the URL handler implementations to check authorizations on resources.

Constructor Detail

URLHandler

public URLHandler(javax.sql.DataSource dataSource,
                  org.wso2.usermanager.Realm realm)

URLHandler

protected URLHandler()
Method Detail

get

public Resource get(java.lang.String url)
             throws RegistryException
Determine if get(...) on the given url can be handled. If yes, process the request and return the resulting resource. Further processing of the resource is terminated if a resource is returned. If the given url cannot be handled return null, which causes other url handlers to process the request, or the request to be reached the media type handlers.

Parameters:
url - URL to identify the resource to be retrieved.
Returns:
Resource instance if the URL can be processed. Null if the request cannot be processed.
Throws:
RegistryException - URL handler implementations should handle all exceptions and throw RegistryException if the exception has to propagated to the client.

put

public java.lang.String put(java.lang.String suggestPath,
                            Resource resource)
                     throws RegistryException
Determine if put(...) on the given url can be handled. If yes, process the request and persisting the resulting resource. Further processing of the resource is terminated if string (actual path) is returned. If the given url cannot be handled return null, which causes other url handlers to process the request, or the request to be reached the media type handlers.

Parameters:
suggestPath - Suggested path to store the resource.
resource - Resource to be stored.
Returns:
If the URL handler impl processes the put request, it returns the actual path on which resource is stored. If it does not process the resource, null should be returned indicating that the request has to be propagated to the next handler.
Throws:
RegistryException - URL handler implementations should handle all exceptions and throw RegistryException if the exception has to propagated to the client.

delete

public boolean delete(java.lang.String path)
               throws RegistryException
Determine if delete(...) on the given url can be handled. If yes, process the request and delete the resulting resource. Further processing of the resource is terminated if true is returned. If the given url cannot be handled return false, which causes other url handlers to process the request, or the request to be reached the media type handlers.

Parameters:
path - Path of the resource to be deleted.
Returns:
true if the URL handler impl processes the delete request. false if it does not process the delete request.
Throws:
RegistryException - URL handler implementations should handle all exceptions and throw RegistryException if the exception has to propagated to the client.


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