|
|
@ -62,7 +62,6 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
log.debug("Request for comment is received for uuid" + uuid);
|
|
|
|
log.debug("Request for comment is received for uuid" + uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
comment.setCreatedAt(Timestamp.from(Instant.now()));
|
|
|
|
comment.setCreatedAt(Timestamp.from(Instant.now()));
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
commentDAO.addComment(tenantId, comment, comment.getCreatedBy(), comment.getParent(), uuid);
|
|
|
|
commentDAO.addComment(tenantId, comment, comment.getCreatedBy(), comment.getParent(), uuid);
|
|
|
@ -114,11 +113,9 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
PaginationResult paginationResult = new PaginationResult();
|
|
|
|
PaginationResult paginationResult = new PaginationResult();
|
|
|
|
List<Comment> comments;
|
|
|
|
List<Comment> comments;
|
|
|
|
request = Util.validateCommentListPageSize(request);
|
|
|
|
request = Util.validateCommentListPageSize(request);
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("get all comments of the application release" + uuid);
|
|
|
|
log.debug("get all comments of the application release" + uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
comments = commentDAO.getAllComments(uuid, request);
|
|
|
|
comments = commentDAO.getAllComments(uuid, request);
|
|
|
@ -140,24 +137,22 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Comment getComment(int CommentId) throws CommentManagementException {
|
|
|
|
public Comment getComment(int commentId) throws CommentManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
Comment comment = null;
|
|
|
|
Comment comment = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Comment retrieval request is received for the comment id " + CommentId);
|
|
|
|
log.debug("Comment retrieval request is received for the comment id " + commentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
comment = commentDAO.getComment(CommentId);
|
|
|
|
comment = commentDAO.getComment(commentId);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"DB Connection error occurs ,Comment with comment id " + CommentId + "cannot get.", e);
|
|
|
|
"DB Connection error occurs ,Comment with comment id " + commentId + "cannot get.", e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"SQL Exception occurs,Comment with comment id " + CommentId + "cannot get.", e);
|
|
|
|
"SQL Exception occurs,Comment with comment id " + commentId + "cannot get.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -165,54 +160,52 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteComment(int CommentId) throws CommentManagementException {
|
|
|
|
public void deleteComment(int commentId) throws CommentManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
Comment comment;
|
|
|
|
Comment comment;
|
|
|
|
comment = getComment(CommentId);
|
|
|
|
comment = getComment(commentId);
|
|
|
|
|
|
|
|
|
|
|
|
if (comment == null) {
|
|
|
|
if (comment == null) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"Cannot delete a non-existing comment for the application with comment id" + CommentId);
|
|
|
|
"Cannot delete a non-existing comment for the application with comment id" + commentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
commentDAO.deleteComment(CommentId);
|
|
|
|
commentDAO.deleteComment(commentId);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"DB Connection error occurs deleting comment with comment id " + CommentId + ".", e);
|
|
|
|
"DB Connection error occurs deleting comment with comment id " + commentId + ".", e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new CommentManagementException("SQL error occurs deleting comment with comment id " + CommentId + ".",
|
|
|
|
throw new CommentManagementException("SQL error occurs deleting comment with comment id " + commentId + ".",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"Transaction Management Exception occurs deleting comment with comment id " + CommentId + ".", e);
|
|
|
|
"Transaction Management Exception occurs deleting comment with comment id " + commentId + ".", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Comment updateComment(Comment comment, int CommentId) throws CommentManagementException {
|
|
|
|
public Comment updateComment(Comment comment, int commentId) throws CommentManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
validateComment(CommentId, comment.getComment());
|
|
|
|
validateComment(commentId, comment.getComment());
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Comment retrieval request is received for the comment id " + CommentId);
|
|
|
|
log.debug("Comment retrieval request is received for the comment id " + commentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
comment.setModifiedAt(Timestamp.from(Instant.now()));
|
|
|
|
comment.setModifiedAt(Timestamp.from(Instant.now()));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
commentDAO.getComment(CommentId);
|
|
|
|
commentDAO.getComment(commentId);
|
|
|
|
return commentDAO
|
|
|
|
return commentDAO
|
|
|
|
.updateComment(CommentId, comment.getComment(), comment.getModifiedBy(), comment.getModifiedAt());
|
|
|
|
.updateComment(commentId, comment.getComment(), comment.getModifiedBy(), comment.getModifiedAt());
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new CommentManagementException("SQL Error occurs updating comment with comment id " + CommentId + ".",
|
|
|
|
throw new CommentManagementException("SQL Error occurs updating comment with comment id " + commentId + ".",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new CommentManagementException(
|
|
|
|
throw new CommentManagementException(
|
|
|
|
"DB Connection error occurs updating comment with comment id " + CommentId + ".", e);
|
|
|
|
"DB Connection error occurs updating comment with comment id " + commentId + ".", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|