jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r599171 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ nodetype/ observation/ state/
Date Wed, 28 Nov 2007 22:35:11 GMT
Author: jukka
Date: Wed Nov 28 14:35:10 2007
New Revision: 599171

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

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Wed Nov 28 14:35:10 2007
@@ -17,9 +17,10 @@
 package org.apache.jackrabbit.jcr2spi;
 
 import org.apache.jackrabbit.util.ChildrenCollectorFilter;
-import org.apache.jackrabbit.util.IteratorHelper;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.value.ValueFormat;
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
@@ -80,7 +81,6 @@
 import java.io.InputStream;
 import java.util.Calendar;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -438,7 +438,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);
     }
 
     /**
@@ -485,7 +485,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);
     }
 
     /**
@@ -539,7 +539,7 @@
         NodeReferences refs = getNodeState().getNodeReferences();
         if (refs.isEmpty()) {
             // there are no references, return empty iterator
-            return IteratorHelper.EMPTY;
+            return PropertyIteratorAdapter.EMPTY;
         } else {
             return new LazyItemIterator(itemMgr, session.getHierarchyManager(), refs.iterator());
         }
@@ -884,7 +884,7 @@
 
         // if same workspace, ignore
         if (session.getWorkspace().getName().equals(srcWorkspace)) {
-            return IteratorHelper.EMPTY;
+            return NodeIteratorAdapter.EMPTY;
         }
         // make sure the workspace exists and is accessible for this session.
         session.checkAccessibleWorkspace(srcWorkspace);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
Wed Nov 28 14:35:10 2007
@@ -35,18 +35,15 @@
 import javax.naming.StringRefAddr;
 import javax.naming.spi.ObjectFactory;
 
+import org.apache.jackrabbit.commons.AbstractRepository;
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.XASessionInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>RepositoryImpl</code>...
  */
-public class RepositoryImpl implements Repository, Referenceable {
-
-    private static Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
+public class RepositoryImpl extends AbstractRepository implements Referenceable {
 
     // configuration of the repository
     private final RepositoryConfig config;
@@ -94,27 +91,6 @@
             config.getRepositoryService().dispose(info);
             throw ex;
         }
-    }
-
-    /**
-     * @see Repository#login(javax.jcr.Credentials)
-     */
-    public Session login(Credentials credentials) throws LoginException, NoSuchWorkspaceException,
RepositoryException {
-        return login(credentials, null);
-    }
-
-    /**
-     * @see Repository#login(String)
-     */
-    public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException,
RepositoryException {
-        return login(null, workspaceName);
-    }
-
-    /**
-     * @see Repository#login()
-     */
-    public Session login() throws LoginException, NoSuchWorkspaceException, RepositoryException
{
-        return login(null, null);
     }
 
     //---------------------------------------------------------< Rereferencable >---

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Wed Nov 28 14:35:10 2007
@@ -52,6 +52,7 @@
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.conversion.PathResolver;
@@ -61,7 +62,6 @@
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 import javax.jcr.AccessDeniedException;
@@ -86,25 +86,14 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.Version;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.TransformerException;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.ParserConfigurationException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+
 import java.security.AccessControlException;
 import java.util.Map;
 
 /**
  * <code>SessionImpl</code>...
  */
-public class SessionImpl implements Session, ManagerProvider {
+public class SessionImpl extends AbstractSession implements ManagerProvider {
 
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
@@ -395,35 +384,6 @@
     }
 
     /**
-     * @see javax.jcr.Session#importXML(String, java.io.InputStream, int)
-     */
-    public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws
IOException, PathNotFoundException, ItemExistsException, ConstraintViolationException, VersionException,
InvalidSerializedDataException, LockException, RepositoryException {
-        // NOTE: checks are performed by 'getImportContentHandler'
-        ImportHandler handler = (ImportHandler) getImportContentHandler(parentAbsPath, uuidBehavior);
-        try {
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            factory.setNamespaceAware(true);
-            factory.setFeature(
-                    "http://xml.org/sax/features/namespace-prefixes", false);
-
-            SAXParser parser = factory.newSAXParser();
-            parser.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);
-        }
-    }
-
-    /**
      * @see javax.jcr.Session#exportSystemView(String, org.xml.sax.ContentHandler, boolean,
boolean)
      */
     public void exportSystemView(String absPath, ContentHandler contentHandler, boolean skipBinary,
boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException {
@@ -437,26 +397,6 @@
     }
 
     /**
-     * @see javax.jcr.Session#exportSystemView(String, OutputStream, boolean, boolean)
-     */
-    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);
-        }
-    }
-
-    /**
      * @see javax.jcr.Session#exportDocumentView(String, org.xml.sax.ContentHandler, boolean,
boolean)
      */
     public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean
skipBinary, boolean noRecurse) throws InvalidSerializedDataException, PathNotFoundException,
SAXException, RepositoryException {
@@ -467,26 +407,6 @@
             throw new PathNotFoundException(absPath);
         }
         new DocViewSAXEventGenerator((Node) item, noRecurse, skipBinary, contentHandler).serialize();
