package at.gv.egovernment.moa.id.proxy.servlet; import java.io.IOException; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import at.gv.egovernment.moa.id.proxy.MOAIDProxyInitializer; import at.gv.egovernment.moa.id.util.HTTPRequestJSPForwarder; import at.gv.egovernment.moa.id.util.MOAIDMessageProvider; import at.gv.egovernment.moa.logging.Logger; /** * Servlet requested for updating the MOA-ID Auth configuration from configuration file * * @author Paul Ivancsics * @version $Id$ */ public class ConfigurationServlet extends HttpServlet { /** * Handle a HTTP GET request, used to indicated that the MOA * configuration needs to be updated (reloaded). * * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest, HttpServletResponse) */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MOAIDMessageProvider msg = MOAIDMessageProvider.getInstance(); try { MOAIDProxyInitializer.initialize(); String message = msg.getMessage("config.00", new Object[] { DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.GERMAN).format(new Date())} ); Logger.info(message); HTTPRequestJSPForwarder.forwardNamed(message, "/message-proxy.jsp", getServletContext(), request, response); } catch (Throwable t) { String errorMessage = msg.getMessage("config.04", null); Logger.error(errorMessage, t); HTTPRequestJSPForwarder.forwardNamed(errorMessage, "/message-proxy.jsp", getServletContext(), request, response); } } /** * Do the same as doGet. * * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, HttpServletResponse) */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } /** * Calls the web application initializer. * * @see javax.servlet.Servlet#init(ServletConfig) */ public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); } }