Example #1
0
  private String generatePostToFeedHtml(
      final String shortMessage, final String originalMessage, final FeedType type)
      throws UnsupportedEncodingException {
    final StringBuilder sb = new StringBuilder(MAX_LENGTH + OFFSET);
    final String start = "<p style=\"white-space: normal;width:150px\"><img style=\"float:left;\" ";
    switch (type) {
      case error:
        sb.append(start)
            .append("src=\"")
            .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest()))
            .append("/resources/images/symbol-error.png\" width=\"35\" height=\"35\">");

        break;
      case system:
        sb.append(start)
            .append("src=\"")
            .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest()))
            .append("/resources/images/logo.png\"  width=\"40\" height=\"40\">");
        break;
      case info:
        sb.append(start)
            .append("src=\"")
            .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest()))
            .append("/resources/images/info.png\" width=\"35\" height=\"35\">");
        break;
      case data:
        sb.append(start)
            .append("src=\"")
            .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest()))
            .append("/resources/images/point_ok.png\" width=\"40\" height=\"40\">");
        break;
      default:
        sb.append(start)
            .append("src=\"")
            .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest()))
            .append("/resources/images/logo.png\" width=\"40\" height=\"40\">");
    }

    final String shortenedOriginal =
        originalMessage.length() > MAX_LENGTH
            ? originalMessage.substring(0, MAX_LENGTH)
            : originalMessage;

    sb.append("<a href=\"#\" onclick=\"window.open('feed.html?content=")
        .append(URLEncoder.encode(shortenedOriginal, Const.CONST_ENCODING))
        .append("');\">")
        .append("<span>")
        .append(new Date())
        .append("</span>")
        .append("<br /></a>")
        .append(shortMessage)
        .append("</p>");
    return sb.toString();
  }
Example #2
0
  public String postFile(URLFetchService us, List<PostObj> postobjlist) throws Exception {
    int index;

    Gson gson;
    String linkID;
    List<String> linkList;
    HTTPRequest req;
    String param;

    gson = new Gson();

    linkID = createUID();
    linkList = new ArrayList<String>();
    for (index = 0; index < postobjlist.size(); index++) {
      linkList.add(postobjlist.get(index).filelink);
    }

    param =
        URLEncoder.encode("postlist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(postobjlist), "UTF-8")
            + '&'
            + URLEncoder.encode("linkid", "UTF-8")
            + "="
            + URLEncoder.encode(linkID, "UTF-8")
            + '&'
            + URLEncoder.encode("linklist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(linkList), "UTF-8");
    req =
        new HTTPRequest(
            new URL("http://tnfshmoe.appspot.com/postdf89ksfxsyx9sfdex09usdjksd"), HTTPMethod.POST);
    req.setPayload(param.getBytes());
    us.fetch(req);

    return linkID;
  }