jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r603822 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
Date Thu, 13 Dec 2007 05:34:28 GMT
Author: jukka
Date: Wed Dec 12 21:34:18 2007
New Revision: 603822

URL: http://svn.apache.org/viewvc?rev=603822&view=rev
Log:
JCR-1181: Use the new iterator adapters instead of IteratorHelper

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java?rev=603822&r1=603821&r2=603822&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
Wed Dec 12 21:34:18 2007
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr.version.report;
 
-import org.apache.jackrabbit.util.IteratorHelper;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavServletResponse;
@@ -41,7 +41,6 @@
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -170,21 +169,18 @@
      * @throws DavException
      */
     private static NodeTypeIterator getNodeTypes(Session session, ReportInfo info) throws
RepositoryException, DavException {
-        NodeTypeIterator ntIter = null;
         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
 
         // check the simple types first...
         if (info.containsContentElement(XML_REPORT_ALLNODETYPES, NAMESPACE)) {
-            ntIter = ntMgr.getAllNodeTypes();
+            return ntMgr.getAllNodeTypes();
         } else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, NAMESPACE)) {
-            ntIter = ntMgr.getMixinNodeTypes();
+            return ntMgr.getMixinNodeTypes();
         } else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, NAMESPACE)) {
-            ntIter = ntMgr.getPrimaryNodeTypes();
-        }
-        // None of the simple types. test if a report for individual nodetypes
-        // was request. If not, the request body is not valid.
-        if (ntIter == null) {
-            List ntList = new ArrayList();
+            return ntMgr.getPrimaryNodeTypes();
+        } else {
+            // None of the simple types. test if a report for individual
+            // nodetype was request. If not, the request body is not valid.
             List elemList = info.getContentElements(XML_NODETYPE, NAMESPACE);
             if (elemList.isEmpty()) {
                 // throw exception if the request body does not contain a single nodetype
element
@@ -192,6 +188,7 @@
             }
 
             // todo: find better solution...
+            List ntList = new ArrayList();
             Iterator elemIter = elemList.iterator();
             while (elemIter.hasNext()) {
                 Element el = ((Element)elemIter.next());
@@ -200,9 +197,7 @@
                     ntList.add(ntMgr.getNodeType(nodetypeName));
                 }
             }
-            ntIter = new IteratorHelper(Collections.unmodifiableCollection(ntList));
+            return new NodeTypeIteratorAdapter(ntList);
         }
-
-        return ntIter;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java?rev=603822&r1=603821&r2=603822&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
Wed Dec 12 21:34:18 2007
@@ -19,19 +19,18 @@
 import org.apache.jackrabbit.spi.QueryInfo;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.util.IteratorHelper;
 import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.RangeIteratorDecorator;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.query.QueryResult;
-import javax.jcr.query.RowIterator;
 import javax.jcr.query.Row;
 import javax.jcr.RepositoryException;
 import javax.jcr.RangeIterator;
-import java.util.Iterator;
 import java.util.NoSuchElementException;
 
 /**
@@ -116,35 +115,24 @@
      * {@inheritDoc}
      */
     public RangeIterator getRows() {
-        final String[] columnJcrNames;
-        final RowIterator rows;
         try {
-            columnJcrNames = result.getColumnNames();
-            rows = result.getRows();
+            final String[] columnJcrNames = result.getColumnNames();
+            return new RangeIteratorDecorator(result.getRows()) {
+                public Object next() {
+                    try {
+                        return new QueryResultRowImpl(
+                                (Row) super.next(), columnJcrNames, scoreName,
+                                pathName, idFactory, resolver, qValueFactory);
+                    } catch (RepositoryException e) {
+                        log.warn("Exception when creating QueryResultRowImpl: " +
+                                e.getMessage(), e);
+                        throw new NoSuchElementException();
+                    }
+                }
+            };
         } catch (RepositoryException e) {
-            return IteratorHelper.EMPTY;
+            return RangeIteratorAdapter.EMPTY;
         }
-        return new IteratorHelper(new Iterator() {
-            public void remove() {
-                rows.remove();
-            }
-
-            public boolean hasNext() {
-                return rows.hasNext();
-            }
-
-            public Object next() {
-                try {
-                    Row row = rows.nextRow();
-                    return new QueryResultRowImpl(row, columnJcrNames, scoreName,
-                            pathName, idFactory, resolver, qValueFactory);
-                } catch (RepositoryException e) {
-                    log.warn("Exception when creating QueryResultRowImpl: " +
-                            e.getMessage(), e);
-                    throw new NoSuchElementException();
-                }
-            }
-        });
     }
 
     /**



Mime
View raw message