diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java index baccd8132fb..0762f59f655 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/CommentManagementAPI.java @@ -188,7 +188,7 @@ public interface CommentManagementAPI { String uuid); @PUT - @Path("/{apAppCommentId}") + @Path("/{CommentId}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ApiOperation( @@ -229,14 +229,14 @@ public interface CommentManagementAPI { required = true) @Valid Comment comment, @ApiParam( - name="apAppCommentId", + name="CommentId", value = "comment id of the updating comment.", required = true) - @QueryParam("apAppCommentId") + @QueryParam("CommentId") int apAppCommentId); @DELETE - @Path("/{apAppCommentId}") + @Path("/{CommentId}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ApiOperation( @@ -270,10 +270,10 @@ public interface CommentManagementAPI { Response deleteComment( @ApiParam( - name="apAppCommentId", + name="CommentId", value="Id of the comment.", required = true) - @PathParam("apAppCommentId") + @PathParam("CommentId") int apAppCommentId); @GET diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java index f920ccb9632..19a4a43e4c6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/CommentManagementAPIImpl.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.wso2.carbon.device.application.mgt.api.services.impl; import io.swagger.annotations.ApiParam; @@ -97,23 +115,23 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{ @Override @PUT @Consumes("application/json") - @Path("/{apAppCommentId}") + @Path("/{CommentId}") public Response updateComment( @ApiParam Comment comment, - @PathParam("apAppCommentId") int apAppCommentId) { + @PathParam("CommentId") int CommentId) { CommentsManager commentsManager = APIUtil.getCommentsManager(); try { - if (apAppCommentId == 0) { + if (CommentId == 0) { return Response.status(Response.Status.NOT_FOUND) - .entity("Comment with comment id " + apAppCommentId + " 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,apAppCommentId); + comment = commentsManager.updateComment(comment,CommentId); return Response.status(Response.Status.OK).entity(comment).build(); } } catch (CommentManagementException e) { @@ -131,22 +149,22 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{ @Override @DELETE - @Path("/{apAppCommentId}") + @Path("/{CommentId}") public Response deleteComment( - @PathParam("apAppCommentId") - int apAppCommentId){ + @PathParam("CommentId") + int CommentId){ CommentsManager commentsManager = APIUtil.getCommentsManager(); try { - commentsManager.deleteComment(apAppCommentId); + 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).build(); } catch (NotFoundException e) { - log.error("Not found exception occurs to comment id "+apAppCommentId+" .",e); + log.error("Not found exception occurs to comment id "+CommentId+" .",e); return Response.status(Response.Status.NOT_FOUND) - .entity("Comment with" + apAppCommentId + " not found").build(); + .entity("Comment with" + CommentId + " not found").build(); } return Response.status(Response.Status.OK).entity("Comment is deleted successfully.").build(); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationRequest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationRequest.java index 789c27215bb..63c9af14f6c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationRequest.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationResult.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationResult.java index aa95d2a880e..46bf0983fa2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationResult.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/PaginationResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java index 25e956ce200..693198b683e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java @@ -48,13 +48,13 @@ public interface CommentsManager { /** * To validate the pre-request of the comment * - * @param apAppCommentId ID of the comment. + * @param CommentId ID of the comment. * @param comment comment needed to be validate. * @return validated the comment. * @throws CommentManagementException Exceptions of the comment management. * */ - Boolean validateComment(int apAppCommentId,String comment) throws CommentManagementException; + Boolean validateComment(int CommentId,String comment) throws CommentManagementException; /** * Get all comments to pagination @@ -71,32 +71,32 @@ public interface CommentsManager { /** * To get the comment with id. * - * @param apAppCommentId 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 apAppCommentId)throws CommentManagementException; + Comment getComment(int CommentId)throws CommentManagementException; /** * To delete comment using comment id. * - * @param apAppCommentId id of the comment + * @param CommentId id of the comment * @throws CommentManagementException Exceptions of the comment management */ - void deleteComment(int apAppCommentId) throws CommentManagementException; + void deleteComment(int CommentId) throws CommentManagementException; /** * To update a comment. * * @param comment comment of the application. - * @param apAppCommentId id of the comment + * @param CommentId id of the comment * @return {@link Comment}updated comment * @throws CommentManagementException Exceptions of the comment management * @throws SQLException SQL Exception * @throws DBConnectionException Database connection Exception */ - Comment updateComment(Comment comment,int apAppCommentId) throws CommentManagementException, SQLException, DBConnectionException; + Comment updateComment(Comment comment,int CommentId) throws CommentManagementException, SQLException, DBConnectionException; /** * To get number of rated users diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentDAO.java index 20333612e30..263b992740e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentDAO.java @@ -65,7 +65,7 @@ public interface CommentDAO { /** * To update already added comment. * - * @param apAppCommentId 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. @@ -74,13 +74,13 @@ public interface CommentDAO { * @throws DBConnectionException db connection exception * @throws SQLException sql exception */ - Comment updateComment(int apAppCommentId, String updatedComment,String modifiedBy, Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException; + 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 apAppCommentId 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. @@ -89,18 +89,18 @@ public interface CommentDAO { * @throws DBConnectionException db connection exception * @throws SQLException sql exception */ - Comment updateComment(String uuid, int apAppCommentId,String updatedComment,String modifiedBy, Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException; + Comment updateComment(String uuid, int CommentId,String updatedComment,String modifiedBy, Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException; /** * To get the comment with id. * - * @param apAppCommentId 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 apAppCommentId) throws CommentManagementException, SQLException, DBConnectionException; + Comment getComment(int CommentId) throws CommentManagementException, SQLException, DBConnectionException; /** * To get the comment with id. @@ -293,12 +293,12 @@ public interface CommentDAO { /** * To delete comment using comment id. * - * @param apAppCommentId 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 apAppCommentId) throws CommentManagementException, DBConnectionException, SQLException; + void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException, SQLException; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/CommentDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/CommentDAOImpl.java index bcf77f3f484..0435d269eec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/CommentDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/CommentDAOImpl.java @@ -30,13 +30,11 @@ import org.wso2.carbon.device.application.mgt.core.dao.CommentDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; - import java.sql.SQLException; import java.sql.Timestamp; import java.sql.ResultSet; import java.sql.Connection; import java.sql.PreparedStatement; -import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -122,11 +120,11 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } @Override - public Comment updateComment(int apAppCommentId, String updatedComment, String modifiedBy, Timestamp modifiedAt) + 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 ("+apAppCommentId+")"); + log.debug("Request received in DAO Layer to update the comment with ID ("+ CommentId +")"); } Connection connection; @@ -139,7 +137,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { statement = connection.prepareStatement(sql); statement.setString(1, updatedComment); statement.setString(2, modifiedBy); - statement.setInt(3, apAppCommentId); + statement.setInt(3, CommentId); statement.executeUpdate(); rs = statement.executeQuery(); @@ -147,15 +145,15 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } finally { Util.cleanupResources(statement, rs); } - return getComment(apAppCommentId); + return getComment(CommentId); } - public Comment updateComment(String uuid, int apAppCommentID,String updatedComment, String modifiedBy, Timestamp + 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 ( "+apAppCommentID+")"); + "comment id ( "+ CommentId +")"); } Connection connection; @@ -168,20 +166,20 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { statement = connection.prepareStatement(sql); statement.setString(1, updatedComment); statement.setString(2,modifiedBy); - statement.setInt(3,apAppCommentID); + statement.setInt(3, CommentId); statement.executeUpdate(); rs= statement.getResultSet(); } finally { Util.cleanupResources(statement, rs); } - return getComment(apAppCommentID); + return getComment(CommentId); } @Override - public Comment getComment(int apAppCommentId) throws CommentManagementException { + public Comment getComment(int CommentId) throws CommentManagementException { if (log.isDebugEnabled()) { - log.debug("Getting comment with the comment id(" + apAppCommentId + ") from the database"); + log.debug("Getting comment with the comment id(" + CommentId + ") from the database"); } Connection conn; PreparedStatement stmt = null; @@ -193,7 +191,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, apAppCommentId); + stmt.setInt(1, CommentId); rs=stmt.executeQuery(); if (rs.next()) { @@ -212,7 +210,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } } catch (SQLException e) { - throw new CommentManagementException("Error occurred while retrieving information of the comment "+apAppCommentId, e); + throw new CommentManagementException("Error occurred while retrieving information of the comment "+ CommentId, e); } catch (DBConnectionException e) { log.error("DB Connection Exception occurs.", e); } finally { @@ -721,7 +719,6 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } } finally { Util.cleanupResources(stmt, null); - return commentCount; } } @@ -747,7 +744,6 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } } finally { Util.cleanupResources(stmt, null); - } return commentCount; @@ -860,7 +856,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO { } @Override - public void deleteComment(int apAppCommentId) throws CommentManagementException, DBConnectionException, + public void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException, SQLException { Connection conn; @@ -869,7 +865,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, apAppCommentId); + stmt.setInt(1, CommentId); stmt.executeUpdate(); } finally { Util.cleanupResources(stmt, null); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java index 024aaa9cac6..b09a7a10297 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/CommentsManagerImpl.java @@ -84,21 +84,21 @@ public class CommentsManagerImpl implements CommentsManager { /** * To validate the pre-request of the comment * - * @param apAppCommentId ID of the comment. + * @param CommentId ID of the comment. * @param comment comment needed to be validate. * @return Application related with the UUID. * * */ - public Boolean validateComment(int apAppCommentId,String comment) throws CommentManagementException{ + public Boolean validateComment(int CommentId,String comment) throws CommentManagementException{ - if (apAppCommentId <= 0) { + if (CommentId <= 0) { throw new CommentManagementException("Comment ID is null or negative. Comment id is a required parameter to get the " + "relevant comment."); } if(comment==null){ - log.error("Null Point Exception.Comment at comment id "+apAppCommentId+" is null."); + log.error("Null Point Exception.Comment at comment id "+CommentId+" is null."); return false; } return true; @@ -136,18 +136,18 @@ public class CommentsManagerImpl implements CommentsManager { } @Override - public Comment getComment(int apAppCommentId) 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 " + apAppCommentId ); + log.debug("Comment retrieval request is received for the comment id " + CommentId); } try { ConnectionManagerUtil.openDBConnection(); - comment=ApplicationManagementDAOFactory.getCommentDAO().getComment(apAppCommentId); + comment=ApplicationManagementDAOFactory.getCommentDAO().getComment(CommentId); } catch (DBConnectionException e) { log.error("DB Connection Exception occurs.", e); } catch (SQLException e) { @@ -159,18 +159,18 @@ public class CommentsManagerImpl implements CommentsManager { } @Override - public void deleteComment(int apAppCommentId) throws CommentManagementException { + public void deleteComment(int CommentId) throws CommentManagementException { Comment comment; - comment= getComment(apAppCommentId); + comment= getComment(CommentId); if (comment == null) { throw new CommentManagementException( - "Cannot delete a non-existing comment for the application with comment id" + apAppCommentId); + "Cannot delete a non-existing comment for the application with comment id" + CommentId); } try { ConnectionManagerUtil.beginDBTransaction(); - ApplicationManagementDAOFactory.getCommentDAO().deleteComment(apAppCommentId); + ApplicationManagementDAOFactory.getCommentDAO().deleteComment(CommentId); ConnectionManagerUtil.commitDBTransaction(); } catch (DBConnectionException e) { log.error("DB Connection Exception occurs.", e); @@ -184,20 +184,20 @@ public class CommentsManagerImpl implements CommentsManager { } @Override - public Comment updateComment(Comment comment,int apAppCommentId) throws CommentManagementException, SQLException, + public Comment updateComment(Comment comment,int CommentId) throws CommentManagementException, SQLException, DBConnectionException { PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - validateComment(apAppCommentId,comment.getComment()); + validateComment(CommentId,comment.getComment()); if (log.isDebugEnabled()) { - log.debug("Comment retrieval request is received for the comment id " +apAppCommentId); + log.debug("Comment retrieval request is received for the comment id " + CommentId); } comment.setModifiedAt(Timestamp.from(Instant.now())); try { ConnectionManagerUtil.openDBConnection(); - ApplicationManagementDAOFactory.getCommentDAO().getComment(apAppCommentId); - return ApplicationManagementDAOFactory.getCommentDAO().updateComment(apAppCommentId, + ApplicationManagementDAOFactory.getCommentDAO().getComment(CommentId); + return ApplicationManagementDAOFactory.getCommentDAO().updateComment(CommentId, comment.getComment(),comment.getModifiedBy(),comment.getModifiedAt()); } catch (SQLException e) { log.error("SQL Exception occurs.", e); @@ -206,7 +206,7 @@ public class CommentsManagerImpl implements CommentsManager { } finally { ConnectionManagerUtil.closeDBConnection(); } - return ApplicationManagementDAOFactory.getCommentDAO().getComment(apAppCommentId); + return ApplicationManagementDAOFactory.getCommentDAO().getComment(CommentId); } public int getRatedUser(String uuid){