From 4c711e86c61f61d5f498ccd8da6e49501b23797b Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Sun, 25 Jul 2010 17:22:22 +0000 Subject: [PATCH] INT-1256, INT-822, INT-823 added MultipartHttpInputMessage, a multipart-aware implementation of HttpInputMessage --- .../http/MultipartHttpInputMessage.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 spring-integration-http/src/main/java/org/springframework/integration/http/MultipartHttpInputMessage.java diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/MultipartHttpInputMessage.java b/spring-integration-http/src/main/java/org/springframework/integration/http/MultipartHttpInputMessage.java new file mode 100644 index 0000000000..9f57bfe551 --- /dev/null +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/MultipartHttpInputMessage.java @@ -0,0 +1,70 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.http; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.springframework.http.server.ServletServerHttpRequest; +import org.springframework.util.MultiValueMap; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.multipart.MultipartRequest; + +/** + * @author Mark Fisher + * @since 2.0 + */ +public class MultipartHttpInputMessage extends ServletServerHttpRequest implements MultipartRequest { + + private final MultipartHttpServletRequest multipartServletRequest; + + + public MultipartHttpInputMessage(MultipartHttpServletRequest multipartServletRequest) { + super(multipartServletRequest); + this.multipartServletRequest = multipartServletRequest; + } + + + public MultipartFile getFile(String name) { + return this.multipartServletRequest.getFile(name); + } + + public Map getFileMap() { + return this.multipartServletRequest.getFileMap(); + } + + public MultiValueMap getMultiFileMap() { + return this.multipartServletRequest.getMultiFileMap(); + } + + public Iterator getFileNames() { + return this.multipartServletRequest.getFileNames(); + } + + public List getFiles(String name) { + return this.multipartServletRequest.getFiles(name); + } + + // TODO: return MultiValueMap? + @SuppressWarnings("unchecked") + public Map getParameterMap() { + return this.multipartServletRequest.getParameterMap(); + } + +}