|
|
@ -68,13 +68,15 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
commentDAO.addComment(tenantId,comment, comment.getCreatedBy(),comment.getParent(),uuid);
|
|
|
|
commentDAO.addComment(tenantId,comment, comment.getCreatedBy(),comment.getParent(),uuid);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
return comment;
|
|
|
|
return comment;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("Exception occurs.", e);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new CommentManagementException("DB Connection Exception occurs.",e);
|
|
|
|
|
|
|
|
} catch (SQLException | TransactionManagementException e){
|
|
|
|
|
|
|
|
throw new CommentManagementException("SQL Exception occurs.",e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return comment;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -102,8 +104,7 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Comment> getAllComments(PaginationRequest request,String uuid) throws CommentManagementException,
|
|
|
|
public List<Comment> getAllComments(PaginationRequest request,String uuid) throws CommentManagementException {
|
|
|
|
SQLException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PaginationResult paginationResult = new PaginationResult();
|
|
|
|
PaginationResult paginationResult = new PaginationResult();
|
|
|
|
List<Comment> comments;
|
|
|
|
List<Comment> comments;
|
|
|
@ -124,11 +125,12 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
|
|
|
|
|
|
|
|
return comments;
|
|
|
|
return comments;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("DB Connection Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} catch (SQLException e){
|
|
|
|
|
|
|
|
throw new CommentManagementException("SQL Exception occurs.",e);
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -145,9 +147,9 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
comment=commentDAO.getComment(CommentId);
|
|
|
|
comment=commentDAO.getComment(CommentId);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("DB Connection Exception occurs.", e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
log.error("SQL Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("SQL Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -169,19 +171,18 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
commentDAO.deleteComment(CommentId);
|
|
|
|
commentDAO.deleteComment(CommentId);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("DB Connection Exception occurs.", e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
log.error("SQL Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("SQL Exception occurs.", e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
log.error("Transaction Management Exception occurs.", e);
|
|
|
|
throw new CommentManagementException("Transaction Management Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Comment updateComment(Comment comment,int CommentId) throws CommentManagementException, SQLException,
|
|
|
|
public Comment updateComment(Comment comment,int CommentId) throws CommentManagementException {
|
|
|
|
DBConnectionException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
validateComment(CommentId,comment.getComment());
|
|
|
|
validateComment(CommentId,comment.getComment());
|
|
|
@ -193,13 +194,18 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
commentDAO.getComment(CommentId);
|
|
|
|
commentDAO.getComment(CommentId);
|
|
|
|
return commentDAO.updateComment(CommentId, comment.getComment(),comment.getModifiedBy(),comment.getModifiedAt());
|
|
|
|
return commentDAO
|
|
|
|
} finally {
|
|
|
|
.updateComment(CommentId, comment.getComment(), comment.getModifiedBy(), comment.getModifiedAt());
|
|
|
|
|
|
|
|
} catch (SQLException e){
|
|
|
|
|
|
|
|
throw new CommentManagementException("SQL Exception occurs.",e);
|
|
|
|
|
|
|
|
}catch (DBConnectionException e){
|
|
|
|
|
|
|
|
throw new CommentManagementException("DB Connection occurs.",e);
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getRatedUser(String uuid){
|
|
|
|
public int getRatedUser(String uuid) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
int ratedUsers=0;
|
|
|
|
int ratedUsers=0;
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -209,9 +215,9 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ratedUsers =commentDAO.getRatedUser(uuid);
|
|
|
|
ratedUsers =commentDAO.getRatedUser(uuid);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("DB Connection Exception occurs",e);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
log.error("Application Management Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("Application Management Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -219,7 +225,7 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getStars(String uuid) throws SQLException {
|
|
|
|
public int getStars(String uuid) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
int stars=0;
|
|
|
|
int stars=0;
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -229,10 +235,10 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
stars= commentDAO.getStars(uuid);
|
|
|
|
stars= commentDAO.getStars(uuid);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("DB Connection Exception occurs",e);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
log.error("Application Management Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("Application Management Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stars;
|
|
|
|
return stars;
|
|
|
@ -261,14 +267,14 @@ public class CommentsManagerImpl implements CommentsManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
log.error("Application Management Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("Application Management Exception occurs.", e);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
throw new ApplicationManagementException("DB Connection Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newStars;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|