コード例 #1
0
 private void addResponseToList(
     EmoticonListResponse emoticonListResponse, final List<Emoticon> emoticons) {
   for (EmoticonListResponse.Item item : emoticonListResponse.getItems()) {
     final Emoticon newEmoticon =
         new Emoticon(
             StringEscapeUtils.escapeHtml4("(" + item.getShortcut() + ")"), item.getUrl());
     emoticons.add(newEmoticon);
   }
 }
コード例 #2
0
  public void updateEmoticons() {
    final String apiEndpoint =
        this.yaccProperties.getProperty(YaccProperties.PROPERTY_NAME_HIPCHAT_API_ENDPOINT);
    final String authToken =
        this.yaccProperties.getProperty(YaccProperties.PROPERTY_NAME_HIPCHAT_API_AUTH_TOKEN);

    EMOTICONS.clear();

    if ((apiEndpoint != null)
        && (!apiEndpoint.equals(""))
        && (authToken != null)
        && (!authToken.equals(""))) {
      Client client = ClientBuilder.newClient();

      WebTarget emoticonTarget =
          client
              .target(apiEndpoint)
              .path("emoticon")
              .queryParam("auth_token", authToken)
              .queryParam("max-results", 0);

      EmoticonListResponse emoticonListResponse = requestEmoticons(emoticonTarget);
      addResponseToList(emoticonListResponse, EMOTICONS);

      while ((null != emoticonListResponse.getLinks().getNext())
          && (emoticonListResponse.getItems().size() > 0)) {
        emoticonTarget =
            client
                .target(emoticonListResponse.getLinks().getNext())
                .queryParam("auth_token", authToken);

        emoticonListResponse = requestEmoticons(emoticonTarget);
        addResponseToList(emoticonListResponse, EMOTICONS);
      }
    }

    // Add the standard emoticons: :-), etc
    addOtherHipchatEmoticons(EMOTICONS);
  }