1 26 package org.snipsnap.net.admin; 27 28 import org.snipsnap.config.Configuration; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 import java.util.Map ; 33 34 public class SetupProxy implements SetupHandler { 35 public String getName() { 36 return "proxy"; 37 } 38 39 public Map setup(HttpServletRequest request, HttpServletResponse response, Configuration config, Map errors) { 40 String autodetect = request.getParameter(Configuration.APP_REAL_AUTODETECT) != null ? "true" : "false"; 41 config.setRealAutodetect(autodetect); 42 if ("false".equals(autodetect)) { 43 config.setRealHost(request.getParameter(Configuration.APP_REAL_HOST)); 44 String portStr = request.getParameter(Configuration.APP_REAL_PORT); 45 config.setRealPort(request.getParameter(Configuration.APP_REAL_PORT)); 46 if (portStr != null && !"".equals(portStr)) { 47 try { 48 Integer.parseInt(portStr); 49 } catch (NumberFormatException e) { 50 errors.put(Configuration.APP_REAL_PORT, Configuration.APP_REAL_PORT); 51 } 52 } 53 } 54 String realProtocol = request.getParameter(Configuration.APP_REAL_PROTOCOL); 55 if (null != realProtocol && !"".equals(realProtocol)) { 56 config.setRealProtocol(realProtocol.trim()); 57 } 58 String realPath = request.getParameter(Configuration.APP_REAL_PATH); 59 if (null != realPath && !"".equals(realPath)) { 60 realPath = realPath.trim(); 61 config.setRealPath(realPath.startsWith("/") ? realPath : "/" + realPath); 62 } 63 64 return errors; 65 } 66 } 67 | Popular Tags |