Update of /var/cvs/src/org/mmbase/datatypes/processors
In directory james.mmbase.org:/tmp/cvs-serv13303

Modified Files:
        BinaryCommitProcessor.java 
Log Message:
added support for the 'itype' of images, which is a bit differnt


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes/processors


Index: BinaryCommitProcessor.java
===================================================================
RCS file: 
/var/cvs/src/org/mmbase/datatypes/processors/BinaryCommitProcessor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- BinaryCommitProcessor.java  24 Apr 2009 14:30:31 -0000      1.1
+++ BinaryCommitProcessor.java  24 Apr 2009 15:05:24 -0000      1.2
@@ -19,7 +19,7 @@
  * 'filesize' fields.
  *
  * @author Michiel Meeuwissen
- * @version $Id: BinaryCommitProcessor.java,v 1.1 2009/04/24 14:30:31 michiel 
Exp $
+ * @version $Id: BinaryCommitProcessor.java,v 1.2 2009/04/24 15:05:24 michiel 
Exp $
  * @since MMBase-1.9.1
  */
 
@@ -31,7 +31,9 @@
 
     private String filenameField = "filename";
     private String filesizeField = "filesize";
+    private String contenttypeField = "mimetype";
     private String mimetypeField = "mimetype";
+    private boolean itypeField = false;
 
     public void setFilenameField(String fn) {
         filenameField = fn;
@@ -39,10 +41,16 @@
     public void setFilesizeField(String fs) {
         filesizeField = fs;
     }
-    public void setMimetypeField(String fs) {
-        mimetypeField = fs;
+    public void setContenttypeField(String fs) {
+        contenttypeField = fs;
     }
 
+    public void setItype(boolean i) {
+        itypeField = i;
+    }
+
+
+
     private String getFileName(Object o) {
         if (o == null) {
             return null;
@@ -54,7 +62,7 @@
         return null;
 
     }
-    private String getMimeType(Object o) {
+    private String getContentType(Object o) {
         if (o instanceof SerializableInputStream) {
             return ((SerializableInputStream)o).getContentType();
         } else if (o instanceof FileItem) {
@@ -85,12 +93,18 @@
                     node.setValue(filenameField, fn);
                 }
             }
-            if (node.getNodeManager().hasField(mimetypeField) &&
-                (! node.isChanged(mimetypeField) || 
node.isNull(mimetypeField))) {
+            if (node.getNodeManager().hasField(contenttypeField) &&
+                (! node.isChanged(contenttypeField) || 
node.isNull(contenttypeField))) {
 
-                String fn = getMimeType(value);
+                String fn = getContentType(value);
                 if (fn != null) {
-                    node.setValue(mimetypeField, fn);
+                    if (itypeField) {
+                        int slash = fn.indexOf('/');
+                        if (slash > -1)  {
+                            fn = fn.substring(slash + 1);
+                        }
+                    }
+                    node.setValue(contenttypeField, fn);
                 }
             }
         }
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to