org.wso2.carbon.registry.core.jdbc.handlers.builtin
Class SymLinkHandler

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.handlers.Handler
      extended by org.wso2.carbon.registry.core.jdbc.handlers.builtin.SymLinkHandler

public class SymLinkHandler
extends Handler

This handler is used to create a symbolic link from one resource to another and perform registry operations on the symbolic link and have them applied on the actual resource as if the actual resource itself was being used. The symbolic link handler plays a key role to make it possible to create and work with symbolic links via the user interface.


Constructor Summary
SymLinkHandler()
           
 
Method Summary
 void addAssociation(RequestContext requestContext)
          Gets called when an Association is added.
 String addComment(RequestContext requestContext)
          Gets called when adding a comment.
 void applyTag(RequestContext requestContext)
          Gets called when a tag is applied.
 String copy(RequestContext requestContext)
          Copy a resource in the registry.
 void delete(RequestContext requestContext)
          Processes the DELETE action of the media type.
 boolean equals(Object obj)
          Revised implementation of the equals comparison to suite the modified hashCode method.
 Resource get(RequestContext requestContext)
          Processes the GET action for resource path of the requestContext.
 Association[] getAllAssociations(RequestContext requestContext)
          Gets called when getting all Associations.
 Association[] getAssociations(RequestContext requestContext)
          Gets called when getting Associations of given type.
 float getAverageRating(RequestContext requestContext)
          Gets called when getting average rating.
 Comment[] getComments(RequestContext requestContext)
          Gets called when retrieving comments.
 String getMountPoint()
          Method to remove an already mount point
 int getRating(RequestContext requestContext)
          Gets called when getting a rating given by a specific user.
static Set<SymLinkHandler> getSymLinkHandlers()
          Return the sym-link handler set
 Tag[] getTags(RequestContext requestContext)
          Gets called when getting tags.
 String getTargetPoint()
          Method to get the target point
 int hashCode()
          This overrides the default hash code implementation for handler objects, to make sure that each handler of the same type will have identical hash codes unless otherwise it has its own extension.
 void importResource(RequestContext requestContext)
          Creates a resource in the given path by fetching the resource content from the given URL.
 String move(RequestContext requestContext)
          Move a resource in the registry.
 void put(RequestContext requestContext)
          Processes the PUT action.
 void rateResource(RequestContext requestContext)
          Gets called when rating a resource.
 void removeAssociation(RequestContext requestContext)
          Gets called when an Association is removed.
 void removeLink(RequestContext requestContext)
          Remove a symbolic link or un-mount a registry.
 void removeTag(RequestContext requestContext)
          Gets called when a tag is removed.
 String rename(RequestContext requestContext)
          Rename a resource in the registry.
 boolean resourceExists(RequestContext requestContext)
          Gets called when searching for existence of resource.
 void setAuthor(String author)
          Method to set the author
 void setMountPoint(String mountPoint)
          Method to set the mount point
 void setTargetPoint(String targetPoint)
          Method to set the target point
 
Methods inherited from class org.wso2.carbon.registry.core.jdbc.handlers.Handler
createLink, createVersion, dump, editComment, executeQuery, getRegistryContext, getResourcePathsWithTag, getVersions, importChild, invokeAspect, putChild, removeComment, restore, restoreVersion, searchContent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymLinkHandler

public SymLinkHandler()
Method Detail

hashCode

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

Overrides:
hashCode in class Handler
Returns:
hash code for this handler type.

equals

public boolean equals(Object obj)
Description copied from class: Handler
Revised implementation of the equals comparison to suite the modified hashCode method.

Overrides:
equals in class Handler
Parameters:
obj - object to compare for equality.
Returns:
whether equal or not.

put

public void put(RequestContext requestContext)
         throws RegistryException
Description copied from class: Handler
Processes the PUT action. Actual path to which the resource is put may differ from the path given in the requestContext.resourcePath. Therefore, after putting the resource, the actual path to which the resource is put is set in the requestContext.actualPath.

Overrides:
put in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.resourcePath: Path to put the resource. requestContext.resource: Resource to put

Throws:
RegistryException - If the media type handler is supposed to handle the put on the media type and if the put fails due a handler specific error

resourceExists

public boolean resourceExists(RequestContext requestContext)
                       throws RegistryException
Description copied from class: Handler
Gets called when searching for existence of resource.

