diff --git a/.classpath b/.classpath index 941c5a4..2663538 100644 --- a/.classpath +++ b/.classpath @@ -26,6 +26,5 @@ - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 6803684..53d7bc6 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -15,6 +15,7 @@ org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=false org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false @@ -42,6 +43,8 @@ org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon=0 org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 @@ -50,6 +53,7 @@ org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_record_components=16 org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -60,6 +64,7 @@ org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow=0 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 @@ -111,6 +116,7 @@ org.eclipse.jdt.core.formatter.comment.indent_tag_description=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags=false org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true @@ -190,6 +196,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arg org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert @@ -281,6 +288,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_ar org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert @@ -364,6 +372,8 @@ org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.lineSplit=150 @@ -404,5 +414,6 @@ org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator=false org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index e65833f..d651123 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -8,6 +8,7 @@ cleanup.add_missing_nls_tags=false cleanup.add_missing_override_annotations=true cleanup.add_missing_override_annotations_interface_methods=true cleanup.add_serial_version_id=true +cleanup.also_simplify_lambda=true cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=true @@ -27,6 +28,7 @@ cleanup.convert_to_enhanced_for_loop=false cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true cleanup.double_negation=false cleanup.else_if=false cleanup.embedded_if=false @@ -60,6 +62,7 @@ cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=true cleanup.operand_factorization=false cleanup.organize_imports=false cleanup.overridden_assignment=false +cleanup.overridden_assignment_move_decl=true cleanup.plain_replacement=false cleanup.precompile_regex=false cleanup.primitive_comparison=false @@ -89,6 +92,7 @@ cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=true cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true @@ -101,7 +105,11 @@ cleanup.sort_members_all=false cleanup.standard_comparison=false cleanup.static_inner_class=false cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_stringbuffer_stringbuilder=false +cleanup.stringconcat_to_textblock=false cleanup.substring=false cleanup.switch=false cleanup.system_property=false @@ -136,10 +144,11 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Kiss4web -formatter_settings_version=21 +formatter_settings_version=23 jautodoc.cleanup.add_header=false jautodoc.cleanup.javadoc=false jautodoc.cleanup.replace_header=false +org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true diff --git a/lib/xidyn-1.17.0-sources.zip b/lib/xidyn-1.17.0-sources.zip deleted file mode 100644 index 0da63d8..0000000 Binary files a/lib/xidyn-1.17.0-sources.zip and /dev/null differ diff --git a/lib/xidyn-1.17.0.jar b/lib/xidyn-1.17.0.jar deleted file mode 100644 index 3d7ea98..0000000 Binary files a/lib/xidyn-1.17.0.jar and /dev/null differ diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitFailedHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitFailedHook.java index 34b7db7..a2f4bde 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitFailedHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitFailedHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -19,6 +19,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -26,12 +28,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.presenters.URLPresenter; - /** * The Class InitHook. */ @@ -68,25 +68,19 @@ public class ApplicationInitFailedHook extends HookCore public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { - try - { - logger.debug("Doing catch {}.", this.getClass().getName()); + logger.debug("Doing catch {}.", this.getClass().getName()); - String path = servletContext.getRealPath("/") + request.getPathInfo(); - logger.info("path=[{}]", path); + String path = servletContext.getRealPath("/") + request.getPathInfo(); + logger.info("path=[{}]", path); - StringBuffer html = new URLPresenter("/fr/devinsy/kiss4web/dispatcher/hooks/applicationInitFailed.xhtml").dynamize(); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/applicationInitFailed.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - // Display page. - response.setContentType("application/xhtml+xml; charset=UTF-8"); - response.getWriter().println(html); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); - logger.info("Application Init Failed page returned."); - } - catch (XidynException exception) - { - exception.printStackTrace(); - new FatalHook().process(servletConfig, servletContext, request, response); - } + logger.info("Application Init Failed page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitHook.java index d7abd7b..d186ef8 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ApplicationInitHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -19,6 +19,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -26,12 +28,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.presenters.URLPresenter; - /** * The Class InitHook. */ @@ -68,25 +68,19 @@ public class ApplicationInitHook extends HookCore public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { - try - { - logger.debug("Doing catch {}.", this.getClass().getName()); + logger.debug("Doing catch {}.", this.getClass().getName()); - String path = servletContext.getRealPath("/") + request.getPathInfo(); - logger.info("path=[{}]", path); + String path = servletContext.getRealPath("/") + request.getPathInfo(); + logger.info("path=[{}]", path); - StringBuffer html = new URLPresenter("/fr/devinsy/kiss4web/dispatcher/hooks/applicationInit.xhtml").dynamize(); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/applicationInit.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - // Display page. - response.setContentType("application/xhtml+xml; charset=UTF-8"); - response.getWriter().println(html); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); - logger.info("Application Init page returned."); - } - catch (XidynException exception) - { - exception.printStackTrace(); - new FatalHook().process(servletConfig, servletContext, request, response); - } + logger.info("Application Init page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/ErrorHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ErrorHook.java index 38b1eaf..962d1c3 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/ErrorHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ErrorHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -20,6 +20,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.File; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -27,12 +29,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.presenters.URLPresenter; - /** * The Class ErrorHook. */ @@ -78,22 +78,17 @@ public class ErrorHook extends HookCore { logger.debug("Doing catch."); - try - { - String path = servletContext.getRealPath("/") + request.getPathInfo(); - logger.info("path=[{}]", path); + String path = servletContext.getRealPath("/") + request.getPathInfo(); + logger.info("path=[{}]", path); - StringBuffer html = new URLPresenter("/fr/devinsy/kiss4web/dispatcher/hooks/error.xhtml").dynamize(); - // Display page. - response.setContentType("application/xhtml+xml; charset=UTF-8"); - response.getWriter().println(html); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/error.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - logger.info("Error page returned for [{}].", path); - } - catch (XidynException exception) - { - exception.printStackTrace(); - new FatalHook().process(servletConfig, servletContext, request, response); - } + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); + + logger.info("Error page returned for [{}].", path); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/FatalHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/FatalHook.java index abf56a4..7b745ee 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/FatalHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/FatalHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -20,7 +20,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.File; import java.io.IOException; -import java.io.PrintWriter; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -28,6 +29,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,25 +81,14 @@ public class FatalHook extends HookCore String path = servletContext.getRealPath("/") + request.getPathInfo(); logger.info("path=[{}]", path); - // Display fatal error page. - response.setContentType("text/html; charset=UTF-8"); - PrintWriter out = response.getWriter(); - out.println(""); - out.println(""); - out.println("
"); - out.println("A fatal error occured:
"); - out.println("
");
-        // out.println(source.getMessage());
-        out.println("
"); - out.println("
"); - // if (source.getMessage() != null) - // { - // out.println("
" + XidynUtils.restoreEntities(new
-        // StringBuffer(source.getMessage())) + "
"); - // } - out.println("
"); - out.println(""); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/fatal.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path)); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); + + logger.info("Fatal page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/InitFailedHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/InitFailedHook.java index abd819f..7ada872 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/InitFailedHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/InitFailedHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -20,6 +20,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.File; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -27,11 +29,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils; - /** * The Class InitFailedHook. */ @@ -80,9 +81,14 @@ public class InitFailedHook extends HookCore String path = servletContext.getRealPath("/") + request.getPathInfo(); logger.info("path=[{}]", path); - String mimeType = servletContext.getMimeType(path); - KissDispatcherUtils.returnInlineFile(response, new File(path), mimeType); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/initFailed.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - logger.info("File returned directly [{}] with mimetype [{}].", path, servletContext.getMimeType(path)); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); + + logger.info("Init Failed page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/InitHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/InitHook.java index 3faf5b9..65cce00 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/InitHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/InitHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -19,6 +19,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -26,12 +28,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.presenters.URLPresenter; - /** * The Class InitHook. */ @@ -68,25 +68,19 @@ public class InitHook extends HookCore public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { - try - { - logger.debug("Doing catch {}.", this.getClass().getName()); + logger.debug("Doing catch {}.", this.getClass().getName()); - String path = servletContext.getRealPath("/") + request.getPathInfo(); - logger.info("path=[{}]", path); + String path = servletContext.getRealPath("/") + request.getPathInfo(); + logger.info("path=[{}]", path); - StringBuffer html = new URLPresenter("/fr/devinsy/kiss4web/dispatcher/hooks/init.xhtml").dynamize(); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/init.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - // Display page. - response.setContentType("application/xhtml+xml; charset=UTF-8"); - response.getWriter().println(html); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); - logger.info("Init page returned."); - } - catch (XidynException exception) - { - exception.printStackTrace(); - new FatalHook().process(servletConfig, servletContext, request, response); - } + logger.info("Init page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/MaintenanceHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/MaintenanceHook.java index 41c96b4..d70e617 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/MaintenanceHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/MaintenanceHook.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2021 Christian Pierre MOMON + * Copyright (C) 2018-2023 Christian Pierre MOMON * * This file is part of Kiss4web. * @@ -20,6 +20,8 @@ package fr.devinsy.kiss4web.dispatcher.hooks; import java.io.File; import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; @@ -27,12 +29,10 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.presenters.URLPresenter; - /** * The Class MaintenanceHook. */ @@ -76,25 +76,19 @@ public class MaintenanceHook extends HookCore public void process(final ServletConfig servletConfig, final ServletContext servletContext, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { - try - { - logger.debug("Doing catch {}.", this.getClass().getName()); + logger.debug("Doing catch {}.", this.getClass().getName()); - String path = servletContext.getRealPath("/") + request.getPathInfo(); - logger.info("path=[{}]", path); + String path = servletContext.getRealPath("/") + request.getPathInfo(); + logger.info("path=[{}]", path); - StringBuffer html = new URLPresenter("/fr/devinsy/kiss4web/dispatcher/hooks/maintenance.xhtml").dynamize(); + // Get page. + URL url = Hook.class.getResource("/fr/devinsy/kiss4web/dispatcher/hooks/maintenance.xhtml"); + String xhtml = IOUtils.toString(url, StandardCharsets.UTF_8); - // Display page. - response.setContentType("application/xhtml+xml; charset=UTF-8"); - response.getWriter().println(html); + // Display page. + response.setContentType("application/xhtml+xml; charset=UTF-8"); + response.getWriter().println(xhtml); - logger.info("Application Init page returned."); - } - catch (XidynException exception) - { - exception.printStackTrace(); - new FatalHook().process(servletConfig, servletContext, request, response); - } + logger.info("Maintenance page returned."); } } diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/Fatal.xhtml b/src/fr/devinsy/kiss4web/dispatcher/hooks/fatal.xhtml similarity index 100% rename from src/fr/devinsy/kiss4web/dispatcher/hooks/Fatal.xhtml rename to src/fr/devinsy/kiss4web/dispatcher/hooks/fatal.xhtml