jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r599177 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: NodeImpl.java RepositoryImpl.java SessionImpl.java WorkspaceImpl.java nodetype/NodeTypeManagerImpl.java xml/SAXParserProvider.java
Date Wed, 28 Nov 2007 22:50:20 GMT
Author: jukka
Date: Wed Nov 28 14:50:19 2007
New Revision: 599177

URL: http://svn.apache.org/viewvc?rev=599177&view=rev
Log:
JCR-1181: Use common base classes in core

Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SAXParserProvider.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=599177&r1=599176&r2=599177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Wed Nov 28 14:50:19 2007
@@ -42,12 +42,13 @@
 import org.apache.jackrabbit.core.version.DateVersionSelector;
 import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.lock.LockManager;
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
 import org.apache.jackrabbit.conversion.MalformedPathException;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ChildrenCollectorFilter;
-import org.apache.jackrabbit.util.IteratorHelper;
 import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.name.NameConstants;
@@ -92,7 +93,6 @@
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Calendar;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -2816,7 +2816,7 @@
         ArrayList nodes = new ArrayList();
         // traverse children using a special filtering 'collector'
         accept(new ChildrenCollectorFilter(namePattern, nodes, true, false, 1));
-        return new IteratorHelper(Collections.unmodifiableList(nodes));
+        return new NodeIteratorAdapter(nodes);
     }
 
     /**
@@ -2830,7 +2830,7 @@
         ArrayList properties = new ArrayList();
         // traverse children using a special filtering 'collector'
         accept(new ChildrenCollectorFilter(namePattern, properties, false, true, 1));
-        return new IteratorHelper(Collections.unmodifiableList(properties));
+        return new PropertyIteratorAdapter(properties);
     }
 
     /**
@@ -4322,7 +4322,7 @@
                 return new LazyItemIterator(itemMgr, idList);
             } else {
                 // there are no references, return empty iterator
-                return IteratorHelper.EMPTY;
+                return PropertyIteratorAdapter.EMPTY;
             }
         } catch (ItemStateException e) {
             String msg = "Unable to retrieve REFERENCE properties that refer to " + id;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=599177&r1=599176&r2=599177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Wed Nov 28 14:50:19 2007
@@ -22,6 +22,7 @@
 import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.commons.AbstractRepository;
 import org.apache.jackrabbit.core.cluster.ClusterContext;
 import org.apache.jackrabbit.core.cluster.ClusterException;
 import org.apache.jackrabbit.core.cluster.ClusterNode;
@@ -99,8 +100,8 @@
 /**
  * A <code>RepositoryImpl</code> ...
  */