Overrides:
resourceExists in class Handler
Parameters:
requestContext - Information about the current request.
Returns:
True if the resource exists and false if not if the handler processed the RESOURCE_EXISTS action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the resourceExists on the media type and if the resourceExists fails due a handler specific error

get

public Resource get(RequestContext requestContext)
             throws RegistryException
Description copied from class: Handler
Processes the GET action for resource path of the requestContext.

Overrides:
get in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.resourcePath: Path of the resource

requestContext.resource: Resource at the given path. This can be null if no other handler has retrieved that resource so far. If it contains a value, matching handlers are free to do any change to the resource, even they can replace the resource with completely new instance.

Returns:
Resource instance if the handler processed the GET action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the get on the media type and if the get fails due a handler specific error

delete

public void delete(RequestContext requestContext)
            throws RegistryException
Description copied from class: Handler
Processes the DELETE action of the media type.

Overrides:
delete in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.resourcePath: path of the resource to be deleted.

Throws:
RegistryException - If the media type handler is supposed to handle the delete on the media type and if the delete fails due a handler specific error

rename

public String rename(RequestContext requestContext)
              throws RegistryException
Description copied from class: Handler
Rename a resource in the registry. This is equivalent to 1) delete the resource, then 2) add the resource to the new location. The operation is atomic, so if it fails the old resource will still be there.

Overrides:
rename in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.sourcePath: Source/Current Path

requestContext.targetPath: Destination/New Path

Returns:
the actual path for the new resource if the handler processed the RENAME action successfully.
Throws:
RegistryException - if something went wrong

move

public String move(RequestContext requestContext)
            throws RegistryException
Description copied from class: Handler
Move a resource in the registry. This is equivalent to 1) delete the resource, then 2) add the resource to the new location. The operation is atomic, so if it fails the old resource will still be there.

Overrides:
move in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.sourcePath: Source/Current Path

requestContext.targetPath: Destination/New Path

Returns:
the actual path for the new resource if the handler processed the MOVE action successfully.
Throws:
RegistryException - if something went wrong

copy

public String copy(RequestContext requestContext)
            throws RegistryException
Description copied from class: Handler
Copy a resource in the registry. This is equivalent to adding the resource to the new location. The operation is atomic, so if it fails the resource won't be added.

Overrides:
copy in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.sourcePath: Source/Current Path

requestContext.targetPath: Destination/New Path

Returns:
the actual path for the new resource if the handler processed the COPY action successfully.
Throws:
RegistryException - if something went wrong

getAverageRating

public float getAverageRating(RequestContext requestContext)
                       throws RegistryException
Description copied from class: Handler
Gets called when getting average rating.

Overrides:
getAverageRating in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource
Returns:
The average rating if the handler processed the GET_AVERAGE_RATING action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getAverageRating on the media type and if the getAverageRating fails due a handler specific error

getRating

public int getRating(RequestContext requestContext)
              throws RegistryException
Description copied from class: Handler
Gets called when getting a rating given by a specific user.

Overrides:
getRating in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.userName: The name of the user
Returns:
The rating given by the user if the handler processed the GET_RATING action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getRating on the media type and if the getRating fails due a handler specific error

rateResource

public void rateResource(RequestContext requestContext)
                  throws RegistryException
Description copied from class: Handler
Gets called when rating a resource.

Overrides:
rateResource in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.rating: Rating
Throws:
RegistryException - If the media type handler is supposed to handle the rateResource on the media type and if the rateResource fails due a handler specific error

getComments

public Comment[] getComments(RequestContext requestContext)
                      throws RegistryException
Description copied from class: Handler
Gets called when retrieving comments.

Overrides:
getComments in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource
Returns:
Array of comments if the handler processed the REMOVE_COMMENT action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getComments on the media type and if the getComments fails due a handler specific error

addComment

public String addComment(RequestContext requestContext)
                  throws RegistryException
Description copied from class: Handler
Gets called when adding a comment.

Overrides:
addComment in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.comment: The comment to add
Returns:
The comment id of the comment added if the handler processed the ADD_COMMENT action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the addComment on the media type and if the addComment fails due a handler specific error

getTags

public Tag[] getTags(RequestContext requestContext)
              throws RegistryException
Description copied from class: Handler
Gets called when getting tags.

