private void assertNotInitialized() { if (initialized) throw new IllegalStateException(HttpServerText.get().alreadyInitializedByContainer); }
private void assertNotInitialized() { if (initialized) throw new IllegalStateException(HttpServerText.get().alreadyInitializedByContainer); }
public ServletBinder through(Filter filter) { if (filter == null) throw new NullPointerException(HttpServerText.get().filterMustNotBeNull); filters.add(filter); return this; }
/** * @param groupIdx * capture group number, 1 through the number of groups. */ public RegexGroupFilter(final int groupIdx) { if (groupIdx < 1) throw new IllegalArgumentException(MessageFormat.format( HttpServerText.get().invalidIndex, valueOf(groupIdx))); this.groupIdx = groupIdx - 1; }
public ServletBinder through(Filter filter) { if (filter == null) throw new NullPointerException(HttpServerText.get().filterMustNotBeNull); filters.add(filter); return this; }
/** * @param groupIdx * capture group number, 1 through the number of groups. */ public RegexGroupFilter(final int groupIdx) { if (groupIdx < 1) throw new IllegalArgumentException(MessageFormat.format( HttpServerText.get().invalidIndex, valueOf(groupIdx))); this.groupIdx = groupIdx - 1; }
private static File getFile(FilterConfig cfg, String param) throws ServletException { String n = cfg.getInitParameter(param); if (n == null || "".equals(n)) throw new ServletException(MessageFormat.format(HttpServerText.get().parameterNotSet, param)); File path = new File(n); if (!path.exists()) throw new ServletException(MessageFormat.format(HttpServerText.get().pathForParamNotFound, path, param)); return path; }
private static File getFile(FilterConfig cfg, String param) throws ServletException { String n = cfg.getInitParameter(param); if (n == null || "".equals(n)) throw new ServletException(MessageFormat.format(HttpServerText.get().parameterNotSet, param)); File path = new File(n); if (!path.exists()) throw new ServletException(MessageFormat.format(HttpServerText.get().pathForParamNotFound, path, param)); return path; }
/** * Get the selected repository from the request. * * @param req * the current request. * @return the repository; never null. * @throws IllegalStateException * the repository was not set by the filter, the servlet is * being invoked incorrectly and the programmer should ensure * the filter runs before the servlet. * @see #ATTRIBUTE_REPOSITORY */ public static Repository getRepository(final ServletRequest req) { Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY); if (db == null) throw new IllegalStateException(HttpServerText.get().expectedRepositoryAttribute); return db; }
/** * Get the selected repository from the request. * * @param req * the current request. * @return the repository; never null. * @throws IllegalStateException * the repository was not set by the filter, the servlet is * being invoked incorrectly and the programmer should ensure * the filter runs before the servlet. * @see #ATTRIBUTE_REPOSITORY */ public static Repository getRepository(final ServletRequest req) { Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY); if (db == null) throw new IllegalStateException(HttpServerText.get().expectedRepositoryAttribute); return db; }
private static boolean getBoolean(FilterConfig cfg, String param) throws ServletException { String n = cfg.getInitParameter(param); if (n == null) return false; try { return StringUtils.toBoolean(n); } catch (IllegalArgumentException err) { throw new ServletException(MessageFormat.format(HttpServerText.get().invalidBoolean, param, n)); } }
private ServletBinder register(ServletBinderImpl b) { synchronized (bindings) { if (pipelines != null) throw new IllegalStateException( HttpServerText.get().servletAlreadyInitialized); bindings.add(b); } return register((ServletBinder) b); }
public void doFilter(final ServletRequest request, final ServletResponse rsp, final FilterChain chain) throws IOException, ServletException { final WrappedRequest[] g = groupsFor(request); if (groupIdx < g.length) chain.doFilter(g[groupIdx], rsp); else throw new ServletException(MessageFormat.format( HttpServerText.get().invalidRegexGroup, valueOf(groupIdx + 1))); }
private ServletBinder register(ServletBinderImpl b) { synchronized (bindings) { if (pipelines != null) throw new IllegalStateException( HttpServerText.get().servletAlreadyInitialized); bindings.add(b); } return register((ServletBinder) b); }
private static boolean getBoolean(FilterConfig cfg, String param) throws ServletException { String n = cfg.getInitParameter(param); if (n == null) return false; try { return StringUtils.toBoolean(n); } catch (IllegalArgumentException err) { throw new ServletException(MessageFormat.format(HttpServerText.get().invalidBoolean, param, n)); } }
public void doFilter(final ServletRequest request, final ServletResponse rsp, final FilterChain chain) throws IOException, ServletException { final WrappedRequest[] g = groupsFor(request); if (groupIdx < g.length) chain.doFilter(g[groupIdx], rsp); else throw new ServletException(MessageFormat.format( HttpServerText.get().invalidRegexGroup, valueOf(groupIdx + 1))); }
private void log(Repository git, Throwable e) { getServletContext().log(MessageFormat.format( HttpServerText.get().internalErrorDuringUploadPack, ServletUtils.identify(git)), e); } }
/** * Construct a binding for a specific path. * * @param path * pattern to match. * @return binder for the passed path. */ public ServletBinder serve(String path) { if (path.startsWith("*")) return register(new SuffixPipeline.Binder(path.substring(1))); throw new IllegalArgumentException(MessageFormat.format(HttpServerText .get().pathNotSupported, path)); }