- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 31 Aug 2009 11:35:57 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv31198/src/org/w3c/unicorn/action Modified Files: InitAction.java Log Message: Initialization now throws Exceptions and stops if a fatal error is encountered + separated init tasks on InitAction Index: InitAction.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/InitAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- InitAction.java 28 Aug 2009 12:40:09 -0000 1.2 +++ InitAction.java 31 Aug 2009 11:35:55 -0000 1.3 @@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse; import org.w3c.unicorn.Framework; +import org.w3c.unicorn.exceptions.InitializationFailedException; import org.w3c.unicorn.util.Property; /** @@ -28,51 +29,114 @@ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // If PROPERTY_INIT_ACTION is not set or set to true, InitAction is only accessible from localhost. - // If PROPERTY_INIT_ACTION is set to true, any IP can initialize Unicorn. This should not be set in production environment. + // If PROPERTY_INIT_ACTION is set to false, any IP can initialize Unicorn. This should not be set in production environment. String isProtected = Property.get("PROTECT_INIT_ACTION"); if ((isProtected == null || isProtected.equals("true")) && (request.getRemoteAddr().equals("0:0:0:0:0:0:0:1") || request.getRemoteAddr().equals("127.0.0.1")) || (isProtected != null && isProtected.equals("false"))) { response.setContentType("text/plain"); PrintWriter out = response.getWriter(); - out.write("Initializing core: "); - response.flushBuffer(); - Framework.initCore(); - - out.write("OK\nLoading config files: "); - response.flushBuffer(); - Framework.initConfig(); - - out.write("OK\nInitializing unmarshallers: "); - response.flushBuffer(); - Framework.initUnmarshallers(); + String task = request.getParameter("task"); - out.write("OK\nInitializing response parsers: "); - response.flushBuffer(); - Framework.initResponseParsers(); + if (task == null || task.equals("all")) { + out.write("Initializing core: "); + response.flushBuffer(); + try { + Framework.initCore(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + + out.write("Loading config files: "); + response.flushBuffer(); + try { + Framework.initConfig(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + + out.write("Initializing unmarshallers: "); + response.flushBuffer(); + Framework.initUnmarshallers(); + out.write("OK\n"); + + out.write("Initializing response parsers: "); + response.flushBuffer(); + try { + Framework.initResponseParsers(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + } - out.write("OK\nLoading observers: "); - response.flushBuffer(); - Framework.initObservers(); + if (task == null || task.equals("all") || task.equals("observers")) { + out.write("Loading observers: "); + response.flushBuffer(); + try { + Framework.initObservers(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + } - out.write("OK\nLoading tasklist: "); - response.flushBuffer(); - Framework.initTasklists(); + if (task == null || task.equals("all") || task.equals("tasklist")) { + out.write("Loading tasklist: "); + response.flushBuffer(); + try { + Framework.initTasklists(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + } - out.write("OK\nLoading language files: "); - response.flushBuffer(); - Framework.initLanguages(); + if (task == null || task.equals("all") || task.equals("language")) { + out.write("Loading language files: "); + response.flushBuffer(); + try { + Framework.initLanguages(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + + out.write("Initializing Velocity: "); + response.flushBuffer(); + try { + Framework.initVelocity(); + out.write("OK\n"); + } catch (InitializationFailedException e) { + Framework.logger.fatal(e.getMessage(), e); + out.write("FAILED\n" + e); + return; + } + } - out.write("OK\nInitializing Velocity: "); - response.flushBuffer(); - Framework.initVelocity(); - out.write("OK"); out.close(); } else response.sendError(403, "You are not allowed to execute this action."); } - - - + + private void initCore() { + + } + }
Received on Monday, 31 August 2009 11:36:06 UTC