Overrides:
getTags in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource
Returns:
Array of tags added to the given resource if the handler processed the GET_TAGS action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getTags on the media type and if the getTags fails due a handler specific error

applyTag

public void applyTag(RequestContext requestContext)
              throws RegistryException
Description copied from class: Handler
Gets called when a tag is applied.

Overrides:
applyTag in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.tag: Tag
Throws:
RegistryException - If the media type handler is supposed to handle the applyTag on the media type and if the applyTag fails due a handler specific error

getAllAssociations

public Association[] getAllAssociations(RequestContext requestContext)
                                 throws RegistryException
Description copied from class: Handler
Gets called when getting all Associations.

Overrides:
getAllAssociations in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource
Returns:
Array of all associations if the handler processed the GET_ALL_ASSOCIATIONS action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getAllAssociations on the media type and if the getAllAssociations fails due a handler specific error

getAssociations

public Association[] getAssociations(RequestContext requestContext)
                              throws RegistryException
Description copied from class: Handler
Gets called when getting Associations of given type.

Overrides:
getAssociations in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.associationType: Type of Association
Returns:
Array of associations of given type if the handler processed the GET_ASSOCIATIONS action successfully.
Throws:
RegistryException - If the media type handler is supposed to handle the getAssociations on the media type and if the getAssociations fails due a handler specific error

addAssociation

public void addAssociation(RequestContext requestContext)
                    throws RegistryException
Description copied from class: Handler
Gets called when an Association is added.

Overrides:
addAssociation in class Handler
Parameters:
requestContext - Information about the current request. requestContext.sourcePath: Source/Current Path requestContext.targetPath: Destination/New Path requestContext.associationType: Type of Association
Throws:
RegistryException - If the media type handler is supposed to handle the addAssociation on the media type and if the addAssociation fails due a handler specific error

importResource

public void importResource(RequestContext requestContext)
                    throws RegistryException
Description copied from class: Handler
Creates a resource in the given path by fetching the resource content from the given URL.

Overrides:
importResource in class Handler
Parameters:
requestContext - Information about the current request.

requestContext.resourcePath: Path to add the new resource.

requestContext.sourceURL: URL to fetch the resource content

requestContext.resource: Resource instance containing the meta data for the resource to be imported. Once import is done, new resource is created combining the meta data of this meta data object and the imported content.

Throws:
RegistryException - If the media type handler is supposed to handle the import on the media type and if the import fails due a handler specific error

removeLink

public void removeLink(RequestContext requestContext)
Description copied from class: Handler
Remove a symbolic link or un-mount a registry.

Overrides:
removeLink in class Handler
Parameters:
requestContext - Information about the current request.

setMountPoint

public void setMountPoint(String mountPoint)
Method to set the mount point

Parameters:
mountPoint - the mount point

getMountPoint

public String getMountPoint()
Method to remove an already mount point

Returns:
mountPoint the mount point

setTargetPoint

public void setTargetPoint(String targetPoint)
Method to set the target point

Parameters:
targetPoint - the target point

getTargetPoint

public String getTargetPoint()
Method to get the target point

Returns:
the target point

setAuthor

public void setAuthor(String author)
Method to set the author

Parameters:
author - the author

getSymLinkHandlers

public static Set<SymLinkHandler> getSymLinkHandlers()
Return the sym-link handler set

Returns:
sym-link handler set

removeAssociation

public void removeAssociation(RequestContext requestContext)
                       throws RegistryException
Description copied from class: Handler
Gets called when an Association is removed.

Overrides:
removeAssociation in class Handler
Parameters:
requestContext - Information about the current request. requestContext.sourcePath: Source/Current Path requestContext.targetPath: Destination/New Path requestContext.associationType: Type of Association
Throws:
RegistryException - If the media type handler is supposed to handle the removeAssociation on the media type and if the removeAssociation fails due a handler specific error

removeTag

public void removeTag(RequestContext requestContext)
               throws RegistryException
Description copied from class: Handler
Gets called when a tag is removed.

Overrides:
removeTag in class Handler
Parameters:
requestContext - Information about the current request. requestContext.resourcePath: Path of Resource requestContext.tag: Tag
Throws:
RegistryException - If the media type handler is supposed to handle the removeTag on the media type and if the removeTag fails due a handler specific error


Copyright © 2013 WSO2 Inc. All Rights Reserved.