io.undertow.servlet.api.ErrorPage Java Examples
The following examples show how to use
io.undertow.servlet.api.ErrorPage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeploymentManagerImpl.java From quarkus-http with Apache License 2.0 | 6 votes |
private void initializeErrorPages(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) { final Map<Integer, String> codes = new HashMap<>(); final Map<Class<? extends Throwable>, String> exceptions = new HashMap<>(); String defaultErrorPage = null; for (final ErrorPage page : deploymentInfo.getErrorPages()) { if (page.getExceptionType() != null) { exceptions.put(page.getExceptionType(), page.getLocation()); } else if (page.getErrorCode() != null) { codes.put(page.getErrorCode(), page.getLocation()); } else { if (defaultErrorPage != null) { throw UndertowServletMessages.MESSAGES.moreThanOneDefaultErrorPage(defaultErrorPage, page.getLocation()); } else { defaultErrorPage = page.getLocation(); } } } deployment.setErrorPages(new ErrorPages(codes, exceptions, defaultErrorPage)); }
Example #2
Source File: DeploymentManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private void initializeErrorPages(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) { final Map<Integer, String> codes = new HashMap<>(); final Map<Class<? extends Throwable>, String> exceptions = new HashMap<>(); String defaultErrorPage = null; for (final ErrorPage page : deploymentInfo.getErrorPages()) { if (page.getExceptionType() != null) { exceptions.put(page.getExceptionType(), page.getLocation()); } else if (page.getErrorCode() != null) { codes.put(page.getErrorCode(), page.getLocation()); } else { if (defaultErrorPage != null) { throw UndertowServletMessages.MESSAGES.moreThanOneDefaultErrorPage(defaultErrorPage, page.getLocation()); } else { defaultErrorPage = page.getLocation(); } } } deployment.setErrorPages(new ErrorPages(codes, exceptions, defaultErrorPage)); }
Example #3
Source File: DeploymentManagerFactory.java From seed with Mozilla Public License 2.0 | 6 votes |
private Collection<ErrorPage> buildUndertowErrorPages(List<WebConfig.ServerConfig.ErrorPage> errorPages) { List<ErrorPage> undertowErrorPages = new ArrayList<>(); for (WebConfig.ServerConfig.ErrorPage errorPage : errorPages) { String location = errorPage.getLocation(); if (!location.startsWith("/")) { location = "/" + location; } if (errorPage.getExceptionType() != null) { undertowErrorPages.add(new ErrorPage(location, errorPage.getExceptionType())); } else if (errorPage.getErrorCode() != null) { undertowErrorPages.add(new ErrorPage(location, errorPage.getErrorCode())); } else { undertowErrorPages.add(new ErrorPage(location)); } } return undertowErrorPages; }
Example #4
Source File: SimpleAsyncTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws ServletException { DeploymentUtils.setupServlet(new ServletExtension() { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { deploymentInfo.addErrorPages(new ErrorPage("/500", StatusCodes.INTERNAL_SERVER_ERROR)); } }, servlet("messageServlet", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, HELLO_WORLD) .setAsyncSupported(true) .addMapping("/message"), servlet("500", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, "500") .setAsyncSupported(true) .addMapping("/500"), servlet("asyncServlet", AsyncServlet.class) .addInitParam(MessageServlet.MESSAGE, HELLO_WORLD) .setAsyncSupported(true) .addMapping("/async"), servlet("asyncServlet2", AnotherAsyncServlet.class) .setAsyncSupported(true) .addMapping("/async2"), servlet("error", AsyncErrorServlet.class) .setAsyncSupported(true) .addMapping("/error"), servlet("dispatch", AsyncDispatchServlet.class) .setAsyncSupported(true) .addMapping("/dispatch"), servlet("doubleCompleteServlet", AsyncDoubleCompleteServlet.class) .setAsyncSupported(true) .addMapping("/double-complete")); }
Example #5
Source File: SecurityErrorPageTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws IOException, ServletException { final ServletContainer container = ServletContainer.Factory.newInstance(); final PathHandler root = new PathHandler(); DefaultServer.setRootHandler(root); DeploymentInfo builder = new DeploymentInfo(); builder.addServlet(new ServletInfo("secure", SecureServlet.class) .addMapping("/secure")) .addSecurityConstraint(Servlets.securityConstraint().addRoleAllowed("user").addWebResourceCollection(Servlets.webResourceCollection().addUrlPattern("/*"))); builder.addServlet(new ServletInfo("path", PathServlet.class) .addMapping("/*")); builder.addErrorPage(new ErrorPage("/401", StatusCodes.UNAUTHORIZED)); ServletIdentityManager identityManager = new ServletIdentityManager(); identityManager.addUser("user1", "password1"); // Just one role less user. builder.setClassIntrospecter(TestClassIntrospector.INSTANCE) .setClassLoader(ErrorPageTestCase.class.getClassLoader()) .setContextPath("/servletContext") .setServletStackTraces(ServletStackTraces.NONE) .setIdentityManager(identityManager) .setLoginConfig(Servlets.loginConfig("BASIC", "Test Realm")) .setDeploymentName("servletContext.war"); final DeploymentManager manager1 = container.addDeployment(builder); manager1.deploy(); root.addPrefixPath(builder.getContextPath(), manager1.start()); }
Example #6
Source File: Servlets.java From quarkus-http with Apache License 2.0 | 2 votes |
/** * Create an ErrorPage instance for a given exception type * @param location The location to redirect to * @param exceptionType The exception type * @return The error page definition */ public static ErrorPage errorPage(String location, Class<? extends Throwable> exceptionType) { return new ErrorPage(location, exceptionType); }
Example #7
Source File: Servlets.java From quarkus-http with Apache License 2.0 | 2 votes |
/** * Create an ErrorPage instance for a given response code * @param location The location to redirect to * @param statusCode The status code * @return The error page definition */ public static ErrorPage errorPage(String location, int statusCode) { return new ErrorPage(location, statusCode); }
Example #8
Source File: Servlets.java From quarkus-http with Apache License 2.0 | 2 votes |
/** * Create an ErrorPage that corresponds to the default error page * * @param location The error page location * @return The error page instance */ public static ErrorPage errorPage(String location) { return new ErrorPage(location); }
Example #9
Source File: Servlets.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create an ErrorPage instance for a given exception type * @param location The location to redirect to * @param exceptionType The exception type * @return The error page definition */ public static ErrorPage errorPage(String location, Class<? extends Throwable> exceptionType) { return new ErrorPage(location, exceptionType); }
Example #10
Source File: Servlets.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create an ErrorPage instance for a given response code * @param location The location to redirect to * @param statusCode The status code * @return The error page definition */ public static ErrorPage errorPage(String location, int statusCode) { return new ErrorPage(location, statusCode); }
Example #11
Source File: Servlets.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create an ErrorPage that corresponds to the default error page * * @param location The error page location * @return The error page instance */ public static ErrorPage errorPage(String location) { return new ErrorPage(location); }