-    }
-
-    /**
-     * @see javax.jcr.Session#exportDocumentView(String, OutputStream, boolean, boolean)
-     */
-    public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse) throws InvalidSerializedDataException, 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);
-        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Wed Nov 28 14:35:10 2007
@@ -30,7 +30,6 @@
 import org.apache.jackrabbit.jcr2spi.operation.Copy;
 import org.apache.jackrabbit.jcr2spi.operation.Clone;
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
-import org.apache.jackrabbit.jcr2spi.operation.WorkspaceImport;
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
 import org.apache.jackrabbit.jcr2spi.lock.LockManager;
 import org.apache.jackrabbit.jcr2spi.lock.LockManagerImpl;
@@ -48,6 +47,7 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.commons.AbstractWorkspace;
 import org.apache.jackrabbit.conversion.NameResolver;
 import org.apache.jackrabbit.conversion.PathResolver;
 import org.apache.jackrabbit.conversion.NamePathResolver;
@@ -63,7 +63,6 @@
 import javax.jcr.version.Version;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.Workspace;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.AccessDeniedException;
@@ -74,15 +73,12 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.NamespaceRegistry;
-import javax.jcr.InvalidSerializedDataException;
 import javax.jcr.ValueFactory;
-import java.io.InputStream;
-import java.io.IOException;
 
 /**
  * <code>WorkspaceImpl</code>...
  */
-public class WorkspaceImpl implements Workspace, ManagerProvider {
+public class WorkspaceImpl extends AbstractWorkspace implements ManagerProvider {
 
     private static Logger log = LoggerFactory.getLogger(WorkspaceImpl.class);
 
@@ -324,32 +320,6 @@
 
             // build the content handler
             return new WorkspaceContentHandler(this, parentAbsPath, uuidBehavior);
-        } else {
-            throw new PathNotFoundException("No node at path " + parentAbsPath);
-        }
-    }
-
-    /**
-     * @see javax.jcr.Workspace#importXML(String, InputStream, int)
-     */
-    public void importXML(String parentAbsPath, InputStream in, int uuidBehavior)
-        throws IOException, PathNotFoundException, ItemExistsException,
-        ConstraintViolationException, InvalidSerializedDataException,
-        LockException, RepositoryException {
-
-        session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
-        session.checkIsAlive();
-
-        Path parentPath = session.getQPath(parentAbsPath);
-        ItemState itemState = getHierarchyManager().getItemState(parentPath);
-        if (itemState.isNode()) {
-            // make sure the given import target is accessible, not locked and checked out.
-            NodeState parentState = (NodeState) itemState;
-            int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK
| ItemStateValidator.CHECK_VERSIONING;
-            getValidator().checkIsWritable(parentState, options);
-
-            // run the import
-            wspManager.execute(WorkspaceImport.create(parentState, in, uuidBehavior));
         } else {
             throw new PathNotFoundException("No node at path " + parentAbsPath);
         }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
Wed Nov 28 14:35:10 2007
@@ -18,10 +18,10 @@
 
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.namespace.NamespaceResolver;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.util.IteratorHelper;
 import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
 import org.apache.jackrabbit.spi.QNodeDefinition;
@@ -43,7 +43,6 @@
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.nodetype.NodeDefinition;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 import java.io.PrintStream;
@@ -290,7 +289,7 @@
         for (int i = 0; i < ntNames.length; i++) {
             list.add(getNodeType(ntNames[i]));
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**
@@ -305,7 +304,7 @@
                 list.add(nt);
             }
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**
@@ -320,7 +319,7 @@
                 list.add(nt);
             }
         }
-        return new IteratorHelper(Collections.unmodifiableCollection(list));
+        return new NodeTypeIteratorAdapter(list);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
Wed Nov 28 14:35:10 2007
@@ -22,7 +22,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.EventFilter;
-import org.apache.jackrabbit.util.IteratorHelper;
+import org.apache.jackrabbit.commons.iterator.EventListenerIteratorAdapter;
 import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.conversion.NameException;
 import org.slf4j.Logger;
@@ -161,7 +161,7 @@
             ensureReadOnlyMap();
             activeListeners = readOnlySubscriptions;
         }
-        return new ListenerIterator(activeListeners.keySet());
+        return new EventListenerIteratorAdapter(activeListeners.keySet());
     }
 
     //-----------------------< InternalEventListener >--------------------------
@@ -212,15 +212,4 @@
         }
     }
 
-    private static final class ListenerIterator extends IteratorHelper
-            implements EventListenerIterator {
-
-        public ListenerIterator(Collection c) {
-            super(c);
-        }
-
-        public EventListener nextEventListener() {
-            return (EventListener) next();
-        }
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java?rev=599171&r1=599170&r2=599171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java
Wed Nov 28 14:35:10 2007
@@ -16,10 +16,7 @@
  */
 package org.apache.jackrabbit.jcr2spi.state;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.util.IteratorHelper;
-
+import java.util.Collections;
 import java.util.Iterator;
 
 /**
@@ -27,7 +24,6 @@
  */
 class EmptyNodeReferences implements NodeReferences {
 
-    private static Logger log = LoggerFactory.getLogger(EmptyNodeReferences.class);
     private static NodeReferences INSTANCE;
 
     private EmptyNodeReferences() {
@@ -46,6 +42,6 @@
     }
 
     public Iterator iterator() {
-        return IteratorHelper.EMPTY;
+        return Collections.EMPTY_LIST.iterator();
     }
 }



Mime
View raw message