Ejemplo n.º 1
0
  private void initializeErrorPages(
      final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) {
    final Map<Integer, String> codes = new HashMap<Integer, String>();
    final Map<Class<? extends Throwable>, String> exceptions =
        new HashMap<Class<? extends Throwable>, String>();

    for (final ErrorPage page : deploymentInfo.getErrorPages()) {
      if (page.getExceptionType() != null) {
        exceptions.put(page.getExceptionType(), page.getLocation());
      } else {
        codes.put(page.getErrorCode(), page.getLocation());
      }
    }
    deployment.setErrorPages(new ErrorPages(codes, exceptions));
  }
 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));
 }