jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r916643 - /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
Date Fri, 26 Feb 2010 10:49:47 GMT
Author: tripod
Date: Fri Feb 26 10:49:47 2010
New Revision: 916643

URL: http://svn.apache.org/viewvc?rev=916643&view=rev
Log:
JCR-2522 unable to workspace import XML.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java?rev=916643&r1=916642&r2=916643&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
Fri Feb 26 10:49:47 2010
@@ -27,6 +27,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * <code>XmlHandler</code> imports xml files and exports nodes that have
@@ -48,6 +50,19 @@
     public static final String XML_MIMETYPE = "text/xml";
 
     /**
+     * the alternative xml mimetype. tika detects xml as this.
+     */
+    public static final String XML_MIMETYPE_ALT = "application/xml";
+
+    private static final Set<String> supportedTypes;
+    static {
+        supportedTypes = new HashSet<String>();
+        supportedTypes.add(XML_MIMETYPE);
+        supportedTypes.add(XML_MIMETYPE_ALT);
+    }
+
+
+    /**
      * Creates a new <code>XmlHandler</code> with default nodetype definitions
      * and without setting the IOManager.
      *
@@ -87,11 +102,8 @@
      */
     @Override
     public boolean canImport(ImportContext context, boolean isCollection) {
-        if (context == null || context.isCompleted()) {
-            return false;
-        }
-        boolean isXmlMimeType = XML_MIMETYPE.equals(context.getMimeType());
-        return isXmlMimeType
+        return !(context == null || context.isCompleted())
+                && supportedTypes.contains(context.getMimeType())
                 && context.hasStream()
                 && context.getContentLength() > 0
                 && super.canImport(context, isCollection);



Mime
View raw message