You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/07/15 04:45:19 UTC
svn commit: r964284 - in
/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4:
DefaultHttpBinding.java helper/CamelFileDataSource.java
Author: ningjiang
Date: Thu Jul 15 02:45:18 2010
New Revision: 964284
URL: http://svn.apache.org/viewvc?rev=964284&view=rev
Log:
CAMEL-2949, CAMEL-2772 merge the change of camel-http into camel-http4
Added:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java (with props)
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=964284&r1=964283&r2=964284&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java Thu Jul 15 02:45:18 2010
@@ -37,6 +37,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.Message;
import org.apache.camel.StreamCache;
+import org.apache.camel.component.http4.helper.CamelFileDataSource;
import org.apache.camel.component.http4.helper.GZIPHelper;
import org.apache.camel.converter.stream.CachedOutputStream;
import org.apache.camel.spi.HeaderFilterStrategy;
@@ -149,7 +150,7 @@ public class DefaultHttpBinding implemen
Object object = request.getAttribute(name);
if (object instanceof File) {
String fileName = request.getParameter(name);
- message.addAttachment(fileName, new DataHandler(new FileDataSource((File)object), FileTypeMap.getDefaultFileTypeMap().getContentType(fileName)));
+ message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File)object, fileName)));
}
}
}
Added: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java?rev=964284&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java (added)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java Thu Jul 15 02:45:18 2010
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.component.http4.helper;
+
+import java.io.File;
+
+import javax.activation.FileDataSource;
+import javax.activation.FileTypeMap;
+
+public class CamelFileDataSource extends FileDataSource {
+ private String fileName;
+ private FileTypeMap typeMap;
+
+ public CamelFileDataSource(File file, String fileName) {
+ super(file);
+ this.fileName = fileName;
+ }
+
+ public String getContentType() {
+ if (typeMap == null) {
+ return FileTypeMap.getDefaultFileTypeMap().getContentType(fileName);
+ } else {
+ return typeMap.getContentType(fileName);
+ }
+ }
+
+ public void setFileTypeMap(FileTypeMap map) {
+ typeMap = map;
+ }
+
+ public String getName() {
+ if (fileName != null) {
+ return fileName;
+ } else {
+ return super.getName();
+ }
+ }
+
+}
Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
------------------------------------------------------------------------------
svn:keywords = Rev Date