@Test public void testAccept() throws Exception { int result = reviewService.accept(1L, "testuser", new ReviewRequest("local_test", "/test/sub1", 0, 0, ReviewStatus.ACCEPTED.getValue(), "testuser", "testuser", new Date(), Action.UPDATE.getValue())); Assert.assertNotEquals(0, result); }
@Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); } }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); }  }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); }  @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); }  @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id);  }