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

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.dao.JDBCCommentsDAO
All Implemented Interfaces:
CommentsDAO
Direct Known Subclasses:
JDBCCommentsVersionDAO

public class JDBCCommentsDAO
extends Object
implements CommentsDAO

An implementation of the CommentsDAO to store comments on a JDBC-based database.


Field Summary
protected static Object ADD_COMMENT_LOCK
           
 
Constructor Summary
JDBCCommentsDAO(DAOManager daoManager)
          Default constructor
 
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 removeVersionComments(long regVersion)
          Removes all comments added to the given resource for a given version.
 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
 

Field Detail

ADD_COMMENT_LOCK

protected static final Object ADD_COMMENT_LOCK
Constructor Detail

JDBCCommentsDAO

public JDBCCommentsDAO(DAOManager daoManager)
Default constructor

Parameters:
daoManager - instance of the data access object manager.
Method Detail

addComment

public int addComment(ResourceImpl resource,
                      String userID,
                      Comment comment)
               throws RegistryException
Description copied from interface: CommentsDAO
Method to persist a comment.

Specified by:
addComment in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to persist comments.

Specified by:
addComments in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to copy comments.

Specified by:
copyComments in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to update a comment.

Specified by:
updateComment in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to delete a comment.

Specified by:
deleteComment in interface CommentsDAO
Parameters:
commentId - the comment id.
Throws:
RegistryException - if some error occurs while deleting the comment.

removeComments

public void removeComments(ResourceImpl resource)
                    throws RegistryException
Description copied from interface: CommentsDAO
Method to remove all comments added to a resource.

Specified by:
removeComments in interface CommentsDAO
Parameters:
resource - the resource.
Throws:
RegistryException - if some error occurs while removing comments.

getComment

public Comment getComment(long commentID,
                          String resourcePath)
                   throws RegistryException
Description copied from interface: CommentsDAO
Method to get a comment added to a given resource.

Specified by:
getComment in interface CommentsDAO
Parameters:
commentID - the identifier of the comment.
resourcePath - the resource's path.
Returns:
the comment.
Throws:
RegistryException - if an error occurs while getting the comment.

getComments

public Comment[] getComments(ResourceImpl resource)
                      throws RegistryException
Description copied from interface: CommentsDAO
Method to get comments added to a given resource.

Specified by:
getComments in interface CommentsDAO
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
Description copied from interface: CommentsDAO
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.

Specified by:
getResourceWithMinimumData in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to move comments.

Specified by:
moveComments in interface CommentsDAO
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
Description copied from interface: CommentsDAO
Method to move comment paths. This function will move the paths from one path id to another regardless of the resource name.

Specified by:
moveCommentPaths in interface CommentsDAO
Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving comment paths

removeVersionComments

public void removeVersionComments(long regVersion)
                           throws RegistryException
Description copied from interface: CommentsDAO
Removes all comments added to the given resource for a given version. This applies only to versioned resources.

Specified by:
removeVersionComments in interface CommentsDAO
Parameters:
regVersion - the version
Throws:
RegistryException - if an error occurred while removing tags.


Copyright © 2013 WSO2 Inc. All Rights Reserved.