@Test public void testRejectIfExpired() throws Exception { reviewService.rejectIfExpired(new ReviewRequest("local_test", "/test/sub1", 0, 0, ReviewStatus.ACCEPTED.getValue(), "testuser", "testuser", new Date(), Action.UPDATE.getValue())); }
@Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } } }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } }  }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } }  @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 void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } }  @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);  }