CommentId changed into commentId

feature/appm-store/pbac
nishadi 7 years ago
parent da0b147050
commit 3b86f8a443

@ -245,11 +245,11 @@ public interface CommentManagementAPI {
required = true)
@Valid Comment comment,
@ApiParam(
name="CommentId",
name="commentId",
value = "comment id of the updating comment.",
required = true)
@QueryParam("CommentId")
int apAppCommentId);
@QueryParam("commentId")
int commentId);
@DELETE
@Path("/{CommentId}")
@ -286,11 +286,11 @@ public interface CommentManagementAPI {
Response deleteComment(
@ApiParam(
name="CommentId",
name="commentId",
value="Id of the comment.",
required = true)
@PathParam("CommentId")
int apAppCommentId);
@PathParam("commentId")
int commentId);
@GET
@Path("/{uuid}/{stars}")

@ -110,49 +110,49 @@ public class CommentManagementAPIImpl implements CommentManagementAPI {
@Override
@PUT
@Consumes("application/json")
@Path("/{CommentId}")
@Path("/{commentId}")
public Response updateComment(
@ApiParam Comment comment,
@PathParam("CommentId") int CommentId) {
@PathParam("commentId") int commentId) {
CommentsManager commentsManager = APIUtil.getCommentsManager();
try {
if (CommentId == 0) {
if (commentId == 0) {
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) {
String msg = "Given comment is not valid ";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).build();
} else {
comment = commentsManager.updateComment(comment, CommentId);
comment = commentsManager.updateComment(comment, commentId);
return Response.status(Response.Status.OK).entity(comment).build();
}
} catch (CommentManagementException e) {
String msg = "Error occurred while retrieving comments.";
log.error(msg, e);
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
@DELETE
@Path("/{CommentId}")
@Path("/{commentId}")
public Response deleteComment(
@PathParam("CommentId") int CommentId) {
@PathParam("commentId") int commentId) {
CommentsManager commentsManager = APIUtil.getCommentsManager();
try {
commentsManager.deleteComment(CommentId);
commentsManager.deleteComment(commentId);
} catch (CommentManagementException e) {
String msg = "Error occurred while deleting the comment.";
log.error(msg, e);
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) {
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();
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.OK).entity("Comment is deleted successfully.").build();
}
@ -219,7 +219,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI {
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).build();
}
} catch (ApplicationManagementException e) {
log.error("Application Management Exception occurs", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)

@ -65,29 +65,29 @@ public interface CommentsManager {
/**
* 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
* @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.
*
* @param CommentId id of the comment
* @param commentId id of the comment
* @throws CommentManagementException Exceptions of the comment management
*/
void deleteComment(int CommentId) throws CommentManagementException;
void deleteComment(int commentId) throws CommentManagementException;
/**
* To update a comment.
*
* @param comment comment of the application.
* @param CommentId id of the comment
* @param commentId id of the comment
* @return {@link Comment}updated comment
* @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

@ -32,7 +32,7 @@ import java.util.List;
* 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.
@ -66,7 +66,7 @@ import java.util.List;
/**
* To update already added comment.
*
* @param CommentId id of the comment
* @param commentId id of the comment
* @param updatedComment comment after updated
* @param modifiedBy Username of the modified person.
* @param modifiedAt time of the modification.
@ -75,14 +75,14 @@ import java.util.List;
* @throws DBConnectionException db connection 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;
/**
* To update already added 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 modifiedBy Username of the modified person.
* @param modifiedAt time of the modification.
@ -91,19 +91,19 @@ import java.util.List;
* @throws DBConnectionException db connection 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;
/**
* To get the comment with id.
*
* @param CommentId id of the comment
* @param commentId id of the comment
* @return {@link Comment}Comment
* @throws CommentManagementException Exceptions of the comment management.
* @throws DBConnectionException db connection 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.
@ -307,12 +307,12 @@ import java.util.List;
/**
* 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 DBConnectionException db connection 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.

@ -116,11 +116,11 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
}
@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 {
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;
PreparedStatement statement = null;
@ -131,22 +131,22 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
statement = connection.prepareStatement(sql);
statement.setString(1, updatedComment);
statement.setString(2, modifiedBy);
statement.setInt(3, CommentId);
statement.setInt(3, commentId);
statement.executeUpdate();
rs = statement.executeQuery();
} finally {
Util.cleanupResources(statement, rs);
}
return getComment(CommentId);
return getComment(commentId);
}
@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 {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to update the comment with application (" + uuid + ") and "
+ "comment id ( " + CommentId + ")");
+ "comment id ( " + commentId + ")");
}
Connection connection;
PreparedStatement statement = null;
@ -157,20 +157,20 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
statement = connection.prepareStatement(sql);
statement.setString(1, updatedComment);
statement.setString(2, modifiedBy);
statement.setInt(3, CommentId);
statement.setInt(3, commentId);
statement.executeUpdate();
rs = statement.getResultSet();
} finally {
Util.cleanupResources(statement, rs);
}
return getComment(CommentId);
return getComment(commentId);
}
@Override
public Comment getComment(int CommentId) throws CommentManagementException {
public Comment getComment(int commentId) throws CommentManagementException {
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;
PreparedStatement stmt = null;
@ -181,7 +181,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
conn = this.getDBConnection();
sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, CommentId);
stmt.setInt(1, commentId);
rs = stmt.executeQuery();
if (rs.next()) {
comment.setId(rs.getInt("ID"));
@ -197,9 +197,9 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
}
} catch (SQLException e) {
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) {
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 {
Util.cleanupResources(stmt, null);
}
@ -781,7 +781,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
}
@Override
public void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException,
public void deleteComment(int commentId) throws CommentManagementException, DBConnectionException,
SQLException {
Connection conn;
@ -790,7 +790,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
conn = this.getDBConnection();
String sql = "DELETE FROM AP_APP_COMMENT WHERE ID=?;";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, CommentId);
stmt.setInt(1, commentId);
stmt.executeUpdate();
} finally {
Util.cleanupResources(stmt, null);

@ -62,7 +62,6 @@ public class CommentsManagerImpl implements CommentsManager {
log.debug("Request for comment is received for uuid" + uuid);
}
comment.setCreatedAt(Timestamp.from(Instant.now()));
try {
ConnectionManagerUtil.beginDBTransaction();
commentDAO.addComment(tenantId, comment, comment.getCreatedBy(), comment.getParent(), uuid);
@ -114,11 +113,9 @@ public class CommentsManagerImpl implements CommentsManager {
PaginationResult paginationResult = new PaginationResult();
List<Comment> comments;
request = Util.validateCommentListPageSize(request);
if (log.isDebugEnabled()) {
log.debug("get all comments of the application release" + uuid);
}
try {
ConnectionManagerUtil.openDBConnection();
comments = commentDAO.getAllComments(uuid, request);
@ -140,24 +137,22 @@ public class CommentsManagerImpl implements CommentsManager {
}
@Override
public Comment getComment(int CommentId) throws CommentManagementException {
public Comment getComment(int commentId) throws CommentManagementException {
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
Comment comment = null;
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 {
ConnectionManagerUtil.openDBConnection();
comment = commentDAO.getComment(CommentId);
comment = commentDAO.getComment(commentId);
} catch (DBConnectionException e) {
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) {
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 {
ConnectionManagerUtil.closeDBConnection();
}
@ -165,54 +160,52 @@ public class CommentsManagerImpl implements CommentsManager {
}
@Override
public void deleteComment(int CommentId) throws CommentManagementException {
public void deleteComment(int commentId) throws CommentManagementException {
Comment comment;
comment = getComment(CommentId);
comment = getComment(commentId);
if (comment == null) {
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 {
ConnectionManagerUtil.beginDBTransaction();
commentDAO.deleteComment(CommentId);
commentDAO.deleteComment(commentId);
ConnectionManagerUtil.commitDBTransaction();
} catch (DBConnectionException e) {
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) {
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);
} catch (TransactionManagementException e) {
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 {
ConnectionManagerUtil.closeDBConnection();
}
}
@Override
public Comment updateComment(Comment comment, int CommentId) throws CommentManagementException {
public Comment updateComment(Comment comment, int commentId) throws CommentManagementException {
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
validateComment(CommentId, comment.getComment());
validateComment(commentId, comment.getComment());
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()));
try {
ConnectionManagerUtil.openDBConnection();
commentDAO.getComment(CommentId);
commentDAO.getComment(commentId);
return commentDAO
.updateComment(CommentId, comment.getComment(), comment.getModifiedBy(), comment.getModifiedAt());
.updateComment(commentId, comment.getComment(), comment.getModifiedBy(), comment.getModifiedAt());
} 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);
} catch (DBConnectionException e) {
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 {
ConnectionManagerUtil.closeDBConnection();
}

Loading…
Cancel
Save