Author: dpfister
Date: Wed Mar 17 09:15:30 2010
New Revision: 924197

URL: http://svn.apache.org/viewvc?rev=924197&view=rev
Log:
CMIS-156: don't crash on invalid MIME types
- allow mimetype to be 'null'

Modified:
    
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java

Modified: 
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: 
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=924197&r1=924196&r2=924197&view=diff
==============================================================================
--- 
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
 (original)
+++ 
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
 Wed Mar 17 09:15:30 2010
@@ -760,14 +760,16 @@ public abstract class CMISObjectsCollect
     public String getContentType(ObjectEntry object) {
         try {
             String mimeType = (String) 
object.getValue(Property.CONTENT_STREAM_MIME_TYPE);
-            // make sure it's a valid MIME type otherwise Abdera will throw
-            try {
-                new MimeType(mimeType).toString();
-            } catch (Exception e) {
-                log.error("Object " + object.getId() + " has invalid "
-                        + Property.CONTENT_STREAM_MIME_TYPE + " '" + mimeType
-                        + "', will be served as 'application/octet-stream'");
-                mimeType = "application/octet-stream";
+            if (mimeType != null) {
+                // make sure it's a valid MIME type otherwise Abdera will throw
+                try {
+                    new MimeType(mimeType).toString();
+                } catch (Exception e) {
+                    log.error("Object " + object.getId() + " has invalid "
+                            + Property.CONTENT_STREAM_MIME_TYPE + " '" + 
mimeType
+                            + "', will be served as 
'application/octet-stream'");
+                    mimeType = "application/octet-stream";
+                }
             }
             return mimeType;
         } catch (IllegalArgumentException e) {


Reply via email to