Author: michiel
Date: 2009-07-06 22:49:49 +0200 (Mon, 06 Jul 2009)
New Revision: 36590

Modified:
   
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/BinaryCommitProcessor.java
Log:
Added the option to not set the content type at all if is not explicitely found

Modified: 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/BinaryCommitProcessor.java
===================================================================
--- 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/BinaryCommitProcessor.java
  2009-07-06 17:35:15 UTC (rev 36589)
+++ 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/BinaryCommitProcessor.java
  2009-07-06 20:49:49 UTC (rev 36590)
@@ -34,6 +34,8 @@
     private String contenttypeField = "mimetype";
     private boolean itypeField = false;
 
+    private boolean setContentTypeIfNotRecognized = true;
+
     public void setFilenameField(String fn) {
         filenameField = fn;
     }
@@ -48,8 +50,17 @@
         itypeField = i;
     }
 
+    /**
+     * If this is true (default), then the content type will be set to 
'application/octet-stream' if
+     * nothing explicit could be found.
+     * @since MMBase-1.9.2
+     */
+    public void setSetContentTypeIfNotRecognized(boolean s) {
+        setContentTypeIfNotRecognized = s;
+    }
 
 
+
     private String getFileName(Object o) {
         if (o == null) {
             return null;
@@ -62,13 +73,17 @@
 
     }
     private String getContentType(Object o) {
+        String ct = setContentTypeIfNotRecognized ? "application/octet-stream" 
: null;
         if (o instanceof SerializableInputStream) {
-            return ((SerializableInputStream)o).getContentType();
+            ct =  ((SerializableInputStream)o).getContentType();
+            log.debug("Found ct " + ct);
         } else if (o instanceof FileItem) {
-            return ((FileItem)o).getContentType();
+            ct = ((FileItem)o).getContentType();
+            log.debug("Found ct " + ct);
         } else {
-            return "application/octet-stream";
+            log.debug("No ct found in " + o.getClass() + " " + o);
         }
+        return ct;
     }
 
     public void commit(Node node, Field field) {
@@ -106,7 +121,10 @@
                             fn = fn.substring(slash + 1);
                         }
                     }
+                    log.debug("Setting ct " + fn);
                     node.setValue(contenttypeField, fn);
+                } else {
+                    log.debug("No ct found for " + value);
                 }
             }
         }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to