mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Reformatted the code.
This commit is contained in:
parent
1bbd0b1aa5
commit
3bfb2addbb
@ -69,10 +69,9 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
}
|
||||
} catch (NotFoundException e) {
|
||||
log.error("Not found exception occurs to uuid " + uuid + " .", e);
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity("Application with UUID " + uuid + " not found").build();
|
||||
}
|
||||
catch (CommentManagementException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND).entity("Application with UUID " + uuid + " not found")
|
||||
.build();
|
||||
} catch (CommentManagementException e) {
|
||||
String msg = "Error occurred while retrieving comments.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
@ -115,7 +114,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
@PathParam("CommentId") int CommentId) {
|
||||
|
||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||
|
||||
try {
|
||||
if (CommentId == 0) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
@ -151,8 +149,7 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).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();
|
||||
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();
|
||||
}
|
||||
@ -166,7 +163,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
|
||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||
int Stars = 0;
|
||||
|
||||
try {
|
||||
Stars = commentsManager.getStars(uuid);
|
||||
} catch (CommentManagementException e) {
|
||||
@ -188,7 +184,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
|
||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||
int ratedUsers = 0;
|
||||
|
||||
try {
|
||||
ratedUsers = commentsManager.getRatedUser(uuid);
|
||||
} catch (CommentManagementException e) {
|
||||
@ -210,7 +205,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
|
||||
|
||||
CommentsManager commentsManager = APIUtil.getCommentsManager();
|
||||
int newStars = 0;
|
||||
|
||||
try {
|
||||
newStars = commentsManager.updateStars(stars, uuid);
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ public class Comment {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -18,9 +18,6 @@
|
||||
|
||||
package org.wso2.carbon.device.application.mgt.common;
|
||||
|
||||
|
||||
import org.apache.commons.fileupload.MultipartStream;
|
||||
|
||||
/**
|
||||
* This class holds required parameters for a querying a paginated device response.
|
||||
*/
|
||||
@ -60,9 +57,7 @@ public class PaginationRequest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@Override public String toString() {
|
||||
return "Off Set'" + this.offSet + "' row count '" + this.limit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,23 @@
|
||||
/*
|
||||
* 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.common.exception;
|
||||
|
||||
import org.wso2.carbon.device.application.mgt.common.Comment;
|
||||
|
||||
public class CommentManagementException extends Exception {
|
||||
private String message;
|
||||
|
||||
@ -18,8 +34,8 @@ public class CommentManagementException extends Exception{
|
||||
public CommentManagementException() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
|
||||
@Override public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@ -23,11 +23,11 @@ import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.application.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.application.mgt.common.exception.CommentManagementException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CommentsManager is responsible for handling all the add/update/delete/get operations related with
|
||||
*
|
||||
*/
|
||||
public interface CommentsManager {
|
||||
|
||||
@ -49,7 +49,6 @@ public interface CommentsManager {
|
||||
* @param comment comment needed to be validate.
|
||||
* @return validated the comment.
|
||||
* @throws CommentManagementException Exceptions of the comment management.
|
||||
*
|
||||
*/
|
||||
Boolean validateComment(int CommentId, String comment) throws CommentManagementException;
|
||||
|
||||
@ -63,7 +62,6 @@ public interface CommentsManager {
|
||||
*/
|
||||
List<Comment> getAllComments(PaginationRequest request, String uuid) throws CommentManagementException;
|
||||
|
||||
|
||||
/**
|
||||
* To get the comment with id.
|
||||
*
|
||||
@ -81,7 +79,6 @@ public interface CommentsManager {
|
||||
*/
|
||||
void deleteComment(int CommentId) throws CommentManagementException;
|
||||
|
||||
|
||||
/**
|
||||
* To update a comment.
|
||||
*
|
||||
|
||||
@ -24,8 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
/**
|
||||
* This class represents the information related to Pagination configuration.
|
||||
*/
|
||||
@XmlRootElement(name = "PaginationConfiguration")
|
||||
public class PaginationConfiguration {
|
||||
@XmlRootElement(name = "PaginationConfiguration") public class PaginationConfiguration {
|
||||
|
||||
private int commentListPageSize;
|
||||
|
||||
@ -33,8 +32,8 @@ public class PaginationConfiguration {
|
||||
return commentListPageSize;
|
||||
}
|
||||
|
||||
@XmlElement(name = "commentListPageSize", required = true)
|
||||
public void setCommentListPageSize(int commentListPageSize) {
|
||||
@XmlElement(name = "commentListPageSize", required = true) public void setCommentListPageSize(
|
||||
int commentListPageSize) {
|
||||
this.commentListPageSize = commentListPageSize;
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +32,7 @@ import java.util.List;
|
||||
* This interface specifies the database access operations performed for comments.
|
||||
*/
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public interface CommentDAO {
|
||||
@SuppressWarnings("ALL") public interface CommentDAO {
|
||||
|
||||
/**
|
||||
* To add a comment to a application.
|
||||
@ -47,7 +46,8 @@ public interface CommentDAO {
|
||||
* @throws CommentManagementException Exceptions of the comment management.
|
||||
* @throws DBConnectionException db connection exception.
|
||||
*/
|
||||
int addComment(int tenantId , Comment comment, String createdBy, int parentId, String uuid) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int addComment(int tenantId, Comment comment, String createdBy, int parentId, String uuid)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To add a comment to a application.
|
||||
@ -60,7 +60,8 @@ public interface CommentDAO {
|
||||
* @return comment id
|
||||
* @throws CommentManagementException Exceptions of the comment management.
|
||||
*/
|
||||
int addComment(int tenantId, Comment comment,String createdBy,String appType,String appName,String version) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int addComment(int tenantId, Comment comment, String createdBy, String appType, String appName, String version)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To update already added comment.
|
||||
@ -74,7 +75,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
Comment updateComment(int CommentId, 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.
|
||||
@ -89,7 +91,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
Comment updateComment(String uuid, int CommentId,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.
|
||||
@ -123,7 +126,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception
|
||||
* @throws SQLException sql exception
|
||||
**/
|
||||
List<Comment> getAllComments(String uuid,PaginationRequest request) throws CommentManagementException, SQLException, DBConnectionException;
|
||||
List<Comment> getAllComments(String uuid, PaginationRequest request)
|
||||
throws CommentManagementException, SQLException, DBConnectionException;
|
||||
|
||||
/**
|
||||
* To get list of comments using release id and application id.
|
||||
@ -146,7 +150,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getComments(String appType,String appName,String version) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getComments(String appType, String appName, String version)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get list of comments using tenant id.
|
||||
@ -168,7 +173,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getCommentsByUser(String createdBy) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getCommentsByUser(String createdBy)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get list of comments by created use and created time.
|
||||
@ -180,7 +186,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getCommentsByUser(String createdBy,Timestamp createdAt) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getCommentsByUser(String createdBy, Timestamp createdAt)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get list of comments by modified users.
|
||||
@ -191,7 +198,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getCommentsByModifiedUser(String modifiedBy) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getCommentsByModifiedUser(String modifiedBy)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get list of comments using modified user's name and modified time.
|
||||
@ -203,7 +211,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getCommentsByModifiedUser(String modifiedBy,Timestamp modifiedAt) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getCommentsByModifiedUser(String modifiedBy, Timestamp modifiedAt)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get list of comments using application type, application name , application version and parent id of the comment.
|
||||
@ -217,7 +226,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
List<Comment> getComments(String appType,String appName,String version,int parentId) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
List<Comment> getComments(String appType, String appName, String version, int parentId)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get a count of the comments by usernames.
|
||||
@ -251,7 +261,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
int getCommentCountByParent(String uuid,int parentId) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int getCommentCountByParent(String uuid, int parentId)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get a count of comments by modification details.
|
||||
@ -263,7 +274,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
int getCommentCountByUser(String modifiedBy,Timestamp modifedAt) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int getCommentCountByUser(String modifiedBy, Timestamp modifedAt)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get count of comments by application versions.
|
||||
@ -275,7 +287,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
int getCommentCountByApp(int appId, int appReleaseId) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int getCommentCountByApp(int appId, int appReleaseId)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To get count of comments by application details.
|
||||
@ -288,7 +301,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
int getCommentCountByApp(String appType,String appName,String version) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
int getCommentCountByApp(String appType, String appName, String version)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To delete comment using comment id.
|
||||
@ -300,7 +314,6 @@ public interface CommentDAO {
|
||||
*/
|
||||
void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
|
||||
/**
|
||||
* To delete comment using comment id.
|
||||
*
|
||||
@ -320,7 +333,8 @@ public interface CommentDAO {
|
||||
* @throws DBConnectionException db connection exception.
|
||||
* @throws SQLException sql exception
|
||||
*/
|
||||
void deleteComments(int appId,int appReleaseID) throws CommentManagementException, DBConnectionException, SQLException;
|
||||
void deleteComments(int appId, int appReleaseID)
|
||||
throws CommentManagementException, DBConnectionException, SQLException;
|
||||
|
||||
/**
|
||||
* To delete comments using application details.
|
||||
@ -341,8 +355,8 @@ public interface CommentDAO {
|
||||
* @param createdBy Username of the created person.
|
||||
* @throws CommentManagementException Exceptions of the comment management.
|
||||
*/
|
||||
void deleteComments(String appType,String appName,String version,String createdBy)throws CommentManagementException;
|
||||
|
||||
void deleteComments(String appType, String appName, String version, String createdBy)
|
||||
throws CommentManagementException;
|
||||
|
||||
/**
|
||||
* To delete comments by parent id of the comment.
|
||||
@ -353,7 +367,6 @@ public interface CommentDAO {
|
||||
*/
|
||||
void deleteComments(String uuid, int parentId) throws CommentManagementException;
|
||||
|
||||
|
||||
/**
|
||||
* To add the star rating to the application.
|
||||
*
|
||||
|
||||
@ -236,7 +236,6 @@ public class ApplicationManagementDAOFactory {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static CommentDAO getCommentDAO() {
|
||||
if (databaseEngine != null) {
|
||||
switch (databaseEngine) {
|
||||
@ -250,6 +249,7 @@ public class ApplicationManagementDAOFactory {
|
||||
}
|
||||
throw new IllegalStateException("Database engine has not initialized properly.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagem
|
||||
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
|
||||
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
@ -41,8 +42,7 @@ import java.util.List;
|
||||
/**
|
||||
* This class is the default implementation for the Managing the comments.
|
||||
*/
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public class CommentsManagerImpl implements CommentsManager {
|
||||
@SuppressWarnings("deprecation") public class CommentsManagerImpl implements CommentsManager {
|
||||
|
||||
private static final Log log = LogFactory.getLog(CommentsManagerImpl.class);
|
||||
private CommentDAO commentDAO;
|
||||
@ -86,14 +86,14 @@ public class CommentsManagerImpl implements CommentsManager {
|
||||
* @param comment comment needed to be validate.
|
||||
* @return Application related with the UUID.
|
||||
* @throws CommentManagementException Exceptions of the comment management.
|
||||
*
|
||||
*/
|
||||
|
||||
public Boolean validateComment(int CommentId, String comment) throws CommentManagementException {
|
||||
|
||||
if (CommentId <= 0) {
|
||||
throw new CommentManagementException("Comment ID is null or negative. Comment id is a required parameter to get the " +
|
||||
"relevant comment.");
|
||||
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 " + CommentId + " is null.");
|
||||
@ -102,7 +102,6 @@ public class CommentsManagerImpl implements CommentsManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Comment> getAllComments(PaginationRequest request, String uuid) throws CommentManagementException {
|
||||
|
||||
@ -110,7 +109,6 @@ public class CommentsManagerImpl implements CommentsManager {
|
||||
List<Comment> comments;
|
||||
request = Util.validateCommentListPageSize(request);
|
||||
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("get all comments of the application release" + uuid);
|
||||
}
|
||||
@ -205,6 +203,7 @@ public class CommentsManagerImpl implements CommentsManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRatedUser(String uuid) throws ApplicationManagementException {
|
||||
|
||||
int ratedUsers = 0;
|
||||
@ -268,7 +267,6 @@ public class CommentsManagerImpl implements CommentsManager {
|
||||
} catch (ApplicationManagementDAOException e) {
|
||||
ConnectionManagerUtil.rollbackDBTransaction();
|
||||
throw new ApplicationManagementException("Application Management Exception occurs.", e);
|
||||
|
||||
} catch (DBConnectionException e) {
|
||||
throw new ApplicationManagementException("DB Connection Exception occurs.", e);
|
||||
} finally {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user