public ExceptionHandler getExceptionHandler() { if (exceptionHandler == null) { warn("Warning: no Exception Handler set, using basic exception handling only!"); exceptionHandler = new BasicExceptionHandler(getMyLogger()); } return exceptionHandler; }
public TokenAwareServer(ServiceClient serviceClient, String wellKnown) { super(serviceClient.host()); this.serviceClient = serviceClient; this.wellKnown = wellKnown; }
public UsernameTransformer getUsernameTransformer() { return new TrivialUsernameTransformer(); }
public void handleError(PresentableState state, Throwable t) throws IOException, ServletException { state.getResponse().setHeader("X-Frame-Options", "DENY"); JSPUtil.handleException(t, state.getRequest(), state.getResponse(), ERROR_PAGE); }
public static void handleException(Throwable t, HttpServletRequest request, HttpServletResponse response, String page) throws IOException, ServletException { request.setAttribute("exception", t); fwd(request, response, page); } }
/** * One stop shopping for exception handling. All thrown exceptions are intercepted and run through this. * Depending on their type they are wrapped or passed along. You can change this behavior if you need to. * <p>Note that all runtime exceptions, IOExceptions and ServletExceptions are not modified, * so if you over-ride this and throw one of those exceptions you will not get extra cruft. * <p>Also, a response is passed along. This may be used in over-rides, but is not used in the * basic implementation. If it is null, it should be ignored.</p> * * @param t * @param request * @param response * @throws IOException * @throws ServletException */ protected void handleException(Throwable t, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { error("INTERNAL ERROR: " + (t.getMessage() == null ? "(no message)" : t.getMessage())); // log it appropriately // ok, if it is a strange error, print a stack if you need to. if (isDebugOn()) { t.printStackTrace(); } t.printStackTrace(); getExceptionHandler().handleException(t, request, response); }
@Override public void contextInitialized(ServletContextEvent event) { try { AbstractServlet.setConfigurationLoader(getConfigurationLoader(event.getServletContext())); AbstractServlet.setInitialization(getInitialization()); } catch (Exception e) { // one of the few places to actually print the stack trace, since if it bombs here it will be well before // Tomcat has loaded much of anything and no or limited logging will be available. Make sure // someone can actually find a message if there is a problem. e.printStackTrace(); throw new MyConfigurationException("Error: could not load configuration", e); } }
@Override public void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { try { // printAllParameters(httpServletRequest); if (doPing(httpServletRequest, httpServletResponse)) return; /* To read the request body for processing use something like this. // Read from request StringBuilder buffer = new StringBuilder(); BufferedReader reader = httpServletRequest.getReader(); String line; while ((line = reader.readLine()) != null) { buffer.append(line); } String data = buffer.toString() */ doIt(httpServletRequest, httpServletResponse); } catch (Throwable t) { handleException(t, httpServletRequest, httpServletResponse); } }
public ServiceClient createServiceClient(URI host) { return new ServiceClient(host, getSSLConfiguration()); }
/** * This will print all parameters to standard err. It is a low-level debugging tool * and should never be used in production. It gives in effect a report on what is * actually being passed in. * * @param request */ protected void printAllParameters(HttpServletRequest request) { ServletDebugUtil.printAllParameters(this.getClass(), request); } }
protected ConfigurationNode getNode(ServletContext servletContext) throws Exception { return ServletConfigUtil.findConfigurationNode(servletContext, getOa4mpConfigFileKey(), getOa4mpConfigNameKey(), OA4MPConfigTags.COMPONENT); }
public boolean isDebugOn() { return getMyLogger().isDebugOn(); }
@Override public void destroy() { super.destroy(); shutdownCleanup(assetCleanup); }
public AGServer2(ServiceClient serviceClient) { super(serviceClient.host()); this.serviceClient = serviceClient; }
@Override public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { try { // printAllParameters(httpServletRequest); if (doPing(httpServletRequest, httpServletResponse)) return; doIt(httpServletRequest, httpServletResponse); } catch (Throwable t) { t.printStackTrace(); handleException(t, httpServletRequest, httpServletResponse); } }
public void warn(String x) { getMyLogger().warn(x); }
public PAServer2(ServiceClient serviceClient) { super(serviceClient.host()); this.serviceClient = serviceClient; }
public void debug(String x) { getMyLogger().debug(x); }
public UIServer2(ServiceClient serviceClient) { super(serviceClient.host()); this.serviceClient = serviceClient; }
public void setDebugOn(boolean setOn) { getMyLogger().setDebugOn(setOn); }