static void media(HttpServletRequest request, HttpServletResponse response) throws Exception { String bucket = request.getParameter("bucket"); String key = request.getParameter("key"); String retUrl = request.getParameter(S3Servlet.URL_PARAM); if (retUrl == null && !S3Servlet.testing) throw new Exception("Recieved no launch presentation return url"); AmazonS3Client s3 = new AmazonS3Client(S3Servlet.cred); int[] dim = MediaHandler.getMediaDimensions(bucket, key, s3); int width = dim[0]; int height = dim[1]; response.sendRedirect(MediaHandler.getMediaRedirect(bucket, key, retUrl, width, height, s3)); } // image//
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//
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//