-public class RepositoryImpl implements JackrabbitRepository, SessionListener,
-        EventListener {
+public class RepositoryImpl extends AbstractRepository
+        implements JackrabbitRepository, SessionListener, EventListener {
 
     private static Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
 
@@ -1234,29 +1235,6 @@
         } finally {
             shutdownLock.readLock().release();
         }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Session login(String workspaceName)
-            throws LoginException, NoSuchWorkspaceException, RepositoryException {
-        return login(null, workspaceName);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Session login() throws LoginException, RepositoryException {
-        return login(null, null);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Session login(Credentials credentials)
-            throws LoginException, RepositoryException {
-        return login(credentials, null);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=599177&r1=599176&r2=599177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Wed Nov 28 14:50:19 2007
@@ -17,9 +17,6 @@
 package org.apache.jackrabbit.core;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.PrintStream;
 import java.security.AccessControlException;
 import java.security.Principal;
@@ -34,7 +31,6 @@
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.Item;
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -59,12 +55,6 @@
 import javax.jcr.observation.ObservationManager;
 import javax.jcr.version.VersionException;
 import javax.security.auth.Subject;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
 
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.collections.map.ReferenceMap;
@@ -86,9 +76,9 @@
 import org.apache.jackrabbit.core.version.VersionManager;
 import org.apache.jackrabbit.core.xml.DocViewSAXEventGenerator;
 import org.apache.jackrabbit.core.xml.ImportHandler;
-import org.apache.jackrabbit.core.xml.SAXParserProvider;
 import org.apache.jackrabbit.core.xml.SessionImporter;
 import org.apache.jackrabbit.core.xml.SysViewSAXEventGenerator;
+import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.conversion.DefaultNamePathResolver;
@@ -108,7 +98,8 @@
 /**
  * A <code>SessionImpl</code> ...
  */
-public class SessionImpl implements Session, NamePathResolver, Dumpable {
+public class SessionImpl extends AbstractSession
+        implements NamePathResolver, Dumpable {
 
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
@@ -1114,36 +1105,6 @@
     /**
      * {@inheritDoc}
      */
-    public void importXML(String parentAbsPath, InputStream in,
-                          int uuidBehavior)
-            throws IOException, PathNotFoundException, ItemExistsException,
-            ConstraintViolationException, VersionException,
-            InvalidSerializedDataException, LockException, RepositoryException {
-        // check sanity of this session
-        sanityCheck();
-
-        ImportHandler handler = (ImportHandler)
-                getImportContentHandler(parentAbsPath, uuidBehavior);
-        try {
-            SAXParserProvider.getParser().parse(new InputSource(in), handler);
-        } catch (SAXException se) {
-            // check for wrapped repository exception
-            Exception e = se.getException();
-            if (e != null && e instanceof RepositoryException) {
-                throw (RepositoryException) e;
-            } else {
-                String msg = "failed to parse XML stream";
-                log.debug(msg);
-                throw new InvalidSerializedDataException(msg, se);
-            }
-        } catch (ParserConfigurationException e) {
-            throw new RepositoryException("SAX parser configuration error", e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void exportDocumentView(String absPath, ContentHandler contentHandler,
                                    boolean skipBinary, boolean noRecurse)
             throws PathNotFoundException, SAXException, RepositoryException {
@@ -1162,30 +1123,6 @@
     /**
      * {@inheritDoc}
      */
-    public void exportDocumentView(String absPath, OutputStream out,
-                                   boolean skipBinary, boolean noRecurse)
-            throws IOException, PathNotFoundException, RepositoryException {
-
-        SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-
-        try {
-            TransformerHandler th = stf.newTransformerHandler();
-            th.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
-            th.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            th.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
-            th.setResult(new StreamResult(out));
-
-            exportDocumentView(absPath, th, skipBinary, noRecurse);
-        } catch (TransformerException te) {
-            throw new RepositoryException(te);
-        } catch (SAXException se) {
-            throw new RepositoryException(se);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void exportSystemView(String absPath, ContentHandler contentHandler,
                                  boolean skipBinary, boolean noRecurse)
             throws PathNotFoundException, SAXException, RepositoryException {
@@ -1199,29 +1136,6 @@
         }
         new SysViewSAXEventGenerator((Node) item, noRecurse, skipBinary,
                 contentHandler).serialize();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void exportSystemView(String absPath, OutputStream out,
-                                 boolean skipBinary, boolean noRecurse)
-            throws IOException, PathNotFoundException, RepositoryException {
-
-        SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-        try {
-            TransformerHandler th = stf.newTransformerHandler();
-            th.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
-            th.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            th.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
-            th.setResult(new StreamResult(out));
-
-            exportSystemView(absPath, th, skipBinary, noRecurse);
-        } catch (TransformerException te) {
-            throw new RepositoryException(te);
-        } catch (SAXException se) {
-            throw new RepositoryException(se);
-        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=599177&r1=599176&r2=599177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Wed Nov 28 14:50:19 2007
@@ -30,19 +30,17 @@
 import org.apache.jackrabbit.core.version.VersionSelector;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.Importer;
-import org.apache.jackrabbit.core.xml.SAXParserProvider;
 import org.apache.jackrabbit.core.xml.WorkspaceImporter;
+import org.apache.jackrabbit.commons.AbstractWorkspace;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.spi.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.InvalidItemStateException;
-import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NamespaceRegistry;
@@ -59,17 +57,15 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
-import javax.xml.parsers.ParserConfigurationException;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 
 /**
  * A <code>WorkspaceImpl</code> ...
  */
-public class WorkspaceImpl implements JackrabbitWorkspace, EventStateCollectionFactory {
+public class WorkspaceImpl extends AbstractWorkspace
+        implements JackrabbitWorkspace, EventStateCollectionFactory {
 
     private static Logger log = LoggerFactory.getLogger(WorkspaceImpl.class);
 
@@ -811,34 +807,6 @@
                 rep.getNodeTypeRegistry(), uuidBehavior);
         return new ImportHandler(importer, session.getNamespaceResolver(),
                 rep.getNamespaceRegistry());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void importXML(String parentAbsPath, InputStream in,
-                          int uuidBehavior)
-            throws IOException, PathNotFoundException, ItemExistsException,
-            ConstraintViolationException, InvalidSerializedDataException,
-            LockException, RepositoryException {
-
-        ImportHandler handler =
-                (ImportHandler) getImportContentHandler(parentAbsPath, uuidBehavior);
-        try {
-            SAXParserProvider.getParser().parse(new InputSource(in), handler);
-        } catch (SAXException se) {
-            // check for wrapped repository exception
-            Exception e = se.getException();
-            if (e != null && e instanceof RepositoryException) {
-                throw (RepositoryException) e;
-            } else {
-                String msg = "failed to parse XML stream";
-                log.debug(msg);
-                throw new InvalidSerializedDataException(msg, se);
-            }
-        } catch (ParserConfigurationException e) {
-            throw new RepositoryException("SAX parser configuration error", e);
-        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=599177&r1=599176&r2=599177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
Wed Nov 28 14:50:19 2007
@@ -18,6 +18,7 @@
 
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
@@ -36,7 +37,6 @@
 import org.apache.jackrabbit.namespace.NamespaceMapping;
 import org.apache.jackrabbit.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.util.IteratorHelper;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -57,7 +57,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -391,7 +390,7 @@
         for (int i = 0; i < ntNames.length; i++) {
             list.add(getNodeType(ntNames[i]));
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**
@@ -406,7 +405,7 @@
                 list.add(nt);
             }
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**
@@ -421,7 +420,7 @@
                 list.add(nt);
             }
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**
@@ -716,7 +715,8 @@
                 ntReg.reregisterNodeType(nodeTypeDef);
                 result.add(getNodeType(nodeTypeDef.getName()));
             }
-            return new IteratorHelper(result);
+
+            return new NodeTypeIteratorAdapter(result);
         } catch (InvalidNodeTypeDefException e) {
             throw new InvalidNodeTypeDefinitionException(e.getMessage());
         }



Mime
View raw message