You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/11/25 15:04:50 UTC

svn commit: r884108 [9/10] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/ jackrabbit-core/ jackrabbit-core/src...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/GQL.java Wed Nov 25 14:04:38 2009
@@ -16,34 +16,34 @@
  */
 package org.apache.jackrabbit.commons.query;
 
-import org.apache.jackrabbit.util.ISO9075;
-import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
 
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.RowIterator;
-import javax.jcr.query.Row;
-import javax.jcr.query.Query;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
-import javax.jcr.Session;
+import javax.jcr.RangeIterator;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.Value;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.RangeIterator;
-import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.nodetype.NodeTypeIterator;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-import java.util.Collection;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.util.Text;
 
 /**
  * <code>GQL</code> is a simple fulltext query language, which supports field
@@ -120,6 +120,12 @@
  * {@link Row#getValue(String) Row.getValue("rep:excerpt()");}. Please note
  * that this is feature is Jackrabbit specific and will not work with other
  * implementations!
+ * <p/>
+ * <b>Parser callbacks</b>
+ * <p/>
+ * You can get callbacks for each field and query term pair using the method
+ * {@link #parse(String, Session, ParserCallback)}. This may be useful when you
+ * want to do some transformation on the GQL before it is actually executed.
  */
 public final class GQL {
 
@@ -197,7 +203,7 @@
     /**
      * List that contains all {@link PropertyExpression}s.
      */
-    private final List conditions = new ArrayList();
+    private final List<Expression> conditions = new ArrayList<Expression>();
 
     /**
      * An optional common path prefix for the GQL query.
@@ -212,17 +218,17 @@
     /**
      * Maps local names of node types to prefixed names.
      */
-    private Map ntNames;
+    private Map<String, String[]> ntNames;
 
     /**
      * Maps local names of child node definitions to prefixed child node names.
      */
-    private Map childNodeNames;
+    private Map<String, String> childNodeNames;
 
     /**
      * Maps local names of property definitions to prefixed property names.
      */
-    private Map propertyNames;
+    private Map<String, String> propertyNames;
 
     /**
      * The path constraint. Defaults to: <code>//*</code>
@@ -309,6 +315,23 @@
     }
 
     /**
+     * Parses the given <code>statement</code> and generates callbacks for each
+     * GQL term parsed.
+     *
+     * @param statement the GQL statement.
+     * @param session   the current session to resolve namespace prefixes.
+     * @param callback  the callback handler.
+     * @throws RepositoryException if an error occurs while parsing.
+     */
+    public static void parse(String statement,
+                             Session session,
+                             ParserCallback callback)
+            throws RepositoryException {
+        GQL query = new GQL(statement, session, null, null);
+        query.parse(callback);
+    }
+
+    /**
      * Defines a filter for query result rows.
      */
     public interface Filter {
@@ -326,6 +349,26 @@
         public boolean include(Row row) throws RepositoryException;
     }
 
+    /**
+     * Defines a callback interface that may be implemented by client code to
+     * get a callback for each GQL term that is parsed.
+     */
+    public interface ParserCallback {
+
+        /**
+         * A GQL term was parsed.
+         *
+         * @param property the name of the property or an empty string if the
+         *                 term is not prefixed.
+         * @param value    the value of the term.
+         * @param optional whether this term is prefixed with an OR operator.
+         * @throws RepositoryException if an error occurs while processing the
+         *                             term.
+         */
+        public void term(String property, String value, boolean optional)
+                throws RepositoryException;
+    }
+
     //-----------------------------< internal >---------------------------------
 
     /**
@@ -351,11 +394,11 @@
             if (numResults == Integer.MAX_VALUE) {
                 return new RowIterAdapter(nodes, nodes.getSize());
             }
-            List resultRows = new ArrayList();
+            List<Row> resultRows = new ArrayList<Row>();
             while (numResults-- > 0 && nodes.hasNext()) {
                 resultRows.add(nodes.nextRow());
             }
-            return new RowIterAdapter(resultRows, nodes.getSize());
+            return new RowIterAdapter(resultRows, resultRows.size());
         } catch (RepositoryException e) {
             // in case of error return empty result
             return RowIteratorAdapter.EMPTY;
@@ -369,7 +412,12 @@
      * @throws RepositoryException if an error occurs while translating the query.
      */
     private String translateStatement() throws RepositoryException {
-        parse();
+        parse(new ParserCallback() {
+            public void term(String property, String value, boolean optional)
+                    throws RepositoryException {
+                pushExpression(property, value, optional);
+            }
+        });
         StringBuffer stmt = new StringBuffer();
         // path constraint
         stmt.append(pathConstraint);
@@ -378,8 +426,8 @@
         if (typeConstraints != null) {
             predicate.addOperand(typeConstraints);
         }
-        for (Iterator it = conditions.iterator(); it.hasNext(); ) {
-            predicate.addOperand((Expression) it.next());
+        for (Expression condition : conditions) {
+            predicate.addOperand(condition);
         }
         if (predicate.getSize() > 0) {
             stmt.append("[");
@@ -408,18 +456,17 @@
         String[] resolvedNames = resolveNodeTypeName(ntName);
 
         // now resolve node type hierarchy
-        for (int i = 0; i < resolvedNames.length; i++) {
+        for (String resolvedName : resolvedNames) {
             try {
-                NodeType base = ntMgr.getNodeType(resolvedNames[i]);
+                NodeType base = ntMgr.getNodeType(resolvedName);
                 if (base.isMixin()) {
                     // search for nodes where jcr:mixinTypes is set to this mixin
-                    addTypeConstraint(new MixinComparision(resolvedNames[i]));
+                    addTypeConstraint(new MixinComparision(resolvedName));
                 } else {
                     // search for nodes where jcr:primaryType is set to this type
-                    addTypeConstraint(new PrimaryTypeComparision(resolvedNames[i]));
+                    addTypeConstraint(new PrimaryTypeComparision(resolvedName));
                 }
 
-
                 // now search for all node types that are derived from base
                 NodeTypeIterator allTypes = ntMgr.getAllNodeTypes();
                 while (allTypes.hasNext()) {
@@ -435,7 +482,7 @@
                 }
             } catch (NoSuchNodeTypeException e) {
                 // add anyway -> will not match anything
-                addTypeConstraint(new PrimaryTypeComparision(resolvedNames[i]));
+                addTypeConstraint(new PrimaryTypeComparision(resolvedName));
             }
         }
     }
@@ -469,7 +516,7 @@
         } else {
             if (ntNames == null) {
                 NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
-                ntNames = new HashMap();
+                ntNames = new HashMap<String, String[]>();
                 NodeTypeIterator it = ntMgr.getAllNodeTypes();
                 while (it.hasNext()) {
                     String name = it.nextNodeType().getName();
@@ -478,7 +525,7 @@
                     if (idx != -1) {
                         localName = name.substring(idx + 1);
                     }
-                    String[] nts = (String[]) ntNames.get(localName);
+                    String[] nts = ntNames.get(localName);
                     if (nts == null) {
                         nts = new String[]{name};
                     } else {
@@ -490,7 +537,7 @@
                     ntNames.put(localName, nts);
                 }
             }
-            names = (String[]) ntNames.get(ntName);
+            names = ntNames.get(ntName);
             if (names == null) {
                 names = new String[]{ntName};
             }
@@ -516,14 +563,14 @@
             return name;
         }
         if (propertyNames == null) {
-            propertyNames = new HashMap();
+            propertyNames = new HashMap<String, String>();
             NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
             NodeTypeIterator it = ntMgr.getAllNodeTypes();
             while (it.hasNext()) {
                 NodeType nt = it.nextNodeType();
                 PropertyDefinition[] defs = nt.getDeclaredPropertyDefinitions();
-                for (int i = 0; i < defs.length; i++) {
-                    String pn = defs[i].getName();
+                for (PropertyDefinition def : defs) {
+                    String pn = def.getName();
                     if (!pn.equals("*")) {
                         String localName = pn;
                         int idx = pn.indexOf(':');
@@ -535,7 +582,7 @@
                 }
             }
         }
-        String pn = (String) propertyNames.get(name);
+        String pn = propertyNames.get(name);
         if (pn != null) {
             return pn;
         } else {
@@ -561,14 +608,14 @@
             return name;
         }
         if (childNodeNames == null) {
-            childNodeNames = new HashMap();
+            childNodeNames = new HashMap<String, String>();
             NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
             NodeTypeIterator it = ntMgr.getAllNodeTypes();
             while (it.hasNext()) {
                 NodeType nt = it.nextNodeType();
                 NodeDefinition[] defs = nt.getDeclaredChildNodeDefinitions();
-                for (int i = 0; i < defs.length; i++) {
-                    String cnn = defs[i].getName();
+                for (NodeDefinition def : defs) {
+                    String cnn = def.getName();
                     if (!cnn.equals("*")) {
                         String localName = cnn;
                         int idx = cnn.indexOf(':');
@@ -580,7 +627,7 @@
                 }
             }
         }
-        String cnn = (String) childNodeNames.get(name);
+        String cnn = childNodeNames.get(name);
         if (cnn != null) {
             return cnn;
         } else {
@@ -600,10 +647,11 @@
     /**
      * Parses the GQL query statement.
      *
+     * @param callback the parser callback.
      * @throws RepositoryException if an error occurs while reading from the
      *                             repository.
      */
-    private void parse() throws RepositoryException {
+    private void parse(ParserCallback callback) throws RepositoryException {
         char[] stmt = new char[statement.length() + 1];
         statement.getChars(0, statement.length(), stmt, 0);
         stmt[statement.length()] = ' ';
@@ -611,8 +659,7 @@
         StringBuffer value = new StringBuffer();
         boolean quoted = false;
         boolean optional = false;
-        for (int i = 0; i < stmt.length; i++) {
-            char c = stmt[i];
+        for (char c : stmt) {
             switch (c) {
                 case ' ':
                     if (quoted) {
@@ -624,7 +671,7 @@
                             if (v.equals(OR) && p.length() == 0) {
                                 optional = true;
                             } else {
-                                pushExpression(p, v, optional);
+                                callback.term(p, v, optional);
                                 optional = false;
                             }
                             property.setLength(0);
@@ -649,7 +696,7 @@
                 case '"':
                     quoted = !quoted;
                     break;
-                // noise
+                    // noise
                 case '*':
                 case '?':
                 case '\'':
@@ -691,8 +738,8 @@
         } else if (property.equals(TYPE)) {
             String[] nts = Text.explode(value, ',');
             if (nts.length > 0) {
-                for (int i = 0; i < nts.length; i++) {
-                    collectNodeTypes(nts[i]);
+                for (String nt : nts) {
+                    collectNodeTypes(nt);
                 }
             }
         } else if (property.equals(ORDER)) {
@@ -730,7 +777,7 @@
         } else {
             ContainsExpression expr = new ContainsExpression(property, value);
             if (optional) {
-                Expression last = (Expression) conditions.get(conditions.size() - 1);
+                Expression last = conditions.get(conditions.size() - 1);
                 if (last instanceof OptionalExpression) {
                     ((OptionalExpression) last).addOperand(expr);
                 } else {
@@ -854,16 +901,19 @@
                 }
                 String slash = "";
                 for (int i = 0; i < parts.length; i++) {
-                    buffer.append(slash);
-                    String name;
                     if (i == parts.length - 1) {
-                        // last part
-                        buffer.append("@");
-                        name = resolvePropertyName(parts[i]);
+                        if (!parts[i].equals(".")) {
+                            // last part
+                            buffer.append(slash);
+                            buffer.append("@");
+                            buffer.append(ISO9075.encode(
+                                    resolvePropertyName(parts[i])));
+                        }
                     } else {
-                        name = resolveChildNodeName(parts[i]);
+                        buffer.append(slash);
+                        buffer.append(ISO9075.encode(
+                                resolveChildNodeName(parts[i])));
                     }
-                    buffer.append(ISO9075.encode(name));
                     slash = "/";
                 }
             }
@@ -886,7 +936,7 @@
      */
     private abstract class NAryExpression implements Expression {
 
-        private final List operands = new ArrayList();
+        private final List<Expression> operands = new ArrayList<Expression>();
 
         public void toString(StringBuffer buffer)
                 throws RepositoryException {
@@ -894,9 +944,8 @@
                 buffer.append("(");
             }
             String op = "";
-            for (Iterator it = operands.iterator(); it.hasNext(); ) {
+            for (Expression expr : operands) {
                 buffer.append(op);
-                Expression expr = (Expression) it.next();
                 expr.toString(buffer);
                 op = getOperation();
             }
@@ -954,11 +1003,10 @@
         public void toString(StringBuffer buffer)
                 throws RepositoryException {
             buffer.append("order by ");
-            List names = new ArrayList(Arrays.asList(Text.explode(value, ',')));
+            List<String> names = new ArrayList<String>(Arrays.asList(Text.explode(value, ',')));
             int length = buffer.length();
             String comma = "";
-            for (Iterator it = names.iterator(); it.hasNext(); ) {
-                String name = (String) it.next();
+            for (String name : names) {
                 boolean asc;
                 if (name.startsWith("-")) {
                     name = name.substring(1);
@@ -972,8 +1020,8 @@
                 }
                 if (name.length() > 0) {
                     buffer.append(comma);
-                    name = resolvePropertyName(name);
-                    buffer.append("@").append(ISO9075.encode(name));
+                    name = createPropertyName(resolvePropertyName(name));
+                    buffer.append(name);
                     if (!asc) {
                         buffer.append(" ").append(DESCENDING);
                     }
@@ -986,6 +1034,25 @@
             }
         }
 
+        private String createPropertyName(String name) {
+            if (name.contains("/")) {
+                String[] labels = name.split("/");
+
+                name = "";
+                for (int i = 0; i < labels.length; i++) {
+                    String label = ISO9075.encode(labels[i]);
+                    if (i < (labels.length - 1)) {
+                        name += label + "/";
+                    } else {
+                        name += "@" + label;
+                    }
+                }
+                return name;
+            } else {
+                return "@" + ISO9075.encode(name);
+            }
+        }
+
         private void defaultOrderBy(StringBuffer buffer) {
             buffer.append("@").append(JCR_SCORE).append(" ").append(DESCENDING);
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/pom.xml?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/pom.xml Wed Nov 25 14:04:38 2009
@@ -17,10 +17,7 @@
    limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
 <!-- ====================================================================== -->

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/AbstractExportContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/AbstractExportContext.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/AbstractExportContext.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/AbstractExportContext.java Wed Nov 25 14:04:38 2009
@@ -32,21 +32,14 @@
     private final IOListener ioListener;
     private final Item exportRoot;
     private final boolean hasStream;
-    private final MimeResolver mimeResolver;
 
     protected boolean completed;
 
-    public AbstractExportContext(Item exportRoot, boolean hasStream,
-                                 IOListener ioListener) {
-        this(exportRoot, hasStream, ioListener, null);
-    }
-
-    public AbstractExportContext(Item exportRoot, boolean hasStream,
-                                 IOListener ioListener, MimeResolver mimeResolver) {
+    public AbstractExportContext(
+            Item exportRoot, boolean hasStream, IOListener ioListener) {
         this.exportRoot = exportRoot;
         this.hasStream = hasStream;
         this.ioListener = (ioListener != null) ? ioListener : new DefaultIOListener(log);
-        this.mimeResolver = (mimeResolver != null) ? mimeResolver : IOUtil.MIME_RESOLVER;
     }
 
     public IOListener getIOListener() {
@@ -57,10 +50,6 @@
         return exportRoot;
     }
 
-    public MimeResolver getMimeResolver() {
-        return mimeResolver;
-    }
-
     public boolean hasStream() {
         return hasStream;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java Wed Nov 25 14:04:38 2009
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.tika.metadata.Metadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,21 +71,26 @@
 
     private static Logger log = LoggerFactory.getLogger(DefaultHandler.class);
 
-    private String collectionNodetype = JcrConstants.NT_FOLDER;
-    private String defaultNodetype = JcrConstants.NT_FILE;
-    /* IMPORTANT NOTE: for webDAV compliance the default nodetype of the content
-       node has been changed from nt:resource to nt:unstructured. */
-    private String contentNodetype = JcrConstants.NT_UNSTRUCTURED;
+    private String collectionNodetype;
+
+    private String defaultNodetype;
+
+    private String contentNodetype;
 
     private IOManager ioManager;
 
     /**
-     * Creates a new <code>DefaultHandler</code> with default nodetype definitions
-     * and without setting the IOManager.
+     * Creates a new <code>DefaultHandler</code> with default nodetype definitions:<br>
+     * <ul>
+     * <li>Nodetype for Collection: {@link JcrConstants#NT_FOLDER nt:folder}</li>
+     * <li>Nodetype for Non-Collection: {@link JcrConstants#NT_FILE nt:file}</li>
+     * <li>Nodetype for Non-Collection content: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
+     * </ul>
      *
-     * @see IOHandler#setIOManager(IOManager)
+     * @param ioManager the I/O manager
      */
     public DefaultHandler() {
+        this(null);
     }
 
     /**
@@ -92,13 +98,19 @@
      * <ul>
      * <li>Nodetype for Collection: {@link JcrConstants#NT_FOLDER nt:folder}</li>
      * <li>Nodetype for Non-Collection: {@link JcrConstants#NT_FILE nt:file}</li>
-     * <li>Nodetype for Non-Collection content: {@link JcrConstants#NT_RESOURCE nt:resource}</li>
+     * <li>Nodetype for Non-Collection content: {@link JcrConstants#NT_UNSTRUCTURED nt:unstructured}</li>
      * </ul>
      *
      * @param ioManager the I/O manager
      */
     public DefaultHandler(IOManager ioManager) {
-        this.ioManager = ioManager;
+        this(ioManager,
+                JcrConstants.NT_FOLDER,
+                JcrConstants.NT_FILE,
+                // IMPORTANT NOTE: for webDAV compliance the default type
+                // of the content node has been changed from nt:resource to
+                // nt:unstructured
+                JcrConstants.NT_UNSTRUCTURED);
     }
 
     /**
@@ -640,6 +652,28 @@
         return failures;
     }
 
+    /**
+     * Detects the media type of a document based on the given name.
+     *
+     * @param name document name
+     * @return detected content type (or application/octet-stream)
+     */
+    protected String detect(String name) {
+        try {
+            Metadata metadata = new Metadata();
+            metadata.set(Metadata.RESOURCE_NAME_KEY, name);
+            if (ioManager != null && ioManager.getDetector() != null) {
+                return ioManager.getDetector().detect(null, metadata).toString();
+            } else {
+                return "application/octet-stream";
+            }
+        } catch (IOException e) {
+            // Can not happen since the InputStream above is null
+            throw new IllegalStateException(
+                    "Unexpected IOException", e);
+        }
+    }
+
     //------------------------------------------------------------< private >---
     /**
      * Builds a webdav property name from the given jcrName. In case the jcrName

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultIOManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultIOManager.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultIOManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultIOManager.java Wed Nov 25 14:04:38 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.server.io;
 
+import org.apache.tika.detect.Detector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContext.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContext.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContext.java Wed Nov 25 14:04:38 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.server.io;
 
 import javax.jcr.Item;
+
 import java.io.OutputStream;
 
 /**
@@ -39,13 +40,6 @@
     public OutputStream getOutputStream();
 
     /**
-     * Return the <code>MimeResolver</code> defined for this export context.
-     *
-     * @return mimetype resolver defined for this export context.
-     */
-    public MimeResolver getMimeResolver();
-
-    /**
      * Set the content type for the resource content
      *
      * @param mimeType

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContextImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContextImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContextImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ExportContextImpl.java Wed Nov 25 14:04:38 2009
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.io.OutputContext;
+import org.apache.tika.detect.Detector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,13 +54,9 @@
     private File outFile;
     private OutputStream outStream;
 
-    public ExportContextImpl(Item exportRoot, OutputContext outputCtx) throws IOException {
-        this(exportRoot, outputCtx, null);
-    }
-
-    public ExportContextImpl(Item exportRoot, OutputContext outputCtx,
-                             MimeResolver mimeResolver) throws IOException {
-        super(exportRoot, (outputCtx != null) ? outputCtx.hasStream() : false, null, mimeResolver);
+    public ExportContextImpl(Item exportRoot, OutputContext outputCtx)
+            throws IOException {
+        super(exportRoot, outputCtx != null && outputCtx.hasStream(), null);
         this.outputCtx = outputCtx;
         if (hasStream()) {
             // we need a tmp file, since the export could fail

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManager.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManager.java Wed Nov 25 14:04:38 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.server.io;
 
 import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.tika.detect.Detector;
 
 import java.io.IOException;
 
@@ -41,6 +42,20 @@
     public IOHandler[] getIOHandlers();
 
     /**
+     * Return the configured type detector.
+     *
+     * @return content type detector
+     */
+    Detector getDetector();
+
+    /**
+     * Sets the configured type detector.
+     *
+     * @param detector content type detector.
+     */
+    void setDetector(Detector detector);
+
+    /**
      * Passes the specified context and boolean value to the IOHandlers present
      * on this manager.
      * As soon as the first handler incidates success the import should be

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManagerImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOManagerImpl.java Wed Nov 25 14:04:38 2009
@@ -16,13 +16,14 @@
  */
 package org.apache.jackrabbit.server.io;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.webdav.DavResource;
-
 import java.io.IOException;
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.tika.detect.Detector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>IOManagerImpl</code> represents the most simple <code>IOManager</code>
@@ -33,6 +34,11 @@
 
     private static Logger log = LoggerFactory.getLogger(IOManagerImpl.class);
 
+    /**
+     * Content type detector.
+     */
+    private Detector detector;
+
     private final List ioHandlers = new ArrayList();
 
     /**
@@ -64,6 +70,24 @@
     }
 
     /**
+     * Return the configured type detector.
+     *
+     * @return content type detector
+     */
+    public Detector getDetector() {
+        return detector;
+    }
+
+    /**
+     * Sets the configured type detector.
+     *
+     * @param detector content type detector
+     */
+    public void setDetector(Detector detector) {
+        this.detector = detector;
+    }
+
+    /**
      * @see IOManager#importContent(ImportContext, boolean)
      */
     public boolean importContent(ImportContext context, boolean isCollection) throws IOException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/IOUtil.java Wed Nov 25 14:04:38 2009
@@ -49,12 +49,6 @@
     public static final long UNDEFINED_LENGTH = -1;
 
     /**
-     * MimeType resolver used to retrieve the mimetype if no content type is
-     * available during import.
-     */
-    public static final MimeResolver MIME_RESOLVER = new MimeResolver();
-
-    /**
      * Return the last modification time as formatted string.
      *
      * @return last modification time as string.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContext.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContext.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContext.java Wed Nov 25 14:04:38 2009
@@ -17,6 +17,9 @@
 package org.apache.jackrabbit.server.io;
 
 import javax.jcr.Item;
+
+import org.apache.tika.detect.Detector;
+
 import java.io.InputStream;
 
 /**
@@ -33,13 +36,6 @@
     public Item getImportRoot();
 
     /**
-     * Return the <code>MimeResolver</code> defined for this import context.
-     *
-     * @return mimetype resolver defined for this import context.
-     */
-    public MimeResolver getMimeResolver();
-
-    /**
      * Returns the system id of the resource to be imported. This id depends on
      * the system the resource is comming from. it can be a filename, a
      * display name of a webdav resource, an URI, etc.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContextImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContextImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContextImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ImportContextImpl.java Wed Nov 25 14:04:38 2009
@@ -17,10 +17,15 @@
 package org.apache.jackrabbit.server.io;
 
 import org.apache.jackrabbit.webdav.io.InputContext;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Item;
+
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -38,45 +43,13 @@
     private final Item importRoot;
     private final String systemId;
     private final File inputFile;
-    private final MimeResolver mimeResolver;
 
     private InputContext inputCtx;
     private boolean completed;
 
-    /**
-     * Creates a new item import context with the given root item and the
-     * specified <code>InputContext</code>. If the input context provides an
-     * input stream, the stream is written to a temporary file in order to avoid
-     * problems with multiple IOHandlers that try to run the import but fail.
-     * The temporary file is deleted as soon as this context is informed that
-     * the import has been completed and it will not be used any more.
-     *
-     * @param importRoot the import root node
-     * @param systemId
-     * @param inputCtx wrapped by this <code>ImportContext</code>
-     */
-    public ImportContextImpl(Item importRoot, String systemId, InputContext inputCtx) throws IOException {
-        this(importRoot, systemId, inputCtx, null);
-    }
+    private final Detector detector;
 
-    /**
-     * Creates a new item import context with the given root item and the
-     * specified <code>InputContext</code>. If the input context provides an
-     * input stream, the stream is written to a temporary file in order to avoid
-     * problems with multiple IOHandlers that try to run the import but fail.
-     * The temporary file is deleted as soon as this context is informed that
-     * the import has been completed and it will not be used any more.
-     *
-     * @param importRoot the import root node
-     * @param systemId
-     * @param inputCtx wrapped by this <code>ImportContext</code>
-     * @param mimeResolver
-     */
-    public ImportContextImpl(Item importRoot, String systemId, InputContext inputCtx,
-                             MimeResolver mimeResolver) throws IOException {
-        this(importRoot, systemId, (inputCtx != null) ? inputCtx.getInputStream() : null, null, mimeResolver);
-        this.inputCtx = inputCtx;
-    }
+    private final MediaType type;
 
     /**
      * Creates a new item import context. The specified InputStream is written
@@ -87,39 +60,35 @@
      *
      * @param importRoot
      * @param systemId
-     * @param in
+     * @param inputCtx input context, or <code>null</code>
+     * @param stream document input stream, or <code>null</code>
      * @param ioListener
+     * @param detector content type detector
      * @throws IOException
      * @see ImportContext#informCompleted(boolean)
      */
-    public ImportContextImpl(Item importRoot, String systemId, InputStream in,
-                             IOListener ioListener) throws IOException {
-        this(importRoot, systemId, in, ioListener, null);
-    }
-
-    /**
-     * Creates a new item import context. The specified InputStream is written
-     * to a temporary file in order to avoid problems with multiple IOHandlers
-     * that try to run the import but fail. The temporary file is deleted as soon
-     * as this context is informed that the import has been completed and it
-     * will not be used any more.
-     *
-     * @param importRoot
-     * @param systemId
-     * @param in
-     * @param ioListener
-     * @param mimeResolver
-     * @throws IOException
-     * @see ImportContext#informCompleted(boolean)
-     */
-    public ImportContextImpl(Item importRoot, String systemId, InputStream in,
-                             IOListener ioListener, MimeResolver mimeResolver)
+    public ImportContextImpl(
+            Item importRoot, String systemId, InputContext inputCtx,
+            InputStream stream, IOListener ioListener, Detector detector)
             throws IOException {
         this.importRoot = importRoot;
         this.systemId = systemId;
-        this.inputFile = IOUtil.getTempFile(in);
+        this.inputCtx = inputCtx;
         this.ioListener = (ioListener != null) ? ioListener : new DefaultIOListener(log);
-        this.mimeResolver = (mimeResolver == null) ? IOUtil.MIME_RESOLVER : mimeResolver;
+
+        Metadata metadata = new Metadata();
+        if (inputCtx != null && inputCtx.getContentType() != null) {
+            metadata.set(Metadata.CONTENT_TYPE, inputCtx.getContentType());
+        }
+        if (systemId != null) {
+            metadata.set(Metadata.RESOURCE_NAME_KEY, systemId);
+        }
+        if (stream != null && !stream.markSupported()) {
+            stream = new BufferedInputStream(stream);
+        }
+        this.detector = detector;
+        this.type = detector.detect(stream, metadata);
+        this.inputFile = IOUtil.getTempFile(stream);
     }
 
     /**
@@ -137,10 +106,10 @@
     }
 
     /**
-     * @see ImportContext#getImportRoot()
+     * @see ImportContext#getDetector()
      */
-    public MimeResolver getMimeResolver() {
-        return mimeResolver;
+    public Detector getDetector() {
+        return detector;
     }
 
     /**
@@ -210,34 +179,17 @@
     }
 
     /**
-     * @return the content type present on the <code>InputContext</code> or
-     * <code>null</code>
-     * @see InputContext#getContentType()
-     */
-    private String getContentType() {
-        return (inputCtx != null) ? inputCtx.getContentType() : null;
-    }
-
-    /**
      * @see ImportContext#getMimeType()
      */
     public String getMimeType() {
-        String contentType = getContentType();
-        String mimeType = null;
-        if (contentType != null) {
-            mimeType = IOUtil.getMimeType(contentType);
-        } else if (getSystemId() != null) {
-            mimeType = mimeResolver.getMimeType(getSystemId());
-        }
-        return mimeType;
+        return IOUtil.getMimeType(type.toString());
     }
 
     /**
      * @see ImportContext#getEncoding()
      */
     public String getEncoding() {
-        String contentType = getContentType();
-        return (contentType != null) ? IOUtil.getEncoding(contentType) : null;
+        return IOUtil.getEncoding(type.toString());
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java Wed Nov 25 14:04:38 2009
@@ -149,7 +149,7 @@
                 if (contentNode.hasProperty(JcrConstants.JCR_MIMETYPE)) {
                     mimeType = contentNode.getProperty(JcrConstants.JCR_MIMETYPE).getString();
                 } else {
-                    mimeType = context.getMimeResolver().getMimeType(context.getExportRoot().getName());
+                    mimeType = detect(context.getExportRoot().getName());
                 }
             } catch (RepositoryException e) {
                 // ignore and return false

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ZipHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ZipHandler.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ZipHandler.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/ZipHandler.java Wed Nov 25 14:04:38 2009
@@ -153,7 +153,7 @@
                 if (contentNode.hasProperty(JcrConstants.JCR_MIMETYPE)) {
                     mimeType  = contentNode.getProperty(JcrConstants.JCR_MIMETYPE).getString();
                 } else {
-                    mimeType = context.getMimeResolver().getMimeType(context.getExportRoot().getName());
+                    mimeType = detect(context.getExportRoot().getName());
                 }
             } catch (RepositoryException e) {
                 // ignore and return false
@@ -283,7 +283,8 @@
         private final ZipEntry entry;
 
         private ZipEntryImportContext(ImportContext context, ZipEntry entry, BoundedInputStream bin, Node contentNode) throws IOException, RepositoryException {
-            super(contentNode, Text.getName(makeValidJCRPath(entry.getName(), true)), bin, context.getIOListener(), context.getMimeResolver());
+            super(contentNode, Text.getName(makeValidJCRPath(entry.getName(), true)),
+                    null, bin, context.getIOListener(), getIOManager().getDetector());
             this.entry = entry;
             String path = makeValidJCRPath(entry.getName(), true);
             importRoot = IOUtil.mkDirs(contentNode, Text.getRelativeParent(path, 1), getCollectionNodeType());
@@ -312,7 +313,7 @@
         private OutputStream out;
 
         private ZipEntryExportContext(Item exportRoot, OutputStream out, ExportContext context, int pos) {
-            super(exportRoot, out != null, context.getIOListener(), context.getMimeResolver());
+            super(exportRoot, out != null, context.getIOListener());
             this.out = out;
             try {
                 String entryPath = (exportRoot.getPath().length() > pos) ? exportRoot.getPath().substring(pos) : "";

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java Wed Nov 25 14:04:38 2009
@@ -897,7 +897,10 @@
      * @throws IOException
      */
     protected ImportContext getImportContext(InputContext inputCtx, String systemId) throws IOException {
-        return new ImportContextImpl(node, systemId, inputCtx, config.getMimeResolver());
+        return new ImportContextImpl(
+                node, systemId, inputCtx,
+                (inputCtx != null) ? inputCtx.getInputStream() : null,
+                new DefaultIOListener(log), config.getDetector());
     }
 
     /**
@@ -908,7 +911,7 @@
      * @throws IOException
      */
     protected ExportContext getExportContext(OutputContext outputCtx) throws IOException {
-        return new ExportContextImpl(node, outputCtx, config.getMimeResolver());
+        return new ExportContextImpl(node, outputCtx);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java Wed Nov 25 14:04:38 2009
@@ -16,33 +16,33 @@
  */
 package org.apache.jackrabbit.webdav.simple;
 
-import org.apache.jackrabbit.server.io.IOManager;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.jackrabbit.server.io.DefaultIOManager;
 import org.apache.jackrabbit.server.io.IOHandler;
-import org.apache.jackrabbit.server.io.PropertyManager;
+import org.apache.jackrabbit.server.io.IOManager;
 import org.apache.jackrabbit.server.io.PropertyHandler;
+import org.apache.jackrabbit.server.io.PropertyManager;
 import org.apache.jackrabbit.server.io.PropertyManagerImpl;
-import org.apache.jackrabbit.server.io.MimeResolver;
-import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.tika.detect.Detector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-import java.net.URL;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.io.IOException;
-import java.io.InputStream;
-
 /**
  * <code>ResourceConfig</code>...
  */
@@ -50,12 +50,20 @@
 
     private static Logger log = LoggerFactory.getLogger(ResourceConfig.class);
 
+    /**
+     * Content type detector.
+     */
+    private final Detector detector;
+
     private ItemFilter itemFilter;
     private IOManager ioManager;
     private PropertyManager propManager;
     private String[] nodetypeNames = new String[0];
     private boolean collectionNames = false;
-    private MimeResolver mimeResolver;
+
+    public ResourceConfig(Detector detector) {
+        this.detector = detector;
+    }
 
     /**
      * Tries to parse the given xml configuration file.
@@ -86,6 +94,11 @@
      *    &gt;
      * &lt;!ELEMENT defaultmimetype (CDATA) &gt;
      * </pre>
+     * <p>
+     * The &lt;mimetypeproperties/&gt; settings have been deprecated and will
+     * be ignored with a warning. Instead you can use the
+     * {@link SimpleWebdavServlet#INIT_PARAM_MIME_INFO mime-info}
+     * servlet initialization parameter to customize the media type settings.
      *
      * @param configURL
      */
@@ -107,6 +120,7 @@
                 Object inst = buildClassFromConfig(el);
                 if (inst != null && inst instanceof IOManager) {
                     ioManager = (IOManager)inst;
+                    ioManager.setDetector(detector);
                     // get optional 'iohandler' child elements and populate the
                     // ioManager with the instances
                     ElementIterator iohElements = DomUtil.getChildren(el, "iohandler", null);
@@ -177,21 +191,11 @@
                 log.debug("Resource configuration: no 'filter' element specified.");
             }
 
-            // optional mimetype properties
-            Properties properties = new Properties();
-            String defaultMimetype = null;
             el = DomUtil.getChildElement(config, "mimetypeproperties", null);
             if (el != null) {
-                defaultMimetype = DomUtil.getChildText(el, "defaultmimetype", null);
-                ElementIterator it = DomUtil.getChildren(el, "mimemapping", null);
-                while (it.hasNext()) {
-                    Element mimeMapping = it.nextElement();
-                    String extension = DomUtil.getAttribute(mimeMapping, "extension", null);
-                    String mimetype = DomUtil.getAttribute(mimeMapping, "mimetype", null);
-                    properties.put(extension, mimetype);
-                }
+                log.warn("Ignoring deprecated mimetypeproperties settings: {}",
+                        configURL);
             }
-            mimeResolver = new MimeResolver(properties, defaultMimetype);
         } catch (IOException e) {
             log.debug("Invalid resource configuration: " + e.getMessage());
         } catch (ParserConfigurationException e) {
@@ -270,6 +274,7 @@
         if (ioManager == null) {
             log.debug("ResourceConfig: missing io-manager > building DefaultIOManager ");
             ioManager = new DefaultIOManager();
+            ioManager.setDetector(detector);
         }
         return ioManager;
     }
@@ -331,10 +336,12 @@
     }
 
     /**
+     * Returns the configured content type detector.
      *
-     * @return
+     * @return content type detector
      */
-    public MimeResolver getMimeResolver() {
-        return mimeResolver;
+    public Detector getDetector() {
+        return detector;
     }
-}
\ No newline at end of file
+
+}

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java Wed Nov 25 14:04:38 2009
@@ -50,17 +50,6 @@
 
     /**
      * Create a new <code>ResourceFactory</code> that uses the given lock
-     * manager and the default {@link ResourceConfig resource config}.
-     *
-     * @param lockMgr
-     */
-    public ResourceFactoryImpl(LockManager lockMgr) {
-        this.lockMgr = lockMgr;
-        this.resourceConfig = new ResourceConfig();
-    }
-
-    /**
-     * Create a new <code>ResourceFactory</code> that uses the given lock
      * manager and resource filter.
      *
      * @param lockMgr
@@ -68,7 +57,7 @@
      */
     public ResourceFactoryImpl(LockManager lockMgr, ResourceConfig resourceConfig) {
         this.lockMgr = lockMgr;
-        this.resourceConfig = (resourceConfig != null) ? resourceConfig : new ResourceConfig();
+        this.resourceConfig = resourceConfig;
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/SimpleWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/SimpleWebdavServlet.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/SimpleWebdavServlet.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/SimpleWebdavServlet.java Wed Nov 25 14:04:38 2009
@@ -28,13 +28,19 @@
 import org.apache.jackrabbit.webdav.lock.LockManager;
 import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
 import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.mime.MimeTypeException;
+import org.apache.tika.mime.MimeTypesFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Repository;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
+
+import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URL;
 
 /**
  * WebdavServlet provides webdav support (level 1 and 2 complient) for
@@ -76,6 +82,13 @@
     public static final String INIT_PARAM_RESOURCE_CONFIG = "resource-config";
 
     /**
+     * Name of the parameter that specifies the servlet resource path of
+     * a custom &lt;mime-info/&gt; configuration file. The default setting
+     * is to use the MIME media type database included in Apache Tika.
+     */
+    public static final String INIT_PARAM_MIME_INFO = "mime-info";
+
+    /**
      * Servlet context attribute used to store the path prefix instead of
      * having a static field with this servlet. The latter causes problems
      * when running multiple
@@ -150,10 +163,10 @@
         }
         log.info("WWW-Authenticate header = '" + authenticate_header + "'");
 
+        config = new ResourceConfig(getDetector());
         String configParam = getInitParameter(INIT_PARAM_RESOURCE_CONFIG);
         if (configParam != null) {
             try {
-                config = new ResourceConfig();
                 config.parse(getServletContext().getResource(configParam));
             } catch (MalformedURLException e) {
                 log.debug("Unable to build resource filter provider.");
@@ -162,6 +175,40 @@
     }
 
     /**
+     * Reads and returns the configured &lt;mime-info/&gt; database.
+     *
+     * @see #INIT_PARAM_MIME_INFO
+     * @return MIME media type database
+     * @throws ServletException if the database is invalid or can not be read
+     */
+    private Detector getDetector() throws ServletException {
+        URL url;
+
+        String mimeInfo = getInitParameter(INIT_PARAM_MIME_INFO);
+        if (mimeInfo != null) {
+            try {
+                url = getServletContext().getResource(mimeInfo);
+            } catch (MalformedURLException e) {
+                throw new ServletException(
+                        "Invalid " + INIT_PARAM_MIME_INFO
+                        + " configuration setting: " + mimeInfo, e);
+            }
+        } else {
+            url = MimeTypesFactory.class.getResource("tika-mimetypes.xml");
+        }
+
+        try {
+            return MimeTypesFactory.create(url);
+        } catch (MimeTypeException e) {
+            throw new ServletException(
+                    "Invalid MIME media type database: " + url, e);
+        } catch (IOException e) {
+            throw new ServletException(
+                    "Unable to read MIME media type database: " + url, e);
+        }
+    }
+
+    /**
      * {@inheritDoc}
      */
     protected boolean isPreconditionValid(WebdavRequest request,
@@ -345,10 +392,6 @@
      * @return the resource configuration.
      */
     public ResourceConfig getResourceConfig() {
-        // fallback if no config present
-        if (config == null) {
-            config = new ResourceConfig();
-        }
         return config;
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml Wed Nov 25 14:04:38 2009
@@ -17,10 +17,7 @@
    limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
 <!-- ====================================================================== -->

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml Wed Nov 25 14:04:38 2009
@@ -17,10 +17,7 @@
    limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
 <!-- ====================================================================== -->

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java Wed Nov 25 14:04:38 2009
@@ -97,7 +97,7 @@
         if (wsp instanceof WorkspaceImpl) {
             ((WorkspaceImpl) wsp).getItemStateFactory().removeCreationListener(this);
         }
-        // aftwards clear the cache.
+        // ... and clear the cache.
         itemCache.clear();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java Wed Nov 25 14:04:38 2009
@@ -90,7 +90,7 @@
             size = UNDEFINED_SIZE;
         }
         pos = 0;
-        // prefetch first item
+        // fetch first item
         next = prefetchNext();
     }
 
@@ -119,7 +119,7 @@
         iter = entries.iterator();
         size = entries.size();
         pos = 0;
-        // prefetch first item
+        // fetch first item
         next = prefetchNext();
     }
 
@@ -223,7 +223,7 @@
                 entry = iter.next();
             }
         }
-        // prefetch final item (the one to be returned on next())
+        // fetch final item (the one to be returned on next())
         pos++;
         next = prefetchNext();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Wed Nov 25 14:04:38 2009
@@ -393,7 +393,7 @@
      * @see Node#setProperty(String, Node)
      */
     public Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        // duplicate check to make sure, writability is asserted before value
+        // duplicate check to make sure, property can be written before value
         // validation below.
         checkIsWritable();
         Value v;
@@ -1082,7 +1082,7 @@
     public void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
         checkSessionHasPendingChanges();
 
-        // additional checks are performed with subsequest calls.
+        // additional checks are performed with subsequent calls.
         if (hasNode(relPath)) {
             // node at 'relPath' exists -> call restore on the target Node
             getNode(relPath).restore(version, removeExisting);
@@ -1626,7 +1626,7 @@
 
         // get list of existing nodetypes
         Name[] existingNts = getNodeState().getNodeTypeNames();
-        // build effective node type representing primary type including existing mixin's
+        // build effective node type representing primary type including existing mixins
         EffectiveNodeType entExisting = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(existingNts);
 
         // check if the base type supports adding this mixin
@@ -1771,7 +1771,7 @@
             if (rp.getLength() == 1 && rp.getNameElement().denotesName()) {
                 // a single path element must always denote a name. '.' and '..'
                 // will never point to a property. If the NodeEntry does not
-                // contain such a pe, the targetEntry is 'null;
+                // contain such a property entry, the targetEntry is 'null;
                 Name propName = rp.getNameElement().getName();
                 // check if property entry exists
                 targetEntry = getNodeEntry().getPropertyEntry(propName, true);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java Wed Nov 25 14:04:38 2009
@@ -161,8 +161,7 @@
         }
     }
 
-    //---------------------------------------------------------< Rereferencable >---
-
+    //------------------------------------------------------< Referenceable >---
     /**
      * @see Referenceable#getReference()
      */

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java Wed Nov 25 14:04:38 2009
@@ -141,7 +141,7 @@
         session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
         session.checkIsAlive();
 
-        // do intra-workspace copy
+        // do within workspace copy
         Path srcPath = session.getQPath(srcAbsPath);
         Path destPath = session.getQPath(destAbsPath);
 
@@ -158,7 +158,7 @@
 
         // check workspace name
         if (getName().equals(srcWorkspace)) {
-            // same as current workspace, delegate to intra-workspace copy method
+            // same as current workspace, delegate to within workspace copy method
             copy(srcAbsPath, destAbsPath);
             return;
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Wed Nov 25 14:04:38 2009
@@ -566,8 +566,8 @@
             /*
             Execute operation and delegate invalidation of affected item
             states to the operation.
-            NOTE, that the invalidation is independant of the cache behaviour
-            due to the fact, that local eventbundles are not processed by
+            NOTE, that the invalidation is independent of the cache behaviour
+            due to the fact, that local event bundles are not processed by
             the HierarchyEventListener.
             */
             new OperationVisitorImpl(sessionInfo).execute(operation);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java Wed Nov 25 14:04:38 2009
@@ -307,14 +307,14 @@
                 parent.internalRemoveChildEntry(this);
                 break;
             case Status.STALE_DESTROYED:
-                // overlayed does not exist any more -> reverting of pending
+                // state does not exist any more -> reverting of pending
                 // transient changes (that lead to the stale status) can be
                 // omitted and the entry is complete removed instead.
                 remove();
                 break;
             default:
                 // Cannot revert EXISTING, REMOVED, INVALIDATED, MODIFIED states.
-                // State was implicitely reverted or external modifications
+                // State was implicitly reverted or external modifications
                 // reverted the modification.
                 log.debug("State with status " + oldStatus + " cannot be reverted.");
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java Wed Nov 25 14:04:38 2009
@@ -59,7 +59,7 @@
                 Path root = wspManager.getPathFactory().getRootPath();
                 filter = wspManager.createEventFilter(Event.ALL_TYPES, root, true, null, null, true);
             } catch (RepositoryException e) {
-                // spi does not support observation, or another error occurred.
+                // SPI does not support observation, or another error occurred.
                 log.debug("Creating event filter for cache behavoir observation failed", e);
             }
             if (filter == null) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java Wed Nov 25 14:04:38 2009
@@ -425,10 +425,10 @@
                /*
                 * Unknown entry (not-existing or not yet loaded):
                 * Skip all intermediate entries and directly try to load the ItemState
-                * (including building the itermediate entries. If that fails
+                * (including building the intermediate entries. If that fails
                 * ItemNotFoundException is thrown.
                 *
-                * Since 'path' might be ambigous (Node or Property):
+                * Since 'path' might be ambiguous (Node or Property):
                 * 1) first try Node
                 * 2) if the NameElement does not have SNS-index => try Property
                 * 3) else throw
@@ -508,7 +508,7 @@
             * Unknown parent entry (not-existing or not yet loaded) or a parent
             * entry that has been invalidated:
             * Skip all intermediate entries and directly try to load the
-            * PropertyState (including building the itermediate entries. If that
+            * PropertyState (including building the intermediate entries. If that
             * fails ItemNotFoundException is thrown.
             */
             PathBuilder pb = new PathBuilder(getPathFactory());
@@ -883,7 +883,7 @@
                } else {
                    // entry is either rename OR moved back to it's original
                    // parent. for the latter case make sure, there is no attic
-                   // entry remaing refering to the entry that is being added.
+                   // entry remaining referring to the entry that is being added.
                    revertInfo.oldParent.childNodeAttic.remove(this);
                }
            }
@@ -1577,7 +1577,7 @@
         if (he != this) {
             throw new IllegalArgumentException();
         }
-        // NOTE: if reorder occured in combination with a 'move' the clean-up
+        // NOTE: if reorder occurred in combination with a 'move' the clean-up
         // of the revertInfo is postponed until {@link #complete(Move)}.
         switch (operation.getStatus()) {
             case Operation.STATUS_PERSISTED:

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java Wed Nov 25 14:04:38 2009
@@ -102,8 +102,6 @@
     public Lock lock(NodeState nodeState, boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint) throws RepositoryException {
         // retrieve node first
         Node lhNode;
-        // NOTE: Node must be retrieved from the given NodeState and not from
-        // the overlayed workspace nodestate.
         Item item = itemManager.getItem(nodeState.getHierarchyEntry());
         if (item.isNode()) {
             lhNode = (Node) item;
@@ -309,7 +307,7 @@
             return entry.getNodeState();
         } catch (RepositoryException e) {
             // may occur if the nodeState is not accessible or some generic
-            // error occured.
+            // error occurred.
             // for this case, assume that no lock exists and delegate final
             // validation to the spi-implementation.
             log.warn("Error while accessing lock holding NodeState", e.getMessage());
@@ -381,7 +379,7 @@
                 // assume no lock is present (might not be correct due to incomplete hierarchy)
                 return null;
             } else {
-                // check lockMap again with the lockholding state
+                // check lockMap again with the lock-holding state
                 l = getLockFromMap(nState);
                 if (l != null) {
                     return l;
@@ -668,7 +666,7 @@
             this.node = lockHoldingNode;
 
             // if observation is supported OR if this is a session-scoped lock
-            // holded by this session -> store lock in the map
+            // hold by this session -> store lock in the map
             if (cacheBehaviour == CacheBehaviour.OBSERVATION) {
                 lockMap.put(lockState.lockHoldingState, this);
                 lockState.startListening();
@@ -676,7 +674,7 @@
                 lockMap.put(lockState.lockHoldingState, this);
                 lockState.startListening();
                 // open-scoped locks: the map entry and the lock information
-                // stored therein may become outdated if the token is transfered
+                // stored therein may become outdated if the token is transferred
                 // to another session -> info must be reloaded.
                 if (!isSessionScoped()) {
                     reloadInfo = true;
@@ -795,7 +793,7 @@
          */
         public void lockTokenAdded(String lockToken) throws RepositoryException {
             if (!isSessionScoped() && !isLockOwningSession()) {
-                // unless this lock is session-scoped (token is never transfered)
+                // unless this lock is session-scoped (token is never transferred)
                 // and the session isn't the owner yet (token already present),
                 // it could be that this affects this lock and session became
                 // lock holder -> reload info to assert.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/CreateActivity.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/CreateActivity.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/CreateActivity.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/CreateActivity.java Wed Nov 25 14:04:38 2009
@@ -62,7 +62,7 @@
         assert status == STATUS_PENDING;
         status = STATUS_PERSISTED;
         
-        // TODO: check if invaliation of the activity store is required.
+        // TODO: check if invalidation of the activity store is required.
     }
 
     //----------------------------------------< Access Operation Parameters >---

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java Wed Nov 25 14:04:38 2009
@@ -100,7 +100,7 @@
                 srcState.getNodeEntry().move(destName, destParentState.getNodeEntry(), false);
                 // TODO: TOBEFIXED. moved state ev. got a new definition.
             } catch (RepositoryException e) {
-                // should not occure
+                // should not occur
                 log.error("Internal error", e);
                 srcParentState.getHierarchyEntry().invalidate(false);
                 destParentState.getHierarchyEntry().invalidate(false);
@@ -183,7 +183,7 @@
         if (sessionMove) {
             NodeEntry destEntry = (NodeEntry) destParentState.getHierarchyEntry();
 
-            // force childnodeentries list to be present before the move is executed
+            // force child node entries list to be present before the move is executed
             // on the hierarchy entry.
             assertChildNodeEntries(srcParentState);
             assertChildNodeEntries(destParentState);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/security/AccessManager.java Wed Nov 25 14:04:38 2009
@@ -33,10 +33,10 @@
     /**
      * predefined action constants
      */
-    public String READ_ACTION = "read";
-    public String REMOVE_ACTION = "remove";
-    public String ADD_NODE_ACTION = "add_node";
-    public String SET_PROPERTY_ACTION = "set_property";
+    public String READ_ACTION = javax.jcr.Session.ACTION_READ;
+    public String REMOVE_ACTION = javax.jcr.Session.ACTION_REMOVE;
+    public String ADD_NODE_ACTION = javax.jcr.Session.ACTION_ADD_NODE;
+    public String SET_PROPERTY_ACTION = javax.jcr.Session.ACTION_SET_PROPERTY;
 
     public String[] READ = new String[] {READ_ACTION};
     public String[] REMOVE = new String[] {REMOVE_ACTION};

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java Wed Nov 25 14:04:38 2009
@@ -115,7 +115,7 @@
      */
     private static int getInitialStatus(NodeEntry parent) {
         int status = Status.EXISTING;
-        // walk up hiearchy and check if any of the parents is transiently
+        // walk up hierarchy and check if any of the parents is transiently
         // removed, in which case the status must be set to EXISTING_REMOVED.
         while (parent != null) {
             if (parent.getStatus() == Status.EXISTING_REMOVED) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java Wed Nov 25 14:04:38 2009
@@ -550,7 +550,7 @@
         NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
          // NOTE: check for name collisions with existing child node has been
          // removed as with JSR 283 having same-named node and property can be
-         // allowed. thus delegate the correspoding validation to the underlying
+         // allowed. thus delegate the corresponding validation to the underlying
          // SPI implementation.
 
         // check for name collisions with an existing property
@@ -578,7 +578,7 @@
     private void checkCollision(NodeState parentState, Name nodeName, Name nodeTypeName) throws RepositoryException, ConstraintViolationException, NoSuchNodeTypeException {
          // NOTE: check for name collisions with existing child property has been
          // removed as with JSR 283 having same-named node and property may be
-         // allowed. thus delegate the correspoding validation to the underlying
+         // allowed. thus delegate the corresponding validation to the underlying
          // SPI implementation.
 
          // check for conflict with existing same-name sibling node.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java Wed Nov 25 14:04:38 2009
@@ -450,7 +450,7 @@
             /*
              Don't use getAllNodeTypeNames() to retrieve the definition:
              for NEW-states the definition is always set upon creation.
-             for all other states the definion must be retrieved only taking
+             for all other states the definition must be retrieved only taking
              the effective nodetypes present on the parent into account
              any kind of transiently added mixins must not have an effect
              on the definition retrieved for an state that has been persisted

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=884108&r1=884107&r2=884108&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java Wed Nov 25 14:04:38 2009
@@ -207,7 +207,7 @@
             /*
             Don't pass 'all-nodetypes from parent':
             for NEW-states the definition is always set upon creation.
-            for all other states the definion must be retrieved only taking
+            for all other states the definition must be retrieved only taking
             the effective nodetypes present on the parent into account
             any kind of transiently added mixins must not have an effect
             on the definition retrieved for an state that has been persisted
@@ -355,7 +355,7 @@
         }
 
         private void setValues(int type, QValue[] values) throws ConstraintViolationException, RepositoryException {
-            // make sure the arguements are consistent and do not violate the
+            // make sure the arguments are consistent and do not violate the
             // given property definition.
             validate(values, type, getDefinition());
             // free old values if existing