Package com.dongxuexidu.douban4j.model.note

Examples of com.dongxuexidu.douban4j.model.note.DoubanNoteEntryObj


    super(accessToken);
  }

  public DoubanNoteEntryObj getNoteById(long noteId) throws DoubanException, IOException {
    String url = RequestUrls.DOUBAN_NOTE_PREFIX + "/" + noteId;
    DoubanNoteEntryObj result = this.client.getResponse(url, null, DoubanNoteEntryObj.class, false);
    return result;
  }
View Full Code Here


    return result;
  }

  public boolean createNewNote (String title, String content, boolean isPrivate, boolean canReply, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanNoteEntryObj entry = generateDoubanNoteEntry(title, content, isPrivate, canReply);
    if (entry == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Note data is not correct, please double check");
    }
    try {
      int responseCode = this.client.postResponseCodeOnly(RequestUrls.DOUBAN_NOTE_PREFIX + "s", entry, true);
View Full Code Here

    }
  }

  public boolean updateNote (long noteId, String title, String content, boolean isPrivate, boolean canReply, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanNoteEntryObj entry = generateDoubanNoteEntry(title, content, isPrivate, canReply);
    if (entry == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Note data is not correct, please double check");
    }
    try {
      int responseCode = this.client.putResponseCodeOnly(RequestUrls.DOUBAN_NOTE_PREFIX + "/" + noteId, entry, true);
View Full Code Here

      }
    }
  }
 
  private DoubanNoteEntryObj generateDoubanNoteEntry (String title, String content, boolean isPrivate, boolean canReply) {
    DoubanNoteEntryObj entry = new DoubanNoteEntryObj();
    if (title != null && title.length() > 0) {
      entry.setTitle(title);
    } else {
      return null;
    }
    if (content != null && content.length() > 0) {
      entry.setContent(content);
    } else {
      return null;
    }
    List<DoubanAttributeObj> atts = new ArrayList<DoubanAttributeObj>();
    DoubanAttributeObj privateAtt = new DoubanAttributeObj();
    privateAtt.setName("privacy");
    if (isPrivate) {
      privateAtt.setValue("private");
    } else {
      privateAtt.setValue("public");
    }
    atts.add(privateAtt);
    DoubanAttributeObj replyAtt = new DoubanAttributeObj();
    replyAtt.setName("can_reply");
    replyAtt.setValue(canReply ? "yes" : "no");
    atts.add(replyAtt);
    entry.setAttributes(atts);
    return entry;
  }
View Full Code Here

   */
  public void testGetNoteById() throws Exception {
    System.out.println("getNoteById");
    long noteId = 1231L;
    DoubanNoteService instance = new DoubanNoteService();
    DoubanNoteEntryObj result = instance.getNoteById(noteId);
    assertEquals(result.getAuthor().getName(),"张君雅");
  }
View Full Code Here

TOP

Related Classes of com.dongxuexidu.douban4j.model.note.DoubanNoteEntryObj

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.