Package com.dongxuexidu.douban4j.model.event

Examples of com.dongxuexidu.douban4j.model.event.DoubanEventEntryObj


    super(accessToken);
  }

  public DoubanEventEntryObj getEventById(long eventId) throws DoubanException, IOException {
    String url = RequestUrls.DOUBAN_EVENT_PREFIX + "/" + eventId;
    DoubanEventEntryObj result = this.client.getResponse(url, null, DoubanEventEntryObj.class, false);
    return result;
  }
View Full Code Here


  }
 
  @UnTested
  public boolean updateEvent(long eventId, String title, EventType type, String content, boolean inviteOnly, boolean canInvite, Date startTime, Date endTime, String where, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanEventEntryObj entry = generateEventEntryObj(title, type, content, inviteOnly, canInvite, startTime, endTime, where);
    if (entry == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Illegal event data provided");
    }
    try {
      int responseCode = this.client.putResponseCodeOnly(RequestUrls.DOUBAN_EVENT_PREFIX + "/" + eventId, entry, true);
View Full Code Here

  }

  @UnTested
  public boolean postNewEvent(String title, EventType type, String content, boolean inviteOnly, boolean canInvite, Date startTime, Date endTime, String where, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanEventEntryObj entry = generateEventEntryObj(title, type, content, inviteOnly, canInvite, startTime, endTime, where);
    System.out.println("cat string : " + Converters.parseDoubanObjToXMLStr(entry));
    if (entry == null) {
      throw ErrorHandler.getCustomDoubanException(100, "Illegal event data provided");
    }
    try {
View Full Code Here

  }
 
  @UnTested
  public boolean deleteEvent (long eventId, String content, String accessToken) throws DoubanException, IOException {
    setAccessToken(accessToken);
    DoubanEventEntryObj entry = new DoubanEventEntryObj();
    entry.setContent(content);
    String url = RequestUrls.DOUBAN_EVENT_PREFIX + "/" + eventId + "/delete";
    try {
      int responseCode = this.client.postResponseCodeOnly(url, entry, true);
      if (responseCode != StatusCode.HTTP_STATUS_OK) {
        return false;
View Full Code Here

      }
    }
  }

  private DoubanEventEntryObj generateEventEntryObj(String title, EventType type, String content, boolean inviteOnly, boolean canInvite, Date startTime, Date endTime, String where) {
    DoubanEventEntryObj entry = new DoubanEventEntryObj();
    if (title != null && title.length() > 0) {
      entry.setTitle(title);
    } else {
      return null;
    }
    if (content != null && content.length() > 0) {
      entry.setContent(content);
    } else {
      return null;
    }
    if (type == null) {
      return null;
    }
    String typeStr = "http://www.douban.com/2007#event." + type.getValue();
   
    //<category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#event.music"/>
    DoubanCategoryObj cat = new DoubanCategoryObj();
    cat.setScheme("http://www.douban.com/2007#kind");
    cat.setTerm(typeStr);
    entry.setCategory(cat);
    DoubanAttributeObj inviteOnlyAtt = new DoubanAttributeObj();
    inviteOnlyAtt.setName("invite_only");
    DoubanAttributeObj canInviteAtt = new DoubanAttributeObj();
    canInviteAtt.setName("can_invite");
    if (inviteOnly) {
      inviteOnlyAtt.setValue("yes");
    } else {
      inviteOnlyAtt.setValue("no");
    }
    if (canInvite) {
      canInviteAtt.setValue("yes");
    } else {
      canInviteAtt.setValue("no");
    }
    List<DoubanAttributeObj> atts = new ArrayList<DoubanAttributeObj>();
    atts.add(canInviteAtt);
    atts.add(inviteOnlyAtt);
    entry.setAttrs(atts);
    if (startTime.after(endTime)) {
      return null;
    }
    String startTimeStr = Converters.convertDateToStringInRFC3339(startTime);
    String endTimeStr = Converters.convertDateToStringInRFC3339(endTime);
    DoubanWhenObj when = new DoubanWhenObj();
    when.setStartTime(startTimeStr);
    when.setEndTime(endTimeStr);
    entry.setWhen(when);
    DoubanWhereObj whereObj = new DoubanWhereObj();
    whereObj.setValue(where);
    entry.setWhere(whereObj);
    return entry;
  }
View Full Code Here

TOP

Related Classes of com.dongxuexidu.douban4j.model.event.DoubanEventEntryObj

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.