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! --- .../springweb/AbstractAuthSourceServlet.java | 81 ++++++++++++++-------- .../impl/idp/process/springweb/AbstractTask.java | 58 ++++++++-------- .../springweb/SpringWebExpressionEvaluator.java | 37 ++++++---- 3 files changed, 105 insertions(+), 71 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractAuthSourceServlet.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractAuthSourceServlet.java index cc899641..bd352bef 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractAuthSourceServlet.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractAuthSourceServlet.java @@ -21,9 +21,7 @@ package at.gv.egiz.eaaf.core.impl.idp.process.springweb; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.api.idp.process.ProcessEngine; -import at.gv.egiz.eaaf.core.impl.idp.process.ProcessInstance; + import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -31,10 +29,14 @@ import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.api.idp.process.ProcessEngine; +import at.gv.egiz.eaaf.core.impl.idp.process.ProcessInstance; + /** - * Abstract HttpServlet that provides means for retrieving the process engine (Spring Web required) - * as well as retrieving the underlying process instance and execution context evaluating a certain - * request parameter. + * Abstract HttpServlet that provides means for retrieving the process engine + * (Spring Web required) as well as retrieving the underlying process instance + * and execution context evaluating a certain request parameter. * * @author tknall * @@ -46,7 +48,8 @@ public abstract class AbstractAuthSourceServlet extends HttpServlet { private ProcessEngine processEngine; /** - * Returns the name of the request parameter representing the respective instance id. + * Returns the name of the request parameter representing the respective + * instance id. *

* Default is {@code processInstanceId}. * @@ -60,11 +63,16 @@ public abstract class AbstractAuthSourceServlet extends HttpServlet { * Returns the underlying process engine instance. * * @return The process engine (never {@code null}). - * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was found. - * @throws NoUniqueBeanDefinitionException if more than one {@link ProcessEngine} bean was found. - * @throws BeansException if a problem getting the {@link ProcessEngine} bean occurred. - * @throws IllegalStateException if the Spring WebApplicationContext was not found, which means - * that the servlet is used outside a Spring web environment. + * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was + * found. + * @throws NoUniqueBeanDefinitionException if more than one + * {@link ProcessEngine} bean was found. + * @throws BeansException if a problem getting the + * {@link ProcessEngine} bean occurred. + * @throws IllegalStateException if the Spring WebApplicationContext + * was not found, which means that the + * servlet is used outside a Spring web + * environment. */ public synchronized ProcessEngine getProcessEngine() { if (processEngine == null) { @@ -73,7 +81,7 @@ public abstract class AbstractAuthSourceServlet extends HttpServlet { if (ctx == null) { throw new IllegalStateException( "Unable to find Spring WebApplicationContext. " - + "Servlet needs to be executed within a Spring web environment."); + + "Servlet needs to be executed within a Spring web environment."); } processEngine = ctx.getBean(ProcessEngine.class); } @@ -86,13 +94,20 @@ public abstract class AbstractAuthSourceServlet extends HttpServlet { * * @param request The HttpServletRequest. * @return The process instance (never {@code null}). - * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was found. - * @throws NoUniqueBeanDefinitionException if more than one {@link ProcessEngine} bean was found. - * @throws BeansException if a problem getting the {@link ProcessEngine} bean occurred. - * @throws IllegalStateException if the Spring WebApplicationContext was not found, which means - * that the servlet is used outside a Spring web environment. - * @throws IllegalArgumentException in case the process instance id referenced by the request - * parameter {@link #getProcessInstanceIdParameterName()} does not exist. + * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was + * found. + * @throws NoUniqueBeanDefinitionException if more than one + * {@link ProcessEngine} bean was found. + * @throws BeansException if a problem getting the + * {@link ProcessEngine} bean occurred. + * @throws IllegalStateException if the Spring WebApplicationContext + * was not found, which means that the + * servlet is used outside a Spring web + * environment. + * @throws IllegalArgumentException in case the process instance id + * referenced by the request parameter + * {@link #getProcessInstanceIdParameterName()} + * does not exist. */ public ProcessInstance getProcessInstance(final HttpServletRequest request) { final String processInstanceId = @@ -105,18 +120,26 @@ public abstract class AbstractAuthSourceServlet extends HttpServlet { } /** - * Retrieves the execution context for the respective process instance referenced by the request - * parameter {@link #getProcessInstanceIdParameterName()}. + * Retrieves the execution context for the respective process instance + * referenced by the request parameter + * {@link #getProcessInstanceIdParameterName()}. * * @param request The HttpServletRequest. * @return The execution context (never {@code null}). - * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was found. - * @throws NoUniqueBeanDefinitionException if more than one {@link ProcessEngine} bean was found. - * @throws BeansException if a problem getting the {@link ProcessEngine} bean occurred. - * @throws IllegalStateException if the Spring WebApplicationContext was not found, which means - * that the servlet is used outside a Spring web environment. - * @throws IllegalArgumentException in case the process instance id referenced by the request - * parameter {@link #getProcessInstanceIdParameterName()} does not exist. + * @throws NoSuchBeanDefinitionException if no {@link ProcessEngine} bean was + * found. + * @throws NoUniqueBeanDefinitionException if more than one + * {@link ProcessEngine} bean was found. + * @throws BeansException if a problem getting the + * {@link ProcessEngine} bean occurred. + * @throws IllegalStateException if the Spring WebApplicationContext + * was not found, which means that the + * servlet is used outside a Spring web + * environment. + * @throws IllegalArgumentException in case the process instance id + * referenced by the request parameter + * {@link #getProcessInstanceIdParameterName()} + * does not exist. */ public ExecutionContext getExecutionContext(final HttpServletRequest request) { return getProcessInstance(request).getExecutionContext(); diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractTask.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractTask.java index 02db6686..2cdb84c5 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractTask.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/AbstractTask.java @@ -21,15 +21,17 @@ package at.gv.egiz.eaaf.core.impl.idp.process.springweb; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import at.gv.egiz.eaaf.core.api.IRequest; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.api.idp.process.Task; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; + import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.filter.RequestContextFilter; +import at.gv.egiz.eaaf.core.api.IRequest; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.api.idp.process.Task; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; + /** * Abstract task implementation providing {@link HttpServletRequest} and * {@link HttpServletResponse}. @@ -68,8 +70,8 @@ public abstract class AbstractTask implements Task { if (request == null || response == null) { throw new IllegalStateException( "Spring's RequestContextHolder did not provide HttpServletResponse. " - + "Did you forget to set the required " - + "org.springframework.web.filter.RequestContextFilter in your web.xml."); + + "Did you forget to set the required " + + "org.springframework.web.filter.RequestContextFilter in your web.xml."); } return internalExecute(pendingReq, executionContext, request, response); } else { @@ -78,43 +80,45 @@ public abstract class AbstractTask implements Task { } /** - * Executes the task providing the underlying {@link ExecutionContext} {@code executionContext} as - * well as the respective {@link HttpServletRequest} and {@link HttpServletResponse}. + * Executes the task providing the underlying {@link ExecutionContext} + * {@code executionContext} as well as the respective {@link HttpServletRequest} + * and {@link HttpServletResponse}. * * @param executionContext The execution context (never {@code null}). - * @param request The HttpServletRequest (never {@code null}). - * @param response The HttpServletResponse (never {@code null}). - * @throws IllegalStateException Thrown in case the task is nur being run within the required - * environment. Refer to javadoc for further information. - * @throws Exception Thrown in case of error executing the task. + * @param request The HttpServletRequest (never {@code null}). + * @param response The HttpServletResponse (never {@code null}). + * @throws IllegalStateException Thrown in case the task is nur being run within + * the required environment. Refer to javadoc for + * further information. + * @throws Exception Thrown in case of error executing the task. */ public abstract void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException; /** - * Executes the task providing the underlying {@link ExecutionContext} {@code executionContext} - * and the {@link IRequest} {@code pendingReq }as well as the respective - * {@link HttpServletRequest} and {@link HttpServletResponse}. + * Executes the task providing the underlying {@link ExecutionContext} + * {@code executionContext} and the {@link IRequest} {@code pendingReq }as well + * as the respective {@link HttpServletRequest} and {@link HttpServletResponse}. * *

- * This method sets the pending-request object of the task implementation and starts the - * {@code execute} method of the task + * This method sets the pending-request object of the task implementation and + * starts the {@code execute} method of the task *

* - * @param pendingReq The pending-request object (never {@code null}). + * @param pendingReq The pending-request object (never {@code null}). * @param executionContext The execution context (never {@code null}). - * @param request The HttpServletRequest (never {@code null}). - * @param response The HttpServletResponse (never {@code null}). - * @return The pending-request object, because Process-management works recursive + * @param request The HttpServletRequest (never {@code null}). + * @param response The HttpServletResponse (never {@code null}). + * @return The pending-request object, because Process-management works + * recursive * - * @throws IllegalStateException Thrown in case the task is being run within the required - * environment. Refer to javadoc for further information. - * @throws Exception Thrown in case of error executing the task. + * @throws IllegalStateException Thrown in case the task is being run within the + * required environment. Refer to javadoc for + * further information. + * @throws Exception Thrown in case of error executing the task. */ protected abstract IRequest internalExecute(IRequest pendingReq, ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response) throws TaskExecutionException; - - } diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/SpringWebExpressionEvaluator.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/SpringWebExpressionEvaluator.java index c723a728..afcc0a58 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/SpringWebExpressionEvaluator.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/springweb/SpringWebExpressionEvaluator.java @@ -22,12 +22,10 @@ package at.gv.egiz.eaaf.core.impl.idp.process.springweb; import java.io.Serializable; import java.util.Map; import java.util.Objects; + import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluationContext; -import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluator; -import at.gv.egiz.eaaf.core.impl.idp.process.model.Transition; + import org.apache.commons.lang3.BooleanUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,13 +37,21 @@ import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluationContext; +import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluator; +import at.gv.egiz.eaaf.core.impl.idp.process.model.Transition; + /** - * Expression evaluator for processing {@link Transition} conditions allowing to. + * Expression evaluator for processing {@link Transition} conditions allowing + * to. * @@ -70,9 +76,10 @@ public class SpringWebExpressionEvaluator implements ExpressionEvaluator { } /** - * Evaluation context that provides access to {@link HttpServletRequest} parameters using - * {@code requestParameter['foo']} for single value parameters or {@code requestParameters['foo']} - * for multi value parameters. Basic calls to {@code ctx} will be delegated. + * Evaluation context that provides access to {@link HttpServletRequest} + * parameters using {@code requestParameter['foo']} for single value parameters + * or {@code requestParameters['foo']} for multi value parameters. Basic calls + * to {@code ctx} will be delegated. * * @author tknall * @@ -82,11 +89,11 @@ public class SpringWebExpressionEvaluator implements ExpressionEvaluator { private static final long serialVersionUID = 1L; /** - * Creates a new expression evaluation context, providing access to HttpServletRequest - * parameter(s). + * Creates a new expression evaluation context, providing access to + * HttpServletRequest parameter(s). * - * @param delegate The original {@link ExpressionEvaluationContext} to be delegated to for - * {@code ctx['foo']} expressions. + * @param delegate The original {@link ExpressionEvaluationContext} to be + * delegated to for {@code ctx['foo']} expressions. */ public SpringWebExpressionEvaluationContext(final ExpressionEvaluationContext delegate) { this.delegate = delegate; -- cgit v1.2.3