You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2012/10/31 15:06:13 UTC

svn commit: r1404144 [3/5] - in /jackrabbit/branches/2.2: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/ jac...

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java Wed Oct 31 14:06:06 2012
@@ -1,27 +1,27 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.packaging;
-
-import java.util.Iterator;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-public interface ContentPackage {
-
-    Iterator getItems(Session session) throws RepositoryException;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.packaging;
+
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+public interface ContentPackage {
+
+    Iterator getItems(Session session) throws RepositoryException;
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java Wed Oct 31 14:06:06 2012
@@ -1,27 +1,27 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.packaging;
-
-import java.io.OutputStream;
-
-import javax.jcr.RepositoryException;
-
-public interface ContentPackageExporter {
-
-    void export(ContentPackage description, OutputStream out)
-    throws RepositoryException;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.packaging;
+
+import java.io.OutputStream;
+
+import javax.jcr.RepositoryException;
+
+public interface ContentPackageExporter {
+
+    void export(ContentPackage description, OutputStream out)
+    throws RepositoryException;
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java Wed Oct 31 14:06:06 2012
@@ -1,205 +1,205 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.packaging;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.commons.predicate.Predicate;
-
-public class FilterContentPackage implements ContentPackage {
-
-    protected final List content = new ArrayList();
-
-    protected boolean includeProperties = false;
-
-    public void addContent(String path, Predicate filterList) {
-        this.content.add(new Content(new String[] {path}, filterList));
-    }
-
-    public void addContent(String[] paths, Predicate filterList) {
-        this.content.add(new Content(paths, filterList));
-    }
-
-    /**
-     * @see org.apache.jackrabbit.commons.packaging.ContentPackage#getItems(javax.jcr.Session)
-     */
-    public Iterator getItems(Session session)
-    throws RepositoryException {
-        return new FilteringIterator(session, new ArrayList(this.content), this.includeProperties);
-    }
-
-    protected static class Content {
-        protected final String[] paths;
-        protected final Predicate filterList;
-
-        public Content(String[] paths, Predicate filterList) {
-            this.paths = paths;
-            this.filterList = filterList;
-        }
-    }
-
-    public static class FilteringIterator implements Iterator {
-
-        /** The content we will iterate over. */
-        protected final List content;
-
-        /**
-         * Filter that defines which items are included
-         */
-        protected Predicate includeFilter;
-
-        protected int contentIndex, pathIndex;
-
-        protected Item nextItem;
-
-        protected Node lastNode;
-
-        protected final Session session;
-
-        protected final List nodeIteratorStack = new ArrayList();
-
-        protected final boolean includeProperties;
-
-        protected PropertyIterator propertyIterator;
-
-        /**
-         * Creates a new tree walker that uses the given filter as include and
-         * traversal filter.
-         *
-         * @param session The session.
-         * @param contentList The list of content objects.
-         * @param includeProperties Should properties be included.
-         */
-        public FilteringIterator(final Session session,
-                                 final List contentList,
-                                 final boolean includeProperties) {
-            this.content = contentList;
-            this.session = session;
-            this.includeProperties = includeProperties;
-        }
-
-        /**
-         * @see java.util.Iterator#hasNext()
-         */
-        public boolean hasNext() {
-            if ( this.nextItem != null ) {
-                return true;
-            }
-            try {
-                return this.checkForNextNode();
-            } catch (RepositoryException e) {
-                // if any error occurs, we stop iterating
-                return false;
-            }
-        }
-
-        protected boolean checkForNextNode() throws RepositoryException {
-            if ( this.propertyIterator != null ) {
-                if ( this.propertyIterator.hasNext() ) {
-                    this.nextItem = this.propertyIterator.nextProperty();
-                    return true;
-                }
-                this.propertyIterator = null;
-            } else if ( this.includeProperties && this.lastNode != null ) {
-                if ( this.lastNode.hasProperties() ) {
-                    this.propertyIterator = this.lastNode.getProperties();
-                    this.propertyIterator.hasNext();
-                    this.nextItem = this.propertyIterator.nextProperty();
-                    return true;
-                }
-            }
-            if ( this.lastNode != null ) {
-
-                if ( this.lastNode.hasNodes() ) {
-                    final NodeIterator iter = this.lastNode.getNodes();
-                    this.nodeIteratorStack.add(iter);
-                }
-                while ( this.nodeIteratorStack.size() > 0 ) {
-                    final NodeIterator iter = (NodeIterator)this.nodeIteratorStack.get(this.nodeIteratorStack.size() - 1);
-                    if ( iter.hasNext() ) {
-                        do {
-                            final Node contextNode = iter.nextNode();
-                            if ( this.includeFilter.evaluate(contextNode) ) {
-                                this.lastNode = contextNode;
-                                this.nextItem = contextNode;
-                                return true;
-                            }
-                        } while ( iter.hasNext() );
-                    }
-                    this.nodeIteratorStack.remove(iter);
-                }
-                this.pathIndex++;
-                this.lastNode = null;
-            }
-            while ( this.contentIndex < this.content.size() ) {
-                final Content content = (Content)this.content.get(this.contentIndex);
-                this.includeFilter = content.filterList;
-                while ( this.pathIndex < content.paths.length ) {
-                    final String path = content.paths[this.pathIndex];
-                    this.pathIndex++;
-                    final Node contextNode = (Node)this.session.getItem(path);
-                    if ( this.includeFilter.evaluate(contextNode) ) {
-                        this.lastNode = contextNode;
-                        this.nextItem = contextNode;
-                        return true;
-                    }
-                }
-                this.contentIndex++;
-                this.pathIndex = 0;
-            }
-
-            return false;
-        }
-
-        /**
-         * @see java.util.Iterator#next()
-         */
-        public Object next() {
-            if ( this.hasNext() ) {
-                final Item result = nextItem;
-                this.nextItem = null;
-                return result;
-            }
-            throw new NoSuchElementException("No more elements available");
-        }
-
-        /**
-         * @see java.util.Iterator#remove()
-         */
-        public void remove() {
-            throw new UnsupportedOperationException("Remove is not supported.");
-        }
-    }
-
-    public boolean isIncludeProperties() {
-        return includeProperties;
-    }
-
-    public void setIncludeProperties(boolean includeProperties) {
-        this.includeProperties = includeProperties;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.packaging;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.commons.predicate.Predicate;
+
+public class FilterContentPackage implements ContentPackage {
+
+    protected final List content = new ArrayList();
+
+    protected boolean includeProperties = false;
+
+    public void addContent(String path, Predicate filterList) {
+        this.content.add(new Content(new String[] {path}, filterList));
+    }
+
+    public void addContent(String[] paths, Predicate filterList) {
+        this.content.add(new Content(paths, filterList));
+    }
+
+    /**
+     * @see org.apache.jackrabbit.commons.packaging.ContentPackage#getItems(javax.jcr.Session)
+     */
+    public Iterator getItems(Session session)
+    throws RepositoryException {
+        return new FilteringIterator(session, new ArrayList(this.content), this.includeProperties);
+    }
+
+    protected static class Content {
+        protected final String[] paths;
+        protected final Predicate filterList;
+
+        public Content(String[] paths, Predicate filterList) {
+            this.paths = paths;
+            this.filterList = filterList;
+        }
+    }
+
+    public static class FilteringIterator implements Iterator {
+
+        /** The content we will iterate over. */
+        protected final List content;
+
+        /**
+         * Filter that defines which items are included
+         */
+        protected Predicate includeFilter;
+
+        protected int contentIndex, pathIndex;
+
+        protected Item nextItem;
+
+        protected Node lastNode;
+
+        protected final Session session;
+
+        protected final List nodeIteratorStack = new ArrayList();
+
+        protected final boolean includeProperties;
+
+        protected PropertyIterator propertyIterator;
+
+        /**
+         * Creates a new tree walker that uses the given filter as include and
+         * traversal filter.
+         *
+         * @param session The session.
+         * @param contentList The list of content objects.
+         * @param includeProperties Should properties be included.
+         */
+        public FilteringIterator(final Session session,
+                                 final List contentList,
+                                 final boolean includeProperties) {
+            this.content = contentList;
+            this.session = session;
+            this.includeProperties = includeProperties;
+        }
+
+        /**
+         * @see java.util.Iterator#hasNext()
+         */
+        public boolean hasNext() {
+            if ( this.nextItem != null ) {
+                return true;
+            }
+            try {
+                return this.checkForNextNode();
+            } catch (RepositoryException e) {
+                // if any error occurs, we stop iterating
+                return false;
+            }
+        }
+
+        protected boolean checkForNextNode() throws RepositoryException {
+            if ( this.propertyIterator != null ) {
+                if ( this.propertyIterator.hasNext() ) {
+                    this.nextItem = this.propertyIterator.nextProperty();
+                    return true;
+                }
+                this.propertyIterator = null;
+            } else if ( this.includeProperties && this.lastNode != null ) {
+                if ( this.lastNode.hasProperties() ) {
+                    this.propertyIterator = this.lastNode.getProperties();
+                    this.propertyIterator.hasNext();
+                    this.nextItem = this.propertyIterator.nextProperty();
+                    return true;
+                }
+            }
+            if ( this.lastNode != null ) {
+
+                if ( this.lastNode.hasNodes() ) {
+                    final NodeIterator iter = this.lastNode.getNodes();
+                    this.nodeIteratorStack.add(iter);
+                }
+                while ( this.nodeIteratorStack.size() > 0 ) {
+                    final NodeIterator iter = (NodeIterator)this.nodeIteratorStack.get(this.nodeIteratorStack.size() - 1);
+                    if ( iter.hasNext() ) {
+                        do {
+                            final Node contextNode = iter.nextNode();
+                            if ( this.includeFilter.evaluate(contextNode) ) {
+                                this.lastNode = contextNode;
+                                this.nextItem = contextNode;
+                                return true;
+                            }
+                        } while ( iter.hasNext() );
+                    }
+                    this.nodeIteratorStack.remove(iter);
+                }
+                this.pathIndex++;
+                this.lastNode = null;
+            }
+            while ( this.contentIndex < this.content.size() ) {
+                final Content content = (Content)this.content.get(this.contentIndex);
+                this.includeFilter = content.filterList;
+                while ( this.pathIndex < content.paths.length ) {
+                    final String path = content.paths[this.pathIndex];
+                    this.pathIndex++;
+                    final Node contextNode = (Node)this.session.getItem(path);
+                    if ( this.includeFilter.evaluate(contextNode) ) {
+                        this.lastNode = contextNode;
+                        this.nextItem = contextNode;
+                        return true;
+                    }
+                }
+                this.contentIndex++;
+                this.pathIndex = 0;
+            }
+
+            return false;
+        }
+
+        /**
+         * @see java.util.Iterator#next()
+         */
+        public Object next() {
+            if ( this.hasNext() ) {
+                final Item result = nextItem;
+                this.nextItem = null;
+                return result;
+            }
+            throw new NoSuchElementException("No more elements available");
+        }
+
+        /**
+         * @see java.util.Iterator#remove()
+         */
+        public void remove() {
+            throw new UnsupportedOperationException("Remove is not supported.");
+        }
+    }
+
+    public boolean isIncludeProperties() {
+        return includeProperties;
+    }
+
+    public void setIncludeProperties(boolean includeProperties) {
+        this.includeProperties = includeProperties;
+    }
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java Wed Oct 31 14:06:06 2012
@@ -1,161 +1,161 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.query.qom;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.qom.Comparison;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModelConstants;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.StaticOperand;
-
-/**
- * Enumeration of the JCR 2.0 query operators.
- *
- * @since Apache Jackrabbit 2.0
- */
-public enum Operator {
-
-    EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
-
-    NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
-
-    GT(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, ">"),
-
-    GE(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, ">="),
-
-    LT(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, "<"),
-
-    LE(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, "<="),
-
-    LIKE(QueryObjectModelConstants.JCR_OPERATOR_LIKE, null, "like");
-
-    /**
-     * JCR name of this operator.
-     */
-    private final String name;
-
-    /**
-     * This operator in XPath syntax.
-     */
-    private final String xpath;
-
-    /**
-     * This operator in SQL syntax.
-     */
-    private final String sql;
-
-    private Operator(String name, String op) {
-        this(name, op, op);
-    }
-
-    private Operator(String name, String xpath, String sql) {
-        this.name = name;
-        this.xpath = xpath;
-        this.sql = sql;
-    }
-
-    /**
-     * Returns a comparison between the given operands using this operator.
-     *
-     * @param factory factory for creating the comparison
-     * @param left operand on the left hand side
-     * @param right operand on the right hand side
-     * @return comparison
-     * @throws RepositoryException if the comparison can not be created
-     */
-    public Comparison comparison(
-            QueryObjectModelFactory factory,
-            DynamicOperand left, StaticOperand right)
-            throws RepositoryException {
-        return factory.comparison(left, name, right);
-    }
-
-    /**
-     * Formats an XPath constraint with this operator and the given operands.
-     * The operands are simply used as-is, without any quoting or escaping.
-     *
-     * @param a first operand
-     * @param b second operand
-     * @return XPath constraint, <code>a op b</code> or
-     *         <code>jcr:like(a, b)</code> for {@link #LIKE}
-     */
-    public String formatXpath(String a, String b) {
-        if (this == LIKE) {
-            return "jcr:like(" + a + ", " + b + ")";
-        } else {
-            return a + " " + xpath + " " + b;
-        }
-    }
-
-    /**
-     * Formats an SQL constraint with this operator and the given operands.
-     * The operands are simply used as-is, without any quoting or escaping.
-     *
-     * @param a first operand
-     * @param b second operand
-     * @return SQL constraint, <code>a op b</code>
-     */
-    public String formatSql(String a, String b) {
-        return a + " " + sql + " " + b;
-    }
-
-    /**
-     * Returns the JCR 2.0 name of this query operator.
-     *
-     * @see QueryObjectModelConstants
-     * @return JCR name of this operator
-     */
-    public String toString() {
-        return name;
-    }
-
-    /**
-     * Returns an array of the names of all the JCR 2.0 query operators.
-     *
-     * @return names of all query operators
-     */
-    public static String[] getAllQueryOperators() {
-        return new String[] {
-                EQ.toString(),
-                NE.toString(),
-                GT.toString(),
-                GE.toString(),
-                LT.toString(),
-                LE.toString(),
-                LIKE.toString()
-        };
-    }
-
-    /**
-     * Returns the operator with the given JCR name.
-     *
-     * @param name JCR name of an operator
-     * @return operator with the given name
-     * @throws RepositoryException if the given name is unknown
-     */
-    public static Operator getOperatorByName(String name)
-            throws RepositoryException {
-        for (Operator operator : Operator.values()) {
-            if (operator.name.equals(name)) {
-                return operator;
-            }
-        }
-        throw new RepositoryException("Unknown operator name: " + name);
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.query.qom.Comparison;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.StaticOperand;
+
+/**
+ * Enumeration of the JCR 2.0 query operators.
+ *
+ * @since Apache Jackrabbit 2.0
+ */
+public enum Operator {
+
+    EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
+
+    NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
+
+    GT(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, ">"),
+
+    GE(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, ">="),
+
+    LT(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, "<"),
+
+    LE(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, "<="),
+
+    LIKE(QueryObjectModelConstants.JCR_OPERATOR_LIKE, null, "like");
+
+    /**
+     * JCR name of this operator.
+     */
+    private final String name;
+
+    /**
+     * This operator in XPath syntax.
+     */
+    private final String xpath;
+
+    /**
+     * This operator in SQL syntax.
+     */
+    private final String sql;
+
+    private Operator(String name, String op) {
+        this(name, op, op);
+    }
+
+    private Operator(String name, String xpath, String sql) {
+        this.name = name;
+        this.xpath = xpath;
+        this.sql = sql;
+    }
+
+    /**
+     * Returns a comparison between the given operands using this operator.
+     *
+     * @param factory factory for creating the comparison
+     * @param left operand on the left hand side
+     * @param right operand on the right hand side
+     * @return comparison
+     * @throws RepositoryException if the comparison can not be created
+     */
+    public Comparison comparison(
+            QueryObjectModelFactory factory,
+            DynamicOperand left, StaticOperand right)
+            throws RepositoryException {
+        return factory.comparison(left, name, right);
+    }
+
+    /**
+     * Formats an XPath constraint with this operator and the given operands.
+     * The operands are simply used as-is, without any quoting or escaping.
+     *
+     * @param a first operand
+     * @param b second operand
+     * @return XPath constraint, <code>a op b</code> or
+     *         <code>jcr:like(a, b)</code> for {@link #LIKE}
+     */
+    public String formatXpath(String a, String b) {
+        if (this == LIKE) {
+            return "jcr:like(" + a + ", " + b + ")";
+        } else {
+            return a + " " + xpath + " " + b;
+        }
+    }
+
+    /**
+     * Formats an SQL constraint with this operator and the given operands.
+     * The operands are simply used as-is, without any quoting or escaping.
+     *
+     * @param a first operand
+     * @param b second operand
+     * @return SQL constraint, <code>a op b</code>
+     */
+    public String formatSql(String a, String b) {
+        return a + " " + sql + " " + b;
+    }
+
+    /**
+     * Returns the JCR 2.0 name of this query operator.
+     *
+     * @see QueryObjectModelConstants
+     * @return JCR name of this operator
+     */
+    public String toString() {
+        return name;
+    }
+
+    /**
+     * Returns an array of the names of all the JCR 2.0 query operators.
+     *
+     * @return names of all query operators
+     */
+    public static String[] getAllQueryOperators() {
+        return new String[] {
+                EQ.toString(),
+                NE.toString(),
+                GT.toString(),
+                GE.toString(),
+                LT.toString(),
+                LE.toString(),
+                LIKE.toString()
+        };
+    }
+
+    /**
+     * Returns the operator with the given JCR name.
+     *
+     * @param name JCR name of an operator
+     * @return operator with the given name
+     * @throws RepositoryException if the given name is unknown
+     */
+    public static Operator getOperatorByName(String name)
+            throws RepositoryException {
+        for (Operator operator : Operator.values()) {
+            if (operator.name.equals(name)) {
+                return operator;
+            }
+        }
+        throw new RepositoryException("Unknown operator name: " + name);
+    }
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/repository/SingletonRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/repository/SingletonRepositoryFactory.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/repository/SingletonRepositoryFactory.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/repository/SingletonRepositoryFactory.java Wed Oct 31 14:06:06 2012
@@ -1,49 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.repository;
-
-import javax.jcr.Repository;
-
-/**
- * Repository factory that always returns the same configured repository.
- */
-public class SingletonRepositoryFactory implements RepositoryFactory {
-
-    /**
-     * Singleton repository instance.
-     */
-    private final Repository repository;
-
-    /**
-     * Creates a repository factory that always returns the given repository.
-     *
-     * @param repository singleton repository instance.
-     */
-    public SingletonRepositoryFactory(Repository repository) {
-        this.repository = repository;
-    }
-
-    /**
-     * Returns the configured repository instance.
-     *
-     * @return singleton repository instance
-     */
-    public Repository getRepository() {
-        return repository;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.repository;
+
+import javax.jcr.Repository;
+
+/**
+ * Repository factory that always returns the same configured repository.
+ */
+public class SingletonRepositoryFactory implements RepositoryFactory {
+
+    /**
+     * Singleton repository instance.
+     */
+    private final Repository repository;
+
+    /**
+     * Creates a repository factory that always returns the given repository.
+     *
+     * @param repository singleton repository instance.
+     */
+    public SingletonRepositoryFactory(Repository repository) {
+        this.repository = repository;
+    }
+
+    /**
+     * Returns the configured repository instance.
+     *
+     * @return singleton repository instance
+     */
+    public Repository getRepository() {
+        return repository;
+    }
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/repository/SingletonRepositoryFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/visitor/FilteringItemVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/visitor/FilteringItemVisitor.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/visitor/FilteringItemVisitor.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/visitor/FilteringItemVisitor.java Wed Oct 31 14:06:06 2012
@@ -1,237 +1,237 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.commons.visitor;
-
-import java.util.LinkedList;
-
-import javax.jcr.Item;
-import javax.jcr.ItemVisitor;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.commons.predicate.Predicate;
-
-public abstract class FilteringItemVisitor implements ItemVisitor {
-
-    /**
-     * Predicate that defines which items are included.
-     */
-    protected Predicate includePredicate = Predicate.TRUE;
-
-    /**
-     * Predicate that defines which items are traversed.
-     */
-    protected Predicate traversalPredicate = Predicate.TRUE;
-
-    /**
-     * Do we want to walk all properties of nodes?
-     * The default is false.
-     */
-    protected boolean walkProperties = false;
-
-    /**
-     * indicates if traversal should be done in a breadth-first
-     * manner rather than depth-first (which is the default)
-     */
-    protected boolean breadthFirst = false;
-
-    /**
-     * the 0-based level up to which the hierarchy should be traversed
-     * (if it's -1, the hierarchy will be traversed until there are no
-     * more children of the current item)
-     */
-    protected int maxLevel = -1;
-
-    /**
-     * queues used to implement breadth-first traversal
-     */
-    protected LinkedList currentQueue;
-    protected LinkedList nextQueue;
-
-    /**
-     * used to track hierarchy level of item currently being processed
-     */
-    protected int currentLevel;
-
-    public void setMaxLevel(final int ml) {
-        this.maxLevel = ml;
-    }
-
-    public void setBreadthFirst(final boolean flag) {
-        if ( this.breadthFirst != flag ) {
-            this.breadthFirst = flag;
-            if (breadthFirst) {
-                this.currentQueue = new LinkedList();
-                this.nextQueue = new LinkedList();
-            } else {
-                this.currentQueue = null;
-                this.nextQueue = null;
-            }
-
-        }
-    }
-    public void setWalkProperties(final boolean flag) {
-        this.walkProperties = flag;
-    }
-
-    public void setIncludePredicate(final Predicate ip) {
-        this.includePredicate = ip;
-    }
-
-    public void setTraversalPredicate(final Predicate tp) {
-        this.traversalPredicate = tp;
-    }
-
-    /**
-     * Implement this method to add behaviour performed before a
-     * <code>Property</code> is visited.
-     *
-     * @param property the <code>Property</code> that is accepting this visitor.
-     * @param level    hierarchy level of this property (the root node starts at level 0)
-     * @throws RepositoryException if an error occurrs
-     */
-    protected abstract void entering(Property property, int level)
-        throws RepositoryException;
-
-    /**
-     * Implement this method to add behaviour performed before a
-     * <code>Node</code> is visited.
-     *
-     * @param node  the <code>Node</code> that is accepting this visitor.
-     * @param level hierarchy level of this node (the root node starts at level 0)
-     * @throws RepositoryException if an error occurrs
-     */
-    protected abstract void entering(Node node, int level)
-        throws RepositoryException;
-
-    /**
-     * Implement this method to add behaviour performed after a
-     * <code>Property</code> is visited.
-     *
-     * @param property the <code>Property</code> that is accepting this visitor.
-     * @param level    hierarchy level of this property (the root node starts at level 0)
-     * @throws RepositoryException if an error occurrs
-     */
-    protected abstract void leaving(Property property, int level)
-        throws RepositoryException;
-
-    /**
-     * Implement this method to add behaviour performed after a
-     * <code>Node</code> is visited.
-     *
-     * @param node  the <code>Node</code> that is accepting this visitor.
-     * @param level hierarchy level of this node (the root node starts at level 0)
-     * @throws RepositoryException if an error occurrs
-     */
-    protected abstract void leaving(Node node, int level)
-        throws RepositoryException;
-
-    /**
-     * Called when the Visitor is passed to a <code>Property</code>.
-     * <p/>
-     * It calls <code>TraversingItemVisitor.entering(Property, int)</code> followed by
-     * <code>TraversingItemVisitor.leaving(Property, int)</code>. Implement these abstract methods to
-     * specify behaviour on 'arrival at' and 'after leaving' the <code>Property</code>.
-     * <p/>
-     * <p/>
-     * If this method throws, the visiting process is aborted.
-     *
-     * @param property the <code>Property</code> that is accepting this visitor.
-     * @throws RepositoryException if an error occurrs
-     */
-    public void visit(Property property) throws RepositoryException {
-        if ( this.walkProperties && this.includePredicate.evaluate(property) ) {
-            entering(property, currentLevel);
-            leaving(property, currentLevel);
-        }
-    }
-
-    /**
-     * Called when the Visitor is passed to a <code>Node</code>.
-     * <p/>
-     * It calls <code>TraversingItemVisitor.entering(Node, int)</code> followed by
-     * <code>TraversingItemVisitor.leaving(Node, int)</code>. Implement these abstract methods to
-     * specify behaviour on 'arrival at' and 'after leaving' the <code>Node</code>.
-     * <p/>
-     * If this method throws, the visiting process is aborted.
-     *
-     * @param node the <code>Node</code> that is accepting this visitor.
-     * @throws RepositoryException if an error occurrs
-     */
-    public void visit(Node node)
-    throws RepositoryException {
-        if ( this.traversalPredicate.evaluate(node) ) {
-            if ( this.includePredicate == this.traversalPredicate || this.includePredicate.evaluate(node) )  {
-                try {
-                    if (!breadthFirst) {
-                        // depth-first traversal
-                        entering(node, currentLevel);
-                        if (maxLevel == -1 || currentLevel < maxLevel) {
-                            currentLevel++;
-                            if ( this.walkProperties ) {
-                                PropertyIterator propIter = node.getProperties();
-                                while (propIter.hasNext()) {
-                                    propIter.nextProperty().accept(this);
-                                }
-                            }
-                            NodeIterator nodeIter = node.getNodes();
-                            while (nodeIter.hasNext()) {
-                                nodeIter.nextNode().accept(this);
-                            }
-                            currentLevel--;
-                        }
-                        leaving(node, currentLevel);
-                    } else {
-                        // breadth-first traversal
-                        entering(node, currentLevel);
-                        leaving(node, currentLevel);
-
-                        if (maxLevel == -1 || currentLevel < maxLevel) {
-                            if ( this.walkProperties ) {
-                                PropertyIterator propIter = node.getProperties();
-                                while (propIter.hasNext()) {
-                                    nextQueue.addLast(propIter.nextProperty());
-                                }
-                            }
-                            NodeIterator nodeIter = node.getNodes();
-                            while (nodeIter.hasNext()) {
-                                nextQueue.addLast(nodeIter.nextNode());
-                            }
-                        }
-
-                        while (!currentQueue.isEmpty() || !nextQueue.isEmpty()) {
-                            if (currentQueue.isEmpty()) {
-                                currentLevel++;
-                                currentQueue = nextQueue;
-                                nextQueue = new LinkedList();
-                            }
-                            Item e = (Item) currentQueue.removeFirst();
-                            e.accept(this);
-                        }
-                        currentLevel = 0;
-                    }
-                } catch (RepositoryException re) {
-                    currentLevel = 0;
-                    throw re;
-                }
-            }
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.commons.visitor;
+
+import java.util.LinkedList;
+
+import javax.jcr.Item;
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.commons.predicate.Predicate;
+
+public abstract class FilteringItemVisitor implements ItemVisitor {
+
+    /**
+     * Predicate that defines which items are included.
+     */
+    protected Predicate includePredicate = Predicate.TRUE;
+
+    /**
+     * Predicate that defines which items are traversed.
+     */
+    protected Predicate traversalPredicate = Predicate.TRUE;
+
+    /**
+     * Do we want to walk all properties of nodes?
+     * The default is false.
+     */
+    protected boolean walkProperties = false;
+
+    /**
+     * indicates if traversal should be done in a breadth-first
+     * manner rather than depth-first (which is the default)
+     */
+    protected boolean breadthFirst = false;
+
+    /**
+     * the 0-based level up to which the hierarchy should be traversed
+     * (if it's -1, the hierarchy will be traversed until there are no
+     * more children of the current item)
+     */
+    protected int maxLevel = -1;
+
+    /**
+     * queues used to implement breadth-first traversal
+     */
+    protected LinkedList currentQueue;
+    protected LinkedList nextQueue;
+
+    /**
+     * used to track hierarchy level of item currently being processed
+     */
+    protected int currentLevel;
+
+    public void setMaxLevel(final int ml) {
+        this.maxLevel = ml;
+    }
+
+    public void setBreadthFirst(final boolean flag) {
+        if ( this.breadthFirst != flag ) {
+            this.breadthFirst = flag;
+            if (breadthFirst) {
+                this.currentQueue = new LinkedList();
+                this.nextQueue = new LinkedList();
+            } else {
+                this.currentQueue = null;
+                this.nextQueue = null;
+            }
+
+        }
+    }
+    public void setWalkProperties(final boolean flag) {
+        this.walkProperties = flag;
+    }
+
+    public void setIncludePredicate(final Predicate ip) {
+        this.includePredicate = ip;
+    }
+
+    public void setTraversalPredicate(final Predicate tp) {
+        this.traversalPredicate = tp;
+    }
+
+    /**
+     * Implement this method to add behaviour performed before a
+     * <code>Property</code> is visited.
+     *
+     * @param property the <code>Property</code> that is accepting this visitor.
+     * @param level    hierarchy level of this property (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract void entering(Property property, int level)
+        throws RepositoryException;
+
+    /**
+     * Implement this method to add behaviour performed before a
+     * <code>Node</code> is visited.
+     *
+     * @param node  the <code>Node</code> that is accepting this visitor.
+     * @param level hierarchy level of this node (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract void entering(Node node, int level)
+        throws RepositoryException;
+
+    /**
+     * Implement this method to add behaviour performed after a
+     * <code>Property</code> is visited.
+     *
+     * @param property the <code>Property</code> that is accepting this visitor.
+     * @param level    hierarchy level of this property (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract void leaving(Property property, int level)
+        throws RepositoryException;
+
+    /**
+     * Implement this method to add behaviour performed after a
+     * <code>Node</code> is visited.
+     *
+     * @param node  the <code>Node</code> that is accepting this visitor.
+     * @param level hierarchy level of this node (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract void leaving(Node node, int level)
+        throws RepositoryException;
+
+    /**
+     * Called when the Visitor is passed to a <code>Property</code>.
+     * <p/>
+     * It calls <code>TraversingItemVisitor.entering(Property, int)</code> followed by
+     * <code>TraversingItemVisitor.leaving(Property, int)</code>. Implement these abstract methods to
+     * specify behaviour on 'arrival at' and 'after leaving' the <code>Property</code>.
+     * <p/>
+     * <p/>
+     * If this method throws, the visiting process is aborted.
+     *
+     * @param property the <code>Property</code> that is accepting this visitor.
+     * @throws RepositoryException if an error occurrs
+     */
+    public void visit(Property property) throws RepositoryException {
+        if ( this.walkProperties && this.includePredicate.evaluate(property) ) {
+            entering(property, currentLevel);
+            leaving(property, currentLevel);
+        }
+    }
+
+    /**
+     * Called when the Visitor is passed to a <code>Node</code>.
+     * <p/>
+     * It calls <code>TraversingItemVisitor.entering(Node, int)</code> followed by
+     * <code>TraversingItemVisitor.leaving(Node, int)</code>. Implement these abstract methods to
+     * specify behaviour on 'arrival at' and 'after leaving' the <code>Node</code>.
+     * <p/>
+     * If this method throws, the visiting process is aborted.
+     *
+     * @param node the <code>Node</code> that is accepting this visitor.
+     * @throws RepositoryException if an error occurrs
+     */
+    public void visit(Node node)
+    throws RepositoryException {
+        if ( this.traversalPredicate.evaluate(node) ) {
+            if ( this.includePredicate == this.traversalPredicate || this.includePredicate.evaluate(node) )  {
+                try {
+                    if (!breadthFirst) {
+                        // depth-first traversal
+                        entering(node, currentLevel);
+                        if (maxLevel == -1 || currentLevel < maxLevel) {
+                            currentLevel++;
+                            if ( this.walkProperties ) {
+                                PropertyIterator propIter = node.getProperties();
+                                while (propIter.hasNext()) {
+                                    propIter.nextProperty().accept(this);
+                                }
+                            }
+                            NodeIterator nodeIter = node.getNodes();
+                            while (nodeIter.hasNext()) {
+                                nodeIter.nextNode().accept(this);
+                            }
+                            currentLevel--;
+                        }
+                        leaving(node, currentLevel);
+                    } else {
+                        // breadth-first traversal
+                        entering(node, currentLevel);
+                        leaving(node, currentLevel);
+
+                        if (maxLevel == -1 || currentLevel < maxLevel) {
+                            if ( this.walkProperties ) {
+                                PropertyIterator propIter = node.getProperties();
+                                while (propIter.hasNext()) {
+                                    nextQueue.addLast(propIter.nextProperty());
+                                }
+                            }
+                            NodeIterator nodeIter = node.getNodes();
+                            while (nodeIter.hasNext()) {
+                                nextQueue.addLast(nodeIter.nextNode());
+                            }
+                        }
+
+                        while (!currentQueue.isEmpty() || !nextQueue.isEmpty()) {
+                            if (currentQueue.isEmpty()) {
+                                currentLevel++;
+                                currentQueue = nextQueue;
+                                nextQueue = new LinkedList();
+                            }
+                            Item e = (Item) currentQueue.removeFirst();
+                            e.accept(this);
+                        }
+                        currentLevel = 0;
+                    }
+                } catch (RepositoryException re) {
+                    currentLevel = 0;
+                    throw re;
+                }
+            }
+        }
+    }
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/visitor/FilteringItemVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ProxyContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/XmlnsContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/flat/RankTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/xml/XmlnsContentHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/remote/SerializableXid.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/remote/SerializableXid.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/remote/SerializableXid.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/remote/SerializableXid.java Wed Oct 31 14:06:06 2012
@@ -1,71 +1,71 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.rmi.remote;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-import javax.transaction.xa.Xid;
-
-/**
- * Serializable {@link Xid}.
- *
- * @since Jackrabbit JCR-RMI 1.5
- */
-public class SerializableXid implements Serializable, Xid {
-
-    private final int formatId;
-
-    private final byte[] globalTransactionId;
-
-    private final byte[] branchQualifier;
-
-    private final int hashCode;
-
-    public SerializableXid(Xid xid) {
-        formatId = xid.getFormatId();
-        globalTransactionId = xid.getGlobalTransactionId();
-        branchQualifier = xid.getBranchQualifier();
-        hashCode = xid.hashCode();
-    }
-
-    public int getFormatId() {
-        return formatId;
-    }
-
-    public byte[] getGlobalTransactionId() {
-        return globalTransactionId;
-    }
-
-    public byte[] getBranchQualifier() {
-        return branchQualifier;
-    }
-
-    public int hashCode() {
-        return hashCode;
-    }
-
-    public boolean equals(Object xid) {
-        return (xid instanceof Xid)
-            && formatId == ((Xid) xid).getFormatId()
-            && Arrays.equals(
-                    globalTransactionId, ((Xid) xid).getGlobalTransactionId())
-            && Arrays.equals(
-                    branchQualifier, ((Xid) xid).getBranchQualifier());
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.rmi.remote;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * Serializable {@link Xid}.
+ *
+ * @since Jackrabbit JCR-RMI 1.5
+ */
+public class SerializableXid implements Serializable, Xid {
+
+    private final int formatId;
+
+    private final byte[] globalTransactionId;
+
+    private final byte[] branchQualifier;
+
+    private final int hashCode;
+
+    public SerializableXid(Xid xid) {
+        formatId = xid.getFormatId();
+        globalTransactionId = xid.getGlobalTransactionId();
+        branchQualifier = xid.getBranchQualifier();
+        hashCode = xid.hashCode();
+    }
+
+    public int getFormatId() {
+        return formatId;
+    }
+
+    public byte[] getGlobalTransactionId() {
+        return globalTransactionId;
+    }
+
+    public byte[] getBranchQualifier() {
+        return branchQualifier;
+    }
+
+    public int hashCode() {
+        return hashCode;
+    }
+
+    public boolean equals(Object xid) {
+        return (xid instanceof Xid)
+            && formatId == ((Xid) xid).getFormatId()
+            && Arrays.equals(
+                    globalTransactionId, ((Xid) xid).getGlobalTransactionId())
+            && Arrays.equals(
+                    branchQualifier, ((Xid) xid).getBranchQualifier());
+    }
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/remote/SerializableXid.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/SimpleWebdavServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/FilterRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/FilterRepositoryFactory.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/FilterRepositoryFactory.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/FilterRepositoryFactory.java Wed Oct 31 14:06:06 2012
@@ -1,95 +1,95 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.servlet;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-
-import org.apache.jackrabbit.commons.repository.RepositoryFactory;
-
-/**
- * Factory that looks up a repository from the context of a given filter.
- * <p>
- * The default name of the repository attribute is
- * "<code>javax.jcr.Repository</code>", but it can be changed by specifying
- * an init parameter with the same name:
- * <pre>
- * &lt;filter&gt;
- *   &lt;init-param&gt;
- *     &lt;param-name&gt;javax.jcr.Repository&lt;/param-name&gt;
- *     &lt;param-value&gt;my.repository.attribute&lt;/param-value&gt;
- *     &lt;description&gt;
- *       This init parameter causes the repository to be looked up from
- *       the "my.repository.attribute" attribute instead of the default
- *       "javax.jcr.Repository".
- *     &lt;/description&gt;
- *   &lt;/init-param&gt;
- * &lt;/filter&gt;
- * </pre>
- *
- * @since Apache Jackrabbit 1.6
- */
-public class FilterRepositoryFactory implements RepositoryFactory {
-
-    /**
-     * Configuration of the filter whose context contains the repository.
-     */
-    private final FilterConfig config;
-
-    /**
-     * Creates a factory for looking up a repository from the context
-     * associated with the given filter configuration.
-     *
-     * @param config filter configuration
-     */
-    public FilterRepositoryFactory(FilterConfig config) {
-        this.config = config;
-    }
-
-    /**
-     * Looks up and returns a repository bound in the servlet context of
-     * the given filter.
-     *
-     * @return repository from servlet context
-     * @throws RepositoryException if the repository is not available
-     */
-    public Repository getRepository() throws RepositoryException {
-        String name = config.getInitParameter(Repository.class.getName());
-        if (name == null) {
-            name = Repository.class.getName();
-        }
-
-        ServletContext context = config.getServletContext();
-        Object repository = context.getAttribute(name);
-        if (repository instanceof Repository) {
-            return (Repository) repository;
-        } else if (repository != null) {
-            throw new RepositoryException(
-                    "Invalid repository: Attribute " + name
-                    + " in servlet context " + context.getServletContextName()
-                    + " is an instance of " + repository.getClass().getName());
-        } else {
-            throw new RepositoryException(
-                    "Repository not found: Attribute " + name
-                    + " does not exist in servlet context "
-                    + context.getServletContextName());
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.servlet;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+
+import org.apache.jackrabbit.commons.repository.RepositoryFactory;
+
+/**
+ * Factory that looks up a repository from the context of a given filter.
+ * <p>
+ * The default name of the repository attribute is
+ * "<code>javax.jcr.Repository</code>", but it can be changed by specifying
+ * an init parameter with the same name:
+ * <pre>
+ * &lt;filter&gt;
+ *   &lt;init-param&gt;
+ *     &lt;param-name&gt;javax.jcr.Repository&lt;/param-name&gt;
+ *     &lt;param-value&gt;my.repository.attribute&lt;/param-value&gt;
+ *     &lt;description&gt;
+ *       This init parameter causes the repository to be looked up from
+ *       the "my.repository.attribute" attribute instead of the default
+ *       "javax.jcr.Repository".
+ *     &lt;/description&gt;
+ *   &lt;/init-param&gt;
+ * &lt;/filter&gt;
+ * </pre>
+ *
+ * @since Apache Jackrabbit 1.6
+ */
+public class FilterRepositoryFactory implements RepositoryFactory {
+
+    /**
+     * Configuration of the filter whose context contains the repository.
+     */
+    private final FilterConfig config;
+
+    /**
+     * Creates a factory for looking up a repository from the context
+     * associated with the given filter configuration.
+     *
+     * @param config filter configuration
+     */
+    public FilterRepositoryFactory(FilterConfig config) {
+        this.config = config;
+    }
+
+    /**
+     * Looks up and returns a repository bound in the servlet context of
+     * the given filter.
+     *
+     * @return repository from servlet context
+     * @throws RepositoryException if the repository is not available
+     */
+    public Repository getRepository() throws RepositoryException {
+        String name = config.getInitParameter(Repository.class.getName());
+        if (name == null) {
+            name = Repository.class.getName();
+        }
+
+        ServletContext context = config.getServletContext();
+        Object repository = context.getAttribute(name);
+        if (repository instanceof Repository) {
+            return (Repository) repository;
+        } else if (repository != null) {
+            throw new RepositoryException(
+                    "Invalid repository: Attribute " + name
+                    + " in servlet context " + context.getServletContextName()
+                    + " is an instance of " + repository.getClass().getName());
+        } else {
+            throw new RepositoryException(
+                    "Repository not found: Attribute " + name
+                    + " does not exist in servlet context "
+                    + context.getServletContextName());
+        }
+    }
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/FilterRepositoryFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/AbstractLoginFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/AbstractLoginFilter.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/AbstractLoginFilter.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/AbstractLoginFilter.java Wed Oct 31 14:06:06 2012
@@ -1,113 +1,113 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.servlet.login;
-
-import java.io.IOException;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Credentials;
-import javax.jcr.LoginException;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.jackrabbit.servlet.ServletRepository;
-
-/**
- *
- * @since Apache Jackrabbit 1.6
- */
-public abstract class AbstractLoginFilter implements Filter {
-
-    private Repository repository;
-
-    private String workspace;
-
-    private String sessionAttribute;
-
-    private String nodeAttribute;
-
-    public void init(FilterConfig config) {
-        repository = new ServletRepository(config);
-        workspace = config.getInitParameter("workspace");
-
-        sessionAttribute = config.getInitParameter(Session.class.getName());
-        if (sessionAttribute == null) {
-            sessionAttribute = Session.class.getName();
-        }
-
-        nodeAttribute = config.getInitParameter(Node.class.getName());
-        if (nodeAttribute == null) {
-            nodeAttribute = Node.class.getName();
-        }
-    }
-
-    public void destroy() {
-    }
-
-    public void doFilter(
-            ServletRequest request, ServletResponse response,
-            FilterChain chain) throws IOException, ServletException {
-        HttpServletRequest httpRequest = (HttpServletRequest) request;
-        HttpServletResponse httpResponse = (HttpServletResponse) response;
-        try {
-            Credentials credentials = getCredentials(httpRequest);
-            Session session = repository.login(credentials, workspace);
-            try {
-                request.setAttribute(sessionAttribute, session);
-                request.setAttribute(nodeAttribute, session.getRootNode());
-                chain.doFilter(request, response);
-                if (session.hasPendingChanges()) {
-                    session.save();
-                }
-            } finally {
-                session.logout();
-            }
-        } catch (ServletException e) {
-            Throwable cause = e.getRootCause();
-            if (cause instanceof AccessDeniedException) {
-                httpResponse.sendError(
-                        HttpServletResponse.SC_FORBIDDEN, cause.getMessage());
-            } else {
-                throw e;
-            }
-        } catch (LoginException e) {
-            httpResponse.sendError(
-                    HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
-        } catch (NoSuchWorkspaceException e) {
-            throw new ServletException(
-                    "Workspace " + workspace
-                    + " not found in the content repository", e);
-        } catch (RepositoryException e) {
-            throw new ServletException(
-                    "Unable to access the content repository", e);
-        }
-    }
-
-    protected abstract Credentials getCredentials(HttpServletRequest request);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.servlet.login;
+
+import java.io.IOException;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jackrabbit.servlet.ServletRepository;
+
+/**
+ *
+ * @since Apache Jackrabbit 1.6
+ */
+public abstract class AbstractLoginFilter implements Filter {
+
+    private Repository repository;
+
+    private String workspace;
+
+    private String sessionAttribute;
+
+    private String nodeAttribute;
+
+    public void init(FilterConfig config) {
+        repository = new ServletRepository(config);
+        workspace = config.getInitParameter("workspace");
+
+        sessionAttribute = config.getInitParameter(Session.class.getName());
+        if (sessionAttribute == null) {
+            sessionAttribute = Session.class.getName();
+        }
+
+        nodeAttribute = config.getInitParameter(Node.class.getName());
+        if (nodeAttribute == null) {
+            nodeAttribute = Node.class.getName();
+        }
+    }
+
+    public void destroy() {
+    }
+
+    public void doFilter(
+            ServletRequest request, ServletResponse response,
+            FilterChain chain) throws IOException, ServletException {
+        HttpServletRequest httpRequest = (HttpServletRequest) request;
+        HttpServletResponse httpResponse = (HttpServletResponse) response;
+        try {
+            Credentials credentials = getCredentials(httpRequest);
+            Session session = repository.login(credentials, workspace);
+            try {
+                request.setAttribute(sessionAttribute, session);
+                request.setAttribute(nodeAttribute, session.getRootNode());
+                chain.doFilter(request, response);
+                if (session.hasPendingChanges()) {
+                    session.save();
+                }
+            } finally {
+                session.logout();
+            }
+        } catch (ServletException e) {
+            Throwable cause = e.getRootCause();
+            if (cause instanceof AccessDeniedException) {
+                httpResponse.sendError(
+                        HttpServletResponse.SC_FORBIDDEN, cause.getMessage());
+            } else {
+                throw e;
+            }
+        } catch (LoginException e) {
+            httpResponse.sendError(
+                    HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
+        } catch (NoSuchWorkspaceException e) {
+            throw new ServletException(
+                    "Workspace " + workspace
+                    + " not found in the content repository", e);
+        } catch (RepositoryException e) {
+            throw new ServletException(
+                    "Unable to access the content repository", e);
+        }
+    }
+
+    protected abstract Credentials getCredentials(HttpServletRequest request);
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/AbstractLoginFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/BasicLoginFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/BasicLoginFilter.java?rev=1404144&r1=1404143&r2=1404144&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/BasicLoginFilter.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/BasicLoginFilter.java Wed Oct 31 14:06:06 2012
@@ -1,38 +1,38 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.servlet.login;
-
-import javax.jcr.Credentials;
-import javax.jcr.SimpleCredentials;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- *
- * @since Apache Jackrabbit 1.6
- */
-public class BasicLoginFilter extends AbstractLoginFilter {
-
-    protected Credentials getCredentials(HttpServletRequest request) {
-        String authorization = request.getHeader("Authorization");
-        if (authorization != null) {
-            return new SimpleCredentials("TODO", "TODO".toCharArray());
-        } else {
-            return null;
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.servlet.login;
+
+import javax.jcr.Credentials;
+import javax.jcr.SimpleCredentials;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ *
+ * @since Apache Jackrabbit 1.6
+ */
+public class BasicLoginFilter extends AbstractLoginFilter {
+
+    protected Credentials getCredentials(HttpServletRequest request) {
+        String authorization = request.getHeader("Authorization");
+        if (authorization != null) {
+            return new SimpleCredentials("TODO", "TODO".toCharArray());
+        } else {
+            return null;
+        }
+    }
+
+}

Propchange: jackrabbit/branches/2.2/jackrabbit-jcr-servlet/src/main/java/org/apache/jackrabbit/servlet/login/BasicLoginFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native