public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException { PageNode page = ctx.getPageMaker().getPageNode("Redirect to Decoded link", ctx); HTMLNode pageNode = page.outer; HTMLNode contentNode = page.content; if (ctx.isAllowedFullAccess()) contentNode.addChild(ctx.getAlertManager().createSummary()); final String requestPath = request.getPath().substring(path().length()); // Without this it'll try to look in the current directory which will be /decode and won't work. String keyToFetch = "/" + requestPath; // This is for when a browser can't handle 301s, should very rarely (never?) be seen. ctx.getPageMaker() .getInfobox("infobox-warning", "Decode Link", contentNode, "decode-not-redirected", true) .addChild("a", "href", keyToFetch, "Click Here to be re-directed"); this.writeHTMLReply( ctx, 301, "Moved Permanently\nLocation: " + keyToFetch, pageNode.generate()); }
public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException, RedirectException, URISyntaxException { if (!normalizePath(request.getPath()).equals("/")) { sendErrorPage(ctx, 404, "Not found", "the path '" + uri + "' was not found"); return; } String key; String type; boolean automf; boolean deep; boolean ml; int hexWidth = request.getIntParam(PARAM_HEXWIDTH, Configuration.getHexWidth()); if (request.isParameterSet(PARAM_AUTOMF)) { automf = request.getParam(PARAM_AUTOMF).length() > 0; } else { automf = Configuration.getAutoMF(); } if (request.isParameterSet(Globals.PARAM_RECURSIVE)) { deep = request.getParam(Globals.PARAM_RECURSIVE).length() > 0; } else { deep = Configuration.getDeep(); } if (request.isParameterSet(Globals.PARAM_MULTILEVEL)) { ml = request.getParam(Globals.PARAM_MULTILEVEL).length() > 0; } else { ml = Configuration.getMultilevel(); } if (request.isParameterSet(Globals.PARAM_URI)) { key = request.getParam(Globals.PARAM_URI); type = request.getParam(Globals.PARAM_MFTYPE); } else { key = null; type = null; } String extraParams = "&hexwidth=" + hexWidth; if (automf) { extraParams += "&automf=checked"; } if (deep) { extraParams += "&deep=checked"; } if (ml) { extraParams += "&ml=checked"; } List<String> errors = new LinkedList<String>(); if (hexWidth < 1 || hexWidth > 1024) { errors.add("Hex display columns out of range. (1-1024). Set to 32 (default)."); hexWidth = 32; } if (Globals.MFTYPE_ZIP.equals(type)) { throw new RedirectException( KeyUtilsPlugin.PLUGIN_URI + "/Site/?mftype=ZIPmanifest&key=" + key + extraParams); } if (Globals.MFTYPE_TAR.equals(type)) { throw new RedirectException( KeyUtilsPlugin.PLUGIN_URI + "/Site/?mftype=TARmanifest&key=" + key + extraParams); } if (Globals.MFTYPE_SIMPLE.equals(type)) { throw new RedirectException( KeyUtilsPlugin.PLUGIN_URI + "/Site/?mftype=simplemanifest&key=" + key + extraParams); } makeMainPage(ctx, errors, key, hexWidth, automf, deep, ml); }