From 3fada6cef21c9b16467177d866df778203b51b4d Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 5 Dec 2019 09:52:48 +0100 Subject: some code code-style modifications active code-quality checks! --- .../impl/idp/controller/AbstractController.java | 59 +++++++++++----------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java index b15dfeba..c09efc37 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java @@ -20,12 +20,21 @@ package at.gv.egiz.eaaf.core.impl.idp.controller; import java.io.IOException; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.text.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.web.bind.annotation.ExceptionHandler; + import at.gv.egiz.components.eventlog.api.EventConstants; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IStatusMessenger; -import at.gv.egiz.eaaf.core.api.data.EAAFConstants; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.api.data.ExceptionContainer; import at.gv.egiz.eaaf.core.api.idp.IConfigurationWithSP; import at.gv.egiz.eaaf.core.api.idp.auth.services.IProtocolAuthenticationService; @@ -37,13 +46,6 @@ import at.gv.egiz.eaaf.core.exceptions.ProcessExecutionException; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.utils.Random; import at.gv.egiz.eaaf.core.impl.utils.ServletUtils; -import org.apache.commons.text.StringEscapeUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.web.bind.annotation.ExceptionHandler; - /** * Basic application controller that implements core error-handling. @@ -72,16 +74,16 @@ public abstract class AbstractController { /** * EAAF framework exception handler. * - *

- *This handler start a protocol-specific error handling. - *

+ *

+ * This handler start a protocol-specific error handling. + *

* - * @param req http request + * @param req http request * @param resp http response - * @param e exception + * @param e exception * @throws IOException in case of an exception handling error */ - @ExceptionHandler({EaafException.class}) + @ExceptionHandler({ EaafException.class }) public void eaafExceptionHandler(final HttpServletRequest req, final HttpServletResponse resp, final Exception e) throws IOException { try { @@ -102,15 +104,15 @@ public abstract class AbstractController { * This handler wrote an internal server error into http response *

* - * @param resp http response + * @param resp http response * @param exception exception * @throws IOException In case of an internal error. */ - @ExceptionHandler({Exception.class}) + @ExceptionHandler({ Exception.class }) public void genericExceptionHandler(final HttpServletResponse resp, final Exception exception) throws IOException { log.error("Internel Server Error.", exception); - resp.setContentType(EAAFConstants.CONTENTTYPE_HTML_UTF8); + resp.setContentType(EaafConstants.CONTENTTYPE_HTML_UTF8); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error!" + "(Errorcode=9199" + " | Description=" + StringEscapeUtils.escapeHtml4(StringEscapeUtils.escapeEcmaScript(exception.getMessage())) @@ -125,13 +127,13 @@ public abstract class AbstractController { * This handler wrote an internal server error into http response *

* - * @param resp http response + * @param resp http response * @param exception exception */ - @ExceptionHandler({IOException.class}) + @ExceptionHandler({ IOException.class }) public void ioExceptionHandler(final HttpServletResponse resp, final Throwable exception) { log.error("Internel Server Error.", exception); - resp.setContentType(EAAFConstants.CONTENTTYPE_HTML_UTF8); + resp.setContentType(EaafConstants.CONTENTTYPE_HTML_UTF8); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } @@ -144,7 +146,8 @@ public abstract class AbstractController { final Throwable extractedException = extractOriginalExceptionFromProcessException(exceptionThrown); - // extract pendingRequestID and originalException if it was a TaskExecutionException + // extract pendingRequestID and originalException if it was a + // TaskExecutionException if (extractedException instanceof TaskExecutionException) { // set original exception loggedException = ((TaskExecutionException) extractedException).getOriginalException(); @@ -164,14 +167,14 @@ public abstract class AbstractController { } try { - // switch to protocol-finalize method to generate a protocol-specific error message + // switch to protocol-finalize method to generate a protocol-specific error + // message // log error directly in debug mode if (log.isDebugEnabled()) { log.warn(loggedException.getMessage(), loggedException); } - // put exception into transaction store for redirect final String key = Random.nextLongRandom(); if (pendingReq != null) { @@ -187,7 +190,7 @@ public abstract class AbstractController { String redirectUrl = null; redirectUrl = ServletUtils.getBaseUrl(req); redirectUrl += "/" + ProtocolFinalizationController.ENDPOINT_ERRORHANDLING + "?" - + EAAFConstants.PARAM_HTTP_ERROR_CODE + "=" + key; + + EaafConstants.PARAM_HTTP_ERROR_CODE + "=" + key; resp.setContentType("text/html"); resp.setStatus(302); @@ -206,14 +209,12 @@ public abstract class AbstractController { } - - /** * Extracts a TaskExecutionException of a ProcessExecutionExeception Stacktrace. * * @param exception error - * @return Return the latest TaskExecutionExecption if exists, otherwise the latest - * ProcessExecutionException + * @return Return the latest TaskExecutionExecption if exists, otherwise the + * latest ProcessExecutionException */ private Throwable extractOriginalExceptionFromProcessException(final Throwable exception) { Throwable exholder = exception; @@ -238,6 +239,4 @@ public abstract class AbstractController { } } - - } -- cgit v1.2.3