WW-4173 Passes current ActionInvocation to allow based disabling interceptor on it

This commit is contained in:
Lukasz Lenart
2022-10-24 08:27:12 +02:00
parent 94a0c6e425
commit 084c257d6e
7 changed files with 12 additions and 11 deletions
@@ -248,11 +248,11 @@ public class DefaultActionInvocation implements ActionInvocation {
if (interceptor instanceof WithLazyParams) {
interceptor = lazyParamInjector.injectParams(interceptor, interceptorMapping.getParams(), invocationContext);
}
if (interceptor.isDisabled()) {
if (interceptor.isDisabled(this)) {
LOG.debug("Interceptor: {} is disabled, skipping to next", interceptor.getClass().getSimpleName());
resultCode = this.invoke();
} else {
resultCode = interceptor.intercept(DefaultActionInvocation.this);
resultCode = interceptor.intercept(this);
}
} else {
resultCode = invokeActionOnly();
@@ -49,7 +49,7 @@ public abstract class AbstractInterceptor implements Interceptor {
}
@Override
public boolean isDisabled() {
public boolean isDisabled(ActionInvocation invocation) {
return this.disabled;
}
}
@@ -222,8 +222,9 @@ public interface Interceptor extends Serializable {
/**
* Allows to disable processing a given interceptor
*
* @param invocation current {@link ActionInvocation} to determine if the interceptor should be executed
* @return true if the given interceptor should be skipped
* @since 6.1.0
*/
boolean isDisabled();
boolean isDisabled(ActionInvocation invocation);
}
@@ -51,7 +51,7 @@ public class CoepInterceptor extends AbstractInterceptor implements PreResultLis
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
LOG.trace("COEP interceptor has been disabled");
} else {
invocation.addPreResultListener(this);
@@ -61,7 +61,7 @@ public class CoepInterceptor extends AbstractInterceptor implements PreResultLis
@Override
public void beforeResult(ActionInvocation invocation, String resultCode) {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
return;
}
@@ -53,7 +53,7 @@ public class CoopInterceptor extends AbstractInterceptor implements PreResultLis
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
LOG.trace("COOP interceptor has been disabled");
} else {
invocation.addPreResultListener(this);
@@ -63,7 +63,7 @@ public class CoopInterceptor extends AbstractInterceptor implements PreResultLis
@Override
public void beforeResult(ActionInvocation invocation, String resultCode) {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
return;
}
HttpServletRequest request = invocation.getInvocationContext().getServletRequest();
@@ -62,7 +62,7 @@ public class FetchMetadataInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
LOG.trace("Fetch Metadata interceptor has been disabled");
return invocation.invoke();
}
@@ -47,7 +47,7 @@ public final class CspInterceptor extends AbstractInterceptor implements PreResu
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
LOG.trace("CSP interceptor has been disabled");
} else {
invocation.addPreResultListener(this);
@@ -56,7 +56,7 @@ public final class CspInterceptor extends AbstractInterceptor implements PreResu
}
public void beforeResult(ActionInvocation invocation, String resultCode) {
if (this.isDisabled()) {
if (this.isDisabled(invocation)) {
return;
}
HttpServletRequest request = invocation.getInvocationContext().getServletRequest();