1 26 package org.snipsnap.net.admin; 27 28 import org.radeox.util.logging.LogHandler; 29 import org.radeox.util.logging.Logger; 30 import org.snipsnap.config.Configuration; 31 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 import java.util.Map ; 35 36 public class SetupExpert implements SetupHandler { 37 public String getName() { 38 return "expert"; 39 } 40 41 public Map setup(HttpServletRequest request, HttpServletResponse response, Configuration config, Map errors) { 42 config.setAuth(request.getParameter(Configuration.APP_AUTH)); 43 String startSnip = request.getParameter(Configuration.APP_START_SNIP); 44 config.setStartSnip(null == startSnip || "".equals(startSnip) ? "start" : startSnip); 45 config.setPermCreateSnip(allowDeny(request.getParameter(Configuration.APP_PERM_CREATESNIP))); 46 String logger = request.getParameter(Configuration.APP_LOGGER); 47 config.setLogger(logger != null && logger.length() > 0 ? logger : "org.radeox.util.logging.NullLogger"); 48 try { 50 Logger.setHandler((LogHandler) Class.forName(config.getLogger()).newInstance()); 51 } catch (Exception e) { 52 System.err.println("InitFilter: LogHandler not found: " + logger); 53 } 54 String cache = request.getParameter(Configuration.APP_CACHE); 55 config.setCache(cache != null && cache.length() > 0 ? cache : "full"); 56 String encoding = request.getParameter(Configuration.APP_ENCODING); 57 config.setEncoding(encoding != null && encoding.length() > 0 ? encoding : "UTF-8"); 58 59 return errors; 60 } 61 62 private String allowDeny(String value) { 63 if ("allow".equals(value)) { 64 return value; 65 } else { 66 return "deny"; 67 } 68 } 69 } 70 | Popular Tags |