org.wso2.carbon.registry.core.jdbc.dao
Class CommentsDAO

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.dao.CommentsDAO
Direct Known Subclasses:
CommentsVersionDAO

public class CommentsDAO
extends Object

Data Access Object for Comments


Constructor Summary
CommentsDAO()
           
 
Method Summary
 int addComment(ResourceImpl resource, String userID, Comment comment)
          Method to persist a comment.
 void addComments(ResourceImpl resource, CommentDO[] commentDOs)
          Method to persist comments.
 void copyComments(ResourceImpl sourceResource, ResourceImpl targetResource)
          Method to copy comments.
 void deleteComment(long commentId)
          Method to delete a comment.
 Comment getComment(long commentID, String resourcePath)
          Method to get a comment added to a given resource.
 Comment[] getComments(ResourceImpl resource)
          Method to get comments added to a given resource.
 String[] getResourcePathsOfComments(Long[] commentIDs, Connection conn)
          Method to get resource paths of comments.
 ResourceImpl getResourceWithMinimumData(String path)
          Gets the resource with sufficient data to differentiate it from another resource.
 void moveCommentPaths(ResourceIDImpl source, ResourceIDImpl target)
          Method to move comment paths.
 void moveComments(ResourceIDImpl source, ResourceIDImpl target)
          Method to move comments.
 void removeComments(ResourceImpl resource)
          Method to remove all comments added to a resource.
 void updateComment(long commentId, String text)
          Method to update a comment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommentsDAO

public CommentsDAO()
Method Detail

addComment

public int addComment(ResourceImpl resource,
                      String userID,
                      Comment comment)
               throws RegistryException
Method to persist a comment.

Parameters:
resource - the resource
userID - the id of the user who added the comment.
comment - the comment to be persisted.
Returns:
the comment id of the newly added comment.
Throws:
RegistryException - if some error occurs while adding a comment

addComments

public void addComments(ResourceImpl resource,
                        CommentDO[] commentDOs)
                 throws RegistryException
Method to persist comments.

Parameters:
resource - the resource
commentDOs - the comments to be persisted.
Throws:
RegistryException - if some error occurs while adding comments

copyComments

public void copyComments(ResourceImpl sourceResource,
                         ResourceImpl targetResource)
                  throws RegistryException
Method to copy comments.

Parameters:
sourceResource - the source resource.
targetResource - the target resource.
Throws:
RegistryException - if some error occurs while copying comments

updateComment

public void updateComment(long commentId,
                          String text)
                   throws RegistryException
Method to update a comment.

Parameters:
commentId - the comment id.
text - the comment text.
Throws:
RegistryException - if some error occurs while updating the comment.

deleteComment

public void deleteComment(long commentId)
                   throws RegistryException
Method to delete a comment.

Parameters:
commentId - the comment id.
Throws:
RegistryException - if some error occurs while deleting the comment.

removeComments

public void removeComments(ResourceImpl resource)
                    throws RegistryException
Method to remove all comments added to a resource.

Parameters:
resource - the resource.
Throws:
RegistryException - if some error occurs while removing comments.

getComment

public Comment getComment(long commentID,
                          String resourcePath)
                   throws RegistryException
Method to get a comment added to a given resource.

Parameters:
resourcePath - the resource's path.
commentID - the identifier of the comment.
Returns:
the comment.
Throws:
RegistryException - if an error occurs while getting the comment.

getComments

public Comment[] getComments(ResourceImpl resource)
                      throws RegistryException
Method to get comments added to a given resource.

Parameters:
resource - the resource.
Returns:
an array of comments.
Throws:
RegistryException - if an error occurs while getting comments.

getResourcePathsOfComments

public String[] getResourcePathsOfComments(Long[] commentIDs,
                                           Connection conn)
                                    throws RegistryException
Method to get resource paths of comments.

Parameters:
commentIDs - the comment id.
conn - the connection to use.
Returns:
array of resource paths.
Throws:
RegistryException - if an error occurs.

getResourceWithMinimumData

public ResourceImpl getResourceWithMinimumData(String path)
                                        throws RegistryException
Gets the resource with sufficient data to differentiate it from another resource. This would populate a ResourceImpl with the path, name and path identifier of a resource.

Parameters:
path - the path of the resource.
Returns:
the resource with minimum data.
Throws:
RegistryException - if an error occurs while retrieving resource data.

moveComments

public void moveComments(ResourceIDImpl source,
                         ResourceIDImpl target)
                  throws RegistryException
Method to move comments.

Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving comments

moveCommentPaths

public void moveCommentPaths(ResourceIDImpl source,
                             ResourceIDImpl target)
                      throws RegistryException
Method to move comment paths. This function will move the paths from one path id to another regardless of the resource name.

Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving comment paths


Copyright © 2010. All Rights Reserved.