mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
CommentId changed into commentId
This commit is contained in:
parent
da0b147050
commit
3b86f8a443
@ -245,11 +245,11 @@ public interface CommentManagementAPI {
|
|||||||
required = true)
|
required = true)
|
||||||
@Valid Comment comment,
|
@Valid Comment comment,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name="CommentId",
|
name="commentId",
|
||||||
value = "comment id of the updating comment.",
|
value = "comment id of the updating comment.",
|
||||||
required = true)
|
required = true)
|
||||||
@QueryParam("CommentId")
|
@QueryParam("commentId")
|
||||||
int apAppCommentId);
|
int commentId);
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{CommentId}")
|
@Path("/{CommentId}")
|
||||||
@ -286,11 +286,11 @@ public interface CommentManagementAPI {
|
|||||||
|
|
||||||
Response deleteComment(
|
Response deleteComment(
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name="CommentId",
|
name="commentId",
|
||||||
value="Id of the comment.",
|
value="Id of the comment.",
|
||||||
required = true)
|
required = true)
|
||||||
@PathParam("CommentId")
|
@PathParam("commentId")
|
||||||
int apAppCommentId);
|
int commentId);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{uuid}/{stars}")
|
@Path("/{uuid}/{stars}")
|
||||||
|
|||||||
@ -110,49 +110,49 @@ public class CommentManagementAPIImpl implements CommentManagementAPI {
|
|||||||
@Override
|
@Override
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("/{CommentId}")
|
@Path("/{commentId}")
|
||||||
public Response updateComment(
|
public Response updateComment(
|
||||||
@ApiParam Comment comment,
|
@ApiParam Comment comment,
|
||||||
@PathParam("CommentId") int CommentId) {
|
@PathParam("commentId") int commentId) {
|
||||||
|
|
||||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||||
try {
|
try {
|
||||||
if (CommentId == 0) {
|
if (commentId == 0) {
|
||||||
return Response.status(Response.Status.NOT_FOUND)
|
return Response.status(Response.Status.NOT_FOUND)
|
||||||
.entity("Comment with comment id " + CommentId + " not found").build();
|
.entity("Comment with comment id " + commentId + " not found").build();
|
||||||
} else if (comment == null) {
|
} else if (comment == null) {
|
||||||
String msg = "Given comment is not valid ";
|
String msg = "Given comment is not valid ";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
} else {
|
} else {
|
||||||
comment = commentsManager.updateComment(comment, CommentId);
|
comment = commentsManager.updateComment(comment, commentId);
|
||||||
return Response.status(Response.Status.OK).entity(comment).build();
|
return Response.status(Response.Status.OK).entity(comment).build();
|
||||||
}
|
}
|
||||||
} catch (CommentManagementException e) {
|
} catch (CommentManagementException e) {
|
||||||
String msg = "Error occurred while retrieving comments.";
|
String msg = "Error occurred while retrieving comments.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||||
.entity("Comment with Comment Id" + CommentId + " Internal server error occurs").build();
|
.entity("Comment with Comment Id" + commentId + " Internal server error occurs").build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{CommentId}")
|
@Path("/{commentId}")
|
||||||
public Response deleteComment(
|
public Response deleteComment(
|
||||||
@PathParam("CommentId") int CommentId) {
|
@PathParam("commentId") int commentId) {
|
||||||
|
|
||||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||||
try {
|
try {
|
||||||
commentsManager.deleteComment(CommentId);
|
commentsManager.deleteComment(commentId);
|
||||||
} catch (CommentManagementException e) {
|
} catch (CommentManagementException e) {
|
||||||
String msg = "Error occurred while deleting the comment.";
|
String msg = "Error occurred while deleting the comment.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||||
.entity("Comment with Comment Id" + CommentId + " Internal server error occurs").build();
|
.entity("Comment with Comment Id" + commentId + " Internal server error occurs").build();
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
log.error("Not found exception occurs to comment id " + CommentId + " .", e);
|
log.error("Not found exception occurs to comment id " + commentId + " .", e);
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity("Comment with" + CommentId + " not found").build();
|
return Response.status(Response.Status.NOT_FOUND).entity("Comment with" + commentId + " not found").build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Comment is deleted successfully.").build();
|
return Response.status(Response.Status.OK).entity("Comment is deleted successfully.").build();
|
||||||
}
|
}
|
||||||
@ -219,7 +219,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI {
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
log.error("Application Management Exception occurs", e);
|
log.error("Application Management Exception occurs", e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||||
|
|||||||
@ -65,29 +65,29 @@ public interface CommentsManager {
|
|||||||
/**
|
/**
|
||||||
* To get the comment with id.
|
* To get the comment with id.
|
||||||
*
|
*
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @return {@link Comment}Comment of the comment id
|
* @return {@link Comment}Comment of the comment id
|
||||||
* @throws CommentManagementException Exceptions of the comment management.
|
* @throws CommentManagementException Exceptions of the comment management.
|
||||||
*/
|
*/
|
||||||
Comment getComment(int CommentId) throws CommentManagementException;
|
Comment getComment(int commentId) throws CommentManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To delete comment using comment id.
|
* To delete comment using comment id.
|
||||||
*
|
*
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @throws CommentManagementException Exceptions of the comment management
|
* @throws CommentManagementException Exceptions of the comment management
|
||||||
*/
|
*/
|
||||||
void deleteComment(int CommentId) throws CommentManagementException;
|
void deleteComment(int commentId) throws CommentManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To update a comment.
|
* To update a comment.
|
||||||
*
|
*
|
||||||
* @param comment comment of the application.
|
* @param comment comment of the application.
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @return {@link Comment}updated comment
|
* @return {@link Comment}updated comment
|
||||||
* @throws CommentManagementException Exceptions of the comment management
|
* @throws CommentManagementException Exceptions of the comment management
|
||||||
*/
|
*/
|
||||||
Comment updateComment(Comment comment, int CommentId) throws CommentManagementException;
|
Comment updateComment(Comment comment, int commentId) throws CommentManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get number of rated users
|
* To get number of rated users
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
* This interface specifies the database access operations performed for comments.
|
* This interface specifies the database access operations performed for comments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("ALL") public interface CommentDAO {
|
public interface CommentDAO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To add a comment to a application.
|
* To add a comment to a application.
|
||||||
@ -66,7 +66,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* To update already added comment.
|
* To update already added comment.
|
||||||
*
|
*
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @param updatedComment comment after updated
|
* @param updatedComment comment after updated
|
||||||
* @param modifiedBy Username of the modified person.
|
* @param modifiedBy Username of the modified person.
|
||||||
* @param modifiedAt time of the modification.
|
* @param modifiedAt time of the modification.
|
||||||
@ -75,14 +75,14 @@ import java.util.List;
|
|||||||
* @throws DBConnectionException db connection exception
|
* @throws DBConnectionException db connection exception
|
||||||
* @throws SQLException sql exception
|
* @throws SQLException sql exception
|
||||||
*/
|
*/
|
||||||
Comment updateComment(int CommentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
Comment updateComment(int commentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
||||||
throws CommentManagementException, DBConnectionException, SQLException;
|
throws CommentManagementException, DBConnectionException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To update already added comment.
|
* To update already added comment.
|
||||||
*
|
*
|
||||||
* @param uuid uuid of the comment
|
* @param uuid uuid of the comment
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @param updatedComment comment after updated
|
* @param updatedComment comment after updated
|
||||||
* @param modifiedBy Username of the modified person.
|
* @param modifiedBy Username of the modified person.
|
||||||
* @param modifiedAt time of the modification.
|
* @param modifiedAt time of the modification.
|
||||||
@ -91,19 +91,19 @@ import java.util.List;
|
|||||||
* @throws DBConnectionException db connection exception
|
* @throws DBConnectionException db connection exception
|
||||||
* @throws SQLException sql exception
|
* @throws SQLException sql exception
|
||||||
*/
|
*/
|
||||||
Comment updateComment(String uuid, int CommentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
Comment updateComment(String uuid, int commentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
||||||
throws CommentManagementException, DBConnectionException, SQLException;
|
throws CommentManagementException, DBConnectionException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the comment with id.
|
* To get the comment with id.
|
||||||
*
|
*
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @return {@link Comment}Comment
|
* @return {@link Comment}Comment
|
||||||
* @throws CommentManagementException Exceptions of the comment management.
|
* @throws CommentManagementException Exceptions of the comment management.
|
||||||
* @throws DBConnectionException db connection exception
|
* @throws DBConnectionException db connection exception
|
||||||
* @throws SQLException sql exception
|
* @throws SQLException sql exception
|
||||||
*/
|
*/
|
||||||
Comment getComment(int CommentId) throws CommentManagementException, SQLException, DBConnectionException;
|
Comment getComment(int commentId) throws CommentManagementException, SQLException, DBConnectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the comment with id.
|
* To get the comment with id.
|
||||||
@ -307,12 +307,12 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* To delete comment using comment id.
|
* To delete comment using comment id.
|
||||||
*
|
*
|
||||||
* @param CommentId id of the comment
|
* @param commentId id of the comment
|
||||||
* @throws CommentManagementException Exceptions of the comment management.
|
* @throws CommentManagementException Exceptions of the comment management.
|
||||||
* @throws DBConnectionException db connection exception.
|
* @throws DBConnectionException db connection exception.
|
||||||
* @throws SQLException sql exception
|
* @throws SQLException sql exception
|
||||||
*/
|
*/
|
||||||
void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException, SQLException;
|
void deleteComment(int commentId) throws CommentManagementException, DBConnectionException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To delete comment using comment id.
|
* To delete comment using comment id.
|
||||||
|
|||||||
@ -116,11 +116,11 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comment updateComment(int CommentId, String updatedComment, String modifiedBy,
|
public Comment updateComment(int commentId, String updatedComment, String modifiedBy,
|
||||||
Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Request received in DAO Layer to update the comment with ID (" + CommentId + ")");
|
log.debug("Request received in DAO Layer to update the comment with ID (" + commentId + ")");
|
||||||
}
|
}
|
||||||
Connection connection;
|
Connection connection;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -131,22 +131,22 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
statement.setString(1, updatedComment);
|
statement.setString(1, updatedComment);
|
||||||
statement.setString(2, modifiedBy);
|
statement.setString(2, modifiedBy);
|
||||||
statement.setInt(3, CommentId);
|
statement.setInt(3, commentId);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
rs = statement.executeQuery();
|
rs = statement.executeQuery();
|
||||||
} finally {
|
} finally {
|
||||||
Util.cleanupResources(statement, rs);
|
Util.cleanupResources(statement, rs);
|
||||||
}
|
}
|
||||||
return getComment(CommentId);
|
return getComment(commentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comment updateComment(String uuid, int CommentId, String updatedComment, String modifiedBy,
|
public Comment updateComment(String uuid, int commentId, String updatedComment, String modifiedBy,
|
||||||
Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Request received in DAO Layer to update the comment with application (" + uuid + ") and "
|
log.debug("Request received in DAO Layer to update the comment with application (" + uuid + ") and "
|
||||||
+ "comment id ( " + CommentId + ")");
|
+ "comment id ( " + commentId + ")");
|
||||||
}
|
}
|
||||||
Connection connection;
|
Connection connection;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -157,20 +157,20 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
statement.setString(1, updatedComment);
|
statement.setString(1, updatedComment);
|
||||||
statement.setString(2, modifiedBy);
|
statement.setString(2, modifiedBy);
|
||||||
statement.setInt(3, CommentId);
|
statement.setInt(3, commentId);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
rs = statement.getResultSet();
|
rs = statement.getResultSet();
|
||||||
} finally {
|
} finally {
|
||||||
Util.cleanupResources(statement, rs);
|
Util.cleanupResources(statement, rs);
|
||||||
}
|
}
|
||||||
return getComment(CommentId);
|
return getComment(commentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comment getComment(int CommentId) throws CommentManagementException {
|
public Comment getComment(int commentId) throws CommentManagementException {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting comment with the comment id(" + CommentId + ") from the database");
|
log.debug("Getting comment with the comment id(" + commentId + ") from the database");
|
||||||
}
|
}
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -181,7 +181,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;";
|
sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, CommentId);
|
stmt.setInt(1, commentId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
comment.setId(rs.getInt("ID"));
|
comment.setId(rs.getInt("ID"));
|
||||||
@ -197,9 +197,9 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CommentManagementException(
|
throw new CommentManagementException(
|
||||||
"SQL Error occurred while retrieving information of the comment " + CommentId, e);
|
"SQL Error occurred while retrieving information of the comment " + commentId, e);
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
log.error("DB Connection Exception occurred while retrieving information of the comment " + CommentId, e);
|
log.error("DB Connection Exception occurred while retrieving information of the comment " + commentId, e);
|
||||||
} finally {
|
} finally {
|
||||||
Util.cleanupResources(stmt, null);
|
Util.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
@ -781,7 +781,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException,
|
public void deleteComment(int commentId) throws CommentManagementException, DBConnectionException,
|
||||||
SQLException {
|
SQLException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
@ -790,7 +790,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
String sql = "DELETE FROM AP_APP_COMMENT WHERE ID=?;";
|
String sql = "DELETE FROM AP_APP_COMMENT WHERE ID=?;";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, CommentId);
|
stmt.setInt(1, commentId);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} finally {
|
} finally {
|
||||||
Util.cleanupResources(stmt, null);
|
Util.cleanupResources(stmt, null);
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user