コード例 #1
0
  /**
   * 関連キーワード設定/解除
   *
   * @param isRelate true:設定/false:解除
   * @param keyword1 対象キーワード1
   * @param keyword2 対象キーワード2
   * @return 関連キーワードを設定/解除後のキーワード1のキーワード情報
   * @throws HatenaHaikuException
   * @since v0.0.1
   */
  private Keyword _modifyRelateKeyword(boolean isRelate, String keyword1, String keyword2)
      throws HatenaHaikuException {
    if (StringUtil.isSame(keyword1, keyword2)) {
      throw new HatenaHaikuException("対象キーワードに同じキーワードは指定できません。");
    }
    try {
      QueryParameter param = new QueryParameter();
      param.setWord1(keyword1);
      param.setWord2(keyword2);
      String resultXml =
          HttpUtil.doGet(
              loginUser,
              (isRelate ? URL_RELATE_KEYWORD_XML : URL_UNRELATE_KEYWORD_XML),
              param,
              isNeedHttpLog());
      return toKeyword(XmlUtil.getRootElement(resultXml));

    } catch (ParserConfigurationException e) {
      throw new HatenaHaikuException("ParserConfigurationException発生。", e);

    } catch (SAXException e) {
      throw new HatenaHaikuException("SAXException発生。", e);

    } catch (IOException e) {
      throw new HatenaHaikuException("IOException発生。", e);
    }
  }
コード例 #2
0
  /**
   * キーワードのフォローしたり、やめたりします。<br>
   * <i>http://h.hatena.ne.jp/api/keywords/destroy/<font color="red">キーワード</font>.xml</i>
   *
   * @see <a href="http://h.hatena.ne.jp/api#keywords-destroy">keywords/destroy</a>
   * @param isFollow true:フォローする/false:フォローをやめる
   * @param keyword キーワード
   * @return フォローした/やめたキーワード情報
   * @throws HatenaHaikuException
   * @since v0.0.1
   */
  private Keyword _modifyFollowKeyword(boolean isFollow, String keyword)
      throws HatenaHaikuException {
    try {
      String resultXml =
          HttpUtil.doGet(
              loginUser,
              (isFollow ? URL_FOLLOW_KEYWORD : URL_UNFOLLOW_KEYWORD)
                  + StringUtil.encode(keyword)
                  + EXT_XML,
              null,
              isNeedHttpLog());
      return toKeyword(XmlUtil.getRootElement(resultXml));

    } catch (ParserConfigurationException e) {
      throw new HatenaHaikuException("ParserConfigurationException発生。", e);

    } catch (SAXException e) {
      throw new HatenaHaikuException("SAXException発生。", e);

    } catch (IOException e) {
      throw new HatenaHaikuException("IOException発生。", e);
    }
  }