private ServletException newServletExceptionWithFreeMarkerLogging(String message, Throwable cause) throws ServletException { if (cause instanceof TemplateException) { // For backward compatibility, we log into the same category as Environment did when // log_template_exceptions was true. LOG_RT.error(message, cause); } else { LOG.error(message, cause); } ServletException e = new ServletException(message, cause); try { // Prior to Servlet 2.5, the cause exception wasn't set by the above constructor. // If we are on 2.5+ then this will throw an exception as the cause was already set. e.initCause(cause); } catch (Exception ex) { // Ignored; see above } throw e; }
/** * Sets the inner cause for this exception. * * @param cause The inner cause. * @return This object (for method chaining). */ @Override /* Throwable */ public synchronized RestServletException initCause(Throwable cause) { super.initCause(cause); return this; } }
/** * Sets the inner cause for this exception. * * @param cause The inner cause. * @return This object (for method chaining). */ @Override /* Throwable */ public synchronized RestServletException initCause(Throwable cause) { super.initCause(cause); return this; } }
/** * Sets the inner cause for this exception. * * @param cause The inner cause. * @return This object (for method chaining). */ @Override /* Throwable */ public synchronized RestServletException initCause(Throwable cause) { super.initCause(cause); return this; } }
/** * Sets the inner cause for this exception. * * @param cause The inner cause. * @return This object (for method chaining). */ @Override /* Throwable */ public synchronized RestServletException initCause(Throwable cause) { super.initCause(cause); return this; } }
doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { ... ... } catch (Exception e) { ServletException se = new ServletException(e.getMessage(), e); se.initCause(e); throw se; } }
private ServletException wrapException(Exception e, String msg) { this.logger.error(msg, e); ServletException servletException = new ServletException(msg, e); if (servletException.getCause() == null) { servletException.initCause(e); } return servletException; } }
/** * {@inheritDoc} */ @Override public void init( FilterConfig config ) throws ServletException { _filterConfig = config; _mapLastRequestTimes = new HashMap<String, Long>( INITIAL_CAPACITY ); _listOrderedRequests = new LinkedList<Entry>( ); try { String paramValue = _filterConfig.getInitParameter( "minContentLength" ); if ( paramValue != null ) { _nMinContentLength = Integer.parseInt( paramValue ); } paramValue = _filterConfig.getInitParameter( "minInterval" ); if ( paramValue != null ) { _nMinInterval = Integer.parseInt( paramValue ); } } catch( NumberFormatException ex ) { ServletException servletEx = new ServletException( ex.getMessage( ) ); servletEx.initCause( ex ); throw servletEx; } }
private ServletException newServletExceptionWithFreeMarkerLogging(String message, Throwable cause) throws ServletException { if (cause instanceof TemplateException) { // For backward compatibility, we log into the same category as Environment did when // log_template_exceptions was true. LOG_RT.error(message, cause); } else { LOG.error(message, cause); } ServletException e = new ServletException(message, cause); try { // Prior to Servlet 2.5, the cause exception wasn't set by the above constructor. // If we are on 2.5+ then this will throw an exception as the cause was already set. e.initCause(cause); } catch (Exception ex) { // Ignored; see above } throw e; }
private ServletException newServletExceptionWithFreeMarkerLogging(String message, Throwable cause) throws ServletException { if (cause instanceof TemplateException) { // For backward compatibility, we log into the same category as Environment did when // log_template_exceptions was true. LOG_RT.error(message, cause); } else { LOG.error(message, cause); } ServletException e = new ServletException(message, cause); try { // Prior to Servlet 2.5, the cause exception wasn't set by the above constructor. // If we are on 2.5+ then this will throw an exception as the cause was already set. e.initCause(cause); } catch (Exception ex) { // Ignored; see above } throw e; }
/** * Returns a token to use for throttling. * * @return non-null token * @throws ServletException if not token can be acquired */ private TokenQueue.Token acquireToken() throws ServletException { TokenQueue queue = Queues.getSyncConnectionQueue(); if (WAIT_WHEN_BUSY) { try { return queue.waitForToken(); } catch (InterruptedException e) { throw (ServletException) new ServletException("Queue wait interrupted") .initCause(e); } } else { return Queues.getSyncToken(queue); } }
/** * Constructs a direct cone searcher. * If it fails a ServletException is thrown and the token is released. * * @param token token reserving place in resource allocation queue * (released on failure) * @param catalogName table catalogue name * @param tableName table name * @param bestOnly true for best match only, false for all matches * @return new cone searcher */ public static ConeSearcher createConeSearcher(TokenQueue.Token token, String catalogName, String tableName, boolean bestOnly) throws ServletException { try { return attemptCreateConeSearcher(token, catalogName, tableName, bestOnly); } catch (ServletException e) { token.release(); throw e; } catch (Throwable e) { token.release(); throw (ServletException) new ServletException(e.getMessage()) .initCause(e); } }
private void handleScopedRequest(String addonKey, HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException { final long startTime = clock.now().getTime(); // we consume the input to allow inspection of the body via getInputStream InputConsumingHttpServletRequest inputConsumingRequest = new InputConsumingHttpServletRequest(req); UserKey user = userManager.getRemoteUserKey(req); ContentTypeAwareResponse wrappedResponse = new ContentTypeAwareResponse(res); if (!addonScopeManager.isRequestInApiScope(inputConsumingRequest, addonKey)) { respondOutOfAuthorizedScope(addonKey, req, res, user); return; } log.debug("Authorized add-on '{}' to access API at URL '{} {}' for user '{}'", addonKey, req.getMethod(), req.getRequestURI(), user); try { chain.doFilter(inputConsumingRequest, wrappedResponse); //Scope also checks response to see if it is allowed to return. if(!addonScopeManager.isResponseInApiScope(req, wrappedResponse, addonKey)) { respondOutOfAuthorizedScope(addonKey, req, wrappedResponse, user); return; } } catch (Exception e) { long duration = clock.now().getTime() - startTime; eventPublisher.publish(new ScopedRequestAllowedEvent(req, addonKey, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, duration)); throw ServletException.class.cast(new ServletException("Unhandled error in ApiScopingFilter").initCause(e)); } long duration = clock.now().getTime() - startTime; eventPublisher.publish(new ScopedRequestAllowedEvent(req, addonKey, wrappedResponse.getStatusCode(), duration)); }
private void handleScopedRequest(String addonKey, HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException { final long startTime = clock.now().getTime(); // we consume the input to allow inspection of the body via getInputStream InputConsumingHttpServletRequest inputConsumingRequest = new InputConsumingHttpServletRequest(req); UserKey user = userManager.getRemoteUserKey(req); ContentTypeAwareResponse wrappedResponse = new ContentTypeAwareResponse(res); if (!addonScopeManager.isRequestInApiScope(inputConsumingRequest, addonKey)) { respondOutOfAuthorizedScope(addonKey, req, res, user); return; } log.debug("Authorized add-on '{}' to access API at URL '{} {}' for user '{}'", addonKey, req.getMethod(), req.getRequestURI(), user); try { chain.doFilter(inputConsumingRequest, wrappedResponse); //Scope also checks response to see if it is allowed to return. if(!addonScopeManager.isResponseInApiScope(req, wrappedResponse, addonKey)) { respondOutOfAuthorizedScope(addonKey, req, wrappedResponse, user); return; } } catch (Exception e) { long duration = clock.now().getTime() - startTime; eventPublisher.publish(new ScopedRequestAllowedEvent(req, addonKey, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, duration)); throw ServletException.class.cast(new ServletException("Unhandled error in ApiScopingFilter").initCause(e)); } long duration = clock.now().getTime() - startTime; eventPublisher.publish(new ScopedRequestAllowedEvent(req, addonKey, wrappedResponse.getStatusCode(), duration)); }
servletName + "' failure", t); ServletException se = new ServletException(); se.initCause(t); throw se;
servletName + "' failure", t); ServletException se = new ServletException(); se.initCause(t); throw se;
protected boolean doProcessFile(HttpServletRequest request, HttpServletResponse response, PageRequest pageRequest, File file) throws ServletException, IOException { try { return newInstance(pageRequest.getMy().getGardRootPage(), pageRequest.getMy().getLocalPathname(), file).process( request, response, pageRequest); } catch (Exception ex) { throw (ServletException)new ServletException( "Can't process java file: file=" + file + ", pathname=" + pageRequest.getMy().getPathname(), ex).initCause(ex); } }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException { startedEvent(endpoint.getEndpointAddressPath()); if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) { Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath()); if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) { WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor()); endedEvent(endpoint.getEndpointAddressPath()); return; } } // lookup registered URLs and get the appropriate adapter; // pass control to the adapter try { ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request); if (targetEndpoint != null) { targetEndpoint.handle(getServletContext(), request, response); } else { throw new ServletException("Service not found"); } } catch (Throwable t) { ServletException se = new ServletException(); se.initCause(t); throw se; } endedEvent(endpoint.getEndpointAddressPath()); }
se.initCause(t); throw se;