Created
June 7, 2018 09:18
-
-
Save SylvainJuge/ec66728c7fdce1602c6a230b56047d75 to your computer and use it in GitHub Desktop.
Struts 2.5.10 FileUploadInterceptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// intercept(...) method from Struts 2.5.10 | |
// https://github.com/apache/struts/blob/f0f4e9ece77000e0eb0071bf233ed4b9bc9c8205/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java#L264 | |
public String intercept(ActionInvocation invocation) throws Exception { | |
ActionContext ac = invocation.getInvocationContext(); | |
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST); | |
if (!(request instanceof MultiPartRequestWrapper)) { | |
if (LOG.isDebugEnabled()) { | |
ActionProxy proxy = invocation.getProxy(); | |
LOG.debug(getTextMessage("struts.messages.bypass.request", new String[]{proxy.getNamespace(), proxy.getActionName()})); | |
} | |
return invocation.invoke(); | |
} | |
ValidationAware validation = null; | |
Object action = invocation.getAction(); | |
if (action instanceof ValidationAware) { | |
validation = (ValidationAware) action; | |
} | |
MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) request; | |
if (multiWrapper.hasErrors()) { | |
for (LocalizedMessage error : multiWrapper.getErrors()) { | |
if (validation != null) { | |
validation.addActionError(LocalizedTextUtil.findText(error.getClazz(), error.getTextKey(), ActionContext.getContext().getLocale(), error.getDefaultMessage(), error.getArgs())); | |
} | |
} | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment