Package com.dongxuexidu.douban4j.model.review

Examples of com.dongxuexidu.douban4j.model.review.DoubanReviewEntryObj


    super(accessToken);
  }
 
  public DoubanReviewEntryObj getReviewById (long reviewId) throws DoubanException, IOException {
    String url = RequestUrls.DOUBAN_REVIEW_PREFIX + "/" + reviewId;
    DoubanReviewEntryObj result = this.client.getResponse(url, null, DoubanReviewEntryObj.class, false);
    return result;
  }
View Full Code Here


    return result;
  }

  public boolean addNewReview (long subjectId, String content, int rating, String title, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanReviewEntryObj obj = generateReviewObj(subjectId, content, rating, title, null);
    if (obj == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Review data is not correct, please double check");
    }
    try {
      int responseCode = this.client.postResponseCodeOnly(RequestUrls.DOUBAN_REVIEW_PREFIX + "s", obj, true);
View Full Code Here

    }
  }

  public boolean updateReview (long reviewId, long subjectId, String content, String title, int rating, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanReviewEntryObj obj = generateReviewObj(subjectId, content, rating, title, reviewId);
    if (obj == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Review data is not correct, please double check");
    }
    try {
      int responseCode = this.client.putResponseCodeOnly(RequestUrls.DOUBAN_REVIEW_PREFIX + "/" + reviewId, obj, true);
View Full Code Here

      }
    }
  }
 
  private DoubanReviewEntryObj generateReviewObj (long subjectId, String content, int rating, String title, Long reviewUrl) {
    DoubanReviewEntryObj obj = new DoubanReviewEntryObj();
    if (reviewUrl != null) {
      obj.setId(RequestUrls.DOUBAN_REVIEW_PREFIX + "/" + reviewUrl);
    }
    DoubanSubjectObj sub = new DoubanSubjectObj();
    sub.setId("" + subjectId);
    obj.setSubject(sub);
    if (content != null && content.length() > 0) {
      obj.setContent(content);
    } else {
      obj.setContent("");
    }
    if (title != null && title.length() > 0) {
      obj.setTitle(title);
    } else {
      obj.setTitle("");
    }
    DoubanRatingObj rat = new DoubanRatingObj();
    if (rating > 5) {
      rating = 5;
    } else if (rating < 1) {
      rating = 1;
    }
    rat.setValue(rating);
    obj.setRating(rat);
    return obj;
  }
View Full Code Here

   */
  public void testGetReviewById() throws Exception {
    System.out.println("getReviewById");
    long reviewId = 1096809;
    DoubanReviewService instance = new DoubanReviewService();
    DoubanReviewEntryObj result = instance.getReviewById(reviewId);
    assertEquals(result.getTitle(), "生活是粗砺的沙");
    assertEquals(result.getRating().getValue(), 4);
  }
View Full Code Here

TOP

Related Classes of com.dongxuexidu.douban4j.model.review.DoubanReviewEntryObj

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.