コード例 #1
0
  static void returnOembed(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String url = request.getParameter("url");
    if (url == null) throw new Exception("No subject URL found.");

    String retUrl = request.getParameter(S3Servlet.URL_PARAM);
    if (retUrl == null && !S3Servlet.testing)
      throw new Exception("Recieved no launch presentation return url");

    Enumeration<String> en = request.getParameterNames();
    ArrayList<String> keys = new ArrayList<String>(), vals = new ArrayList<String>();

    String key, value;
    while (en.hasMoreElements()) {
      key = en.nextElement();
      if ("action".equals(key)) continue;
      if ("launch_presentation_return_url".equals(key)) continue;
      if ("url".equals(key)) continue;

      if ((value = request.getParameter(key)) != null) {
        keys.add(key);
        vals.add(value);
      } // if//
    } // while//

    String endpoint =
        S3Servlet.makeUrl(
            S3Servlet.server + S3Servlet.prefix + "/" + S3Action.oembed,
            keys.toArray(new String[keys.size()]),
            vals.toArray(new String[vals.size()]));

    String oembedUrl =
        S3Servlet.makeUrl(
            retUrl,
            new String[] {"embed_type", "endpoint", "url"},
            new String[] {"oembed", endpoint, url});

    response.reset();
    response.sendRedirect(oembedUrl);
  } // returnOembed//
コード例 #2
0
  static void flashOrLink(HttpServletRequest request, S3Action action) throws Exception {
    String oembed = request.getParameter("url");

    String[] temp = S3Servlet.parseS3Url(oembed);
    String bucket = temp[0];
    String key = temp[1];
    String prefix = key.contains("/") ? key.substring(0, key.lastIndexOf("/")) : "";

    String retUrl = request.getParameter(S3Servlet.URL_PARAM);
    if (retUrl == null && !S3Servlet.testing)
      throw new Exception("Recieved no launch presentation return url");

    request.setAttribute("action", prefix + "/" + action);
    request.setAttribute(S3Servlet.URL_PARAM, retUrl);
    request.setAttribute("url", oembed);
    request.setAttribute(
        "base", (S3Servlet.cloudBucket.equals(bucket) ? "" : "/" + bucket) + "/" + prefix);
  } // flashOrLink//
コード例 #3
0
  static void returnLink(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String url = request.getParameter("url");
    if (url == null) throw new Exception("No subject URL found.");

    String text = request.getParameter("text");
    if (text == null) throw new Exception("No link text found.");

    String retUrl = request.getParameter(S3Servlet.URL_PARAM);
    if (retUrl == null && !S3Servlet.testing)
      throw new Exception("Recieved no launch presentation return url");

    String title = request.getParameter("title");
    String target = request.getParameter("target") == null ? "null" : "_blank";

    String oembedUrl =
        S3Servlet.makeUrl(
            retUrl,
            new String[] {"embed_type", "url", "title", "text", "target"},
            new String[] {"link", url, title, text, target});

    response.reset();
    response.sendRedirect(oembedUrl);
  } // returnLink//