diff --git a/acrarium/src/main/kotlin/com/faendir/acra/rest/RestConfiguration.kt b/acrarium/src/main/kotlin/com/faendir/acra/rest/RestConfiguration.kt index 7afd170d..b7367664 100644 --- a/acrarium/src/main/kotlin/com/faendir/acra/rest/RestConfiguration.kt +++ b/acrarium/src/main/kotlin/com/faendir/acra/rest/RestConfiguration.kt @@ -5,9 +5,12 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.Ordered import org.springframework.core.annotation.Order +import org.springframework.web.multipart.MultipartHttpServletRequest import org.springframework.web.multipart.MultipartResolver import org.springframework.web.multipart.commons.CommonsMultipartResolver +import org.springframework.web.multipart.support.StandardServletMultipartResolver import javax.servlet.Filter +import javax.servlet.http.HttpServletRequest @Configuration class RestConfiguration { @@ -16,5 +19,23 @@ class RestConfiguration { fun gzipFilter(): Filter = CompressingFilter() @Bean - fun multipartResolver(): MultipartResolver = CommonsMultipartResolver() + fun multipartResolver(): MultipartResolver = SwitchingMultipartResolver() +} + +class SwitchingMultipartResolver : MultipartResolver { + private val commonsResolver = CommonsMultipartResolver() + private val standardResolver = StandardServletMultipartResolver() + override fun isMultipart(request: HttpServletRequest): Boolean { + return request.resolver().isMultipart(request) + } + + override fun resolveMultipart(request: HttpServletRequest): MultipartHttpServletRequest { + return request.resolver().resolveMultipart(request) + } + + override fun cleanupMultipart(request: MultipartHttpServletRequest) { + return request.resolver().cleanupMultipart(request) + } + + private fun HttpServletRequest.resolver() = if (this.servletPath.startsWith("/VAADIN")) standardResolver else commonsResolver } \ No newline at end of file diff --git a/acrarium/src/main/kotlin/com/faendir/acra/security/SecurityUtils.kt b/acrarium/src/main/kotlin/com/faendir/acra/security/SecurityUtils.kt index ebb9d23a..802eaa85 100644 --- a/acrarium/src/main/kotlin/com/faendir/acra/security/SecurityUtils.kt +++ b/acrarium/src/main/kotlin/com/faendir/acra/security/SecurityUtils.kt @@ -50,6 +50,6 @@ object SecurityUtils { @JvmStatic fun isFrameworkInternalRequest(request: HttpServletRequest): Boolean { val parameterValue = request.getParameter(ApplicationConstants.REQUEST_TYPE_PARAMETER) - return (parameterValue != null && RequestType.values().any { it.getIdentifier() == parameterValue }) + return (parameterValue != null && RequestType.values().any { it.identifier == parameterValue }) } } \ No newline at end of file