Author: michiel
Date: 2009-07-06 22:50:39 +0200 (Mon, 06 Jul 2009)
New Revision: 36591

Modified:
   
mmbase/trunk/applications/resources/src/main/java/org/mmbase/datatypes/processors/BinaryFile.java
Log:
added the option to set the mimetype if the value is converted to a String 
(otherwise it gets lost)

Modified: 
mmbase/trunk/applications/resources/src/main/java/org/mmbase/datatypes/processors/BinaryFile.java
===================================================================
--- 
mmbase/trunk/applications/resources/src/main/java/org/mmbase/datatypes/processors/BinaryFile.java
   2009-07-06 20:49:49 UTC (rev 36590)
+++ 
mmbase/trunk/applications/resources/src/main/java/org/mmbase/datatypes/processors/BinaryFile.java
   2009-07-06 20:50:39 UTC (rev 36591)
@@ -98,6 +98,12 @@
 
         private static final long serialVersionUID = 1L;
 
+        private String contenttypeField = "mimetype";
+
+        public void setContenttypeField(String f) {
+            contenttypeField = f;
+        }
+
         public Object process(final Node node, final Field field, final Object 
value) {
             SerializableInputStream is = 
Casting.toSerializableInputStream(value);
             String name = is.getName();
@@ -119,6 +125,16 @@
                 }
                 is.moveTo(f);
                 log.debug("Set a file " + f.getName());
+                if (node.getNodeManager().hasField(contenttypeField)) {
+                    if (! node.isChanged(contenttypeField) || 
node.isNull(contenttypeField)) {
+                        node.setStringValue(contenttypeField, 
is.getContentType());
+                        log.info("Found " + is.getContentType());
+                    } else {
+                        log.debug("Field " + contenttypeField + " is already 
changed " + node.getChanged() + " not setting to " + is.getContentType());
+                    }
+                } else {
+                    log.debug("No field " + contenttypeField);
+                }
                 return f.getName();
             } else {
                 log.debug("No name given, ignoring this processor (not an 
upload)");

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

Reply via email to