Modified CommentManagerImpl

Changed the messages of the Exceptions.
merge-requests/7/head
nishadi 7 years ago
parent 62ac3455dd
commit c35ccf9888

@ -70,13 +70,18 @@ public class CommentsManagerImpl implements CommentsManager {
return comment; return comment;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new CommentManagementException("DB Connection Exception occurs.", e); throw new CommentManagementException(
} catch (SQLException | TransactionManagementException e) { "DB Connection error occurs ,Comment for application with UUID " + uuid + "cannot add.", e);
throw new CommentManagementException("SQL Exception occurs.", e); } catch (SQLException e) {
throw new CommentManagementException(
"SQL Exception occurs,Comment for application with UUID " + uuid + "cannot add.", e);
} catch (TransactionManagementException e) {
throw new CommentManagementException(
"Transaction Management Exception occurs,Comment for application with UUID " + uuid + "cannot add.",
e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
/** /**
@ -96,14 +101,15 @@ public class CommentsManagerImpl implements CommentsManager {
+ "relevant comment."); + "relevant comment.");
} }
if (comment == null) { if (comment == null) {
log.error("Null Point Exception.Comment at comment id " + CommentId + " is null."); log.error("Comment can not be null, but Comment at comment id " + CommentId + " is null.");
return false; return false;
} }
return true; return true;
} }
@Override @Override
public List<Comment> getAllComments(PaginationRequest request, String uuid) throws CommentManagementException { public List<Comment> getAllComments(PaginationRequest request, String uuid)
throws CommentManagementException {
PaginationResult paginationResult = new PaginationResult(); PaginationResult paginationResult = new PaginationResult();
List<Comment> comments; List<Comment> comments;
@ -123,9 +129,11 @@ public class CommentsManagerImpl implements CommentsManager {
return comments; return comments;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new CommentManagementException("DB Connection Exception occurs.", e); throw new CommentManagementException(
"DB Connection error occurs ,Comments of application with UUID " + uuid + "cannot get.", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new CommentManagementException("SQL Exception occurs.", e); throw new CommentManagementException(
"SQL Exception occurs,Comments of application with UUID " + uuid + "cannot get.", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -145,17 +153,18 @@ public class CommentsManagerImpl implements CommentsManager {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
comment = commentDAO.getComment(CommentId); comment = commentDAO.getComment(CommentId);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new CommentManagementException("DB Connection Exception occurs.", e); throw new CommentManagementException(
"DB Connection error occurs ,Comment with comment id " + CommentId + "cannot get.", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new CommentManagementException("SQL Exception occurs.", e); throw new CommentManagementException(
"SQL Exception occurs,Comment with comment id " + CommentId + "cannot get.", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
return comment; return comment;
} }
@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);
@ -169,11 +178,14 @@ public class CommentsManagerImpl implements CommentsManager {
commentDAO.deleteComment(CommentId); commentDAO.deleteComment(CommentId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new CommentManagementException("DB Connection Exception occurs.", e); throw new CommentManagementException(
"DB Connection error occurs deleting comment with comment id " + CommentId + ".", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new CommentManagementException("SQL Exception occurs.", e); throw new CommentManagementException("SQL error occurs deleting comment with comment id " + CommentId + ".",
e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new CommentManagementException("Transaction Management Exception occurs.", e); throw new CommentManagementException(
"Transaction Management Exception occurs deleting comment with comment id " + CommentId + ".", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -195,9 +207,11 @@ public class CommentsManagerImpl implements CommentsManager {
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 Exception occurs.", e); throw new CommentManagementException("SQL Error occurs updating comment with comment id " + CommentId + ".",
e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new CommentManagementException("DB Connection occurs.", e); throw new CommentManagementException(
"DB Connection error occurs updating comment with comment id " + CommentId + ".", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -213,10 +227,9 @@ public class CommentsManagerImpl implements CommentsManager {
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
ratedUsers = commentDAO.getRatedUser(uuid); ratedUsers = commentDAO.getRatedUser(uuid);
} catch (DBConnectionException e) {
throw new ApplicationManagementException("DB Connection Exception occurs", e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
throw new ApplicationManagementException("Application Management Exception occurs.", e); throw new ApplicationManagementException(
"Rated Users of the Application with UUID " + uuid + " can not get.", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -233,10 +246,9 @@ public class CommentsManagerImpl implements CommentsManager {
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
stars = commentDAO.getStars(uuid); stars = commentDAO.getStars(uuid);
} catch (DBConnectionException e) {
throw new ApplicationManagementException("DB Connection Exception occurs", e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
throw new ApplicationManagementException("Application Management Exception occurs.", e); throw new ApplicationManagementException(
"Average stars of the Application with UUID " + uuid + " can not get.", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -266,9 +278,8 @@ public class CommentsManagerImpl implements CommentsManager {
} }
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException("Application Management Exception occurs.", e); throw new ApplicationManagementException(
} catch (DBConnectionException e) { "Updated average stars of the Application with UUID " + uuid + " can not get.", e);
throw new ApplicationManagementException("DB Connection Exception occurs.", e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }

Loading…
Cancel
Save