jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1456030 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: SessionImpl.java xml/ImportHandler.java xml/SessionImporter.java
Date Wed, 13 Mar 2013 16:27:01 GMT
Author: mduerig
Date: Wed Mar 13 16:27:00 2013
New Revision: 1456030

URL: http://svn.apache.org/r1456030
Log:
OAK-672: Avoid JCR APIs calling other JCR APIs
- Clean up ImportHandler and SessionImporter

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1456030&r1=1456029&r2=1456030&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Wed Mar 13 16:27:00 2013
@@ -54,9 +54,7 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.delegate.SessionOperation;
 import org.apache.jackrabbit.oak.jcr.xml.ImportHandler;
 import org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials;
-import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.PermissionProvider;
-import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.apache.jackrabbit.oak.util.TODO;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.util.XMLChar;
@@ -348,12 +346,9 @@ public class SessionImpl extends Abstrac
 
     @Override
     @Nonnull
-    public ContentHandler getImportContentHandler(
-            String parentAbsPath, int uuidBehavior) throws RepositoryException {
-        UserConfiguration userConfiguration = sessionContext.getUserConfiguration();
-        AccessControlConfiguration accessControlConfiguration = sessionContext.getAccessControlConfiguration();
-        return new ImportHandler(getNode(parentAbsPath), dlg.getRoot(), this,
-                dlg, userConfiguration, accessControlConfiguration, uuidBehavior, sessionContext);
+    public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
+            throws RepositoryException {
+        return new ImportHandler(getNode(parentAbsPath), sessionContext, uuidBehavior);
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java?rev=1456030&r1=1456029&r2=1456030&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
Wed Mar 13 16:27:00 2013
@@ -21,16 +21,11 @@ import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.commons.NamespaceHelper;
-import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
-import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceConstants;
-import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
-import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.Attributes;
@@ -40,48 +35,39 @@ import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
- * An <code>ImportHandler</code> instance can be used to import serialized
+ * An {@code ImportHandler} instance can be used to import serialized
  * data in System View XML or Document View XML. Processing of the XML is
- * handled by specialized <code>ContentHandler</code>s
- * (i.e. <code>SysViewImportHandler</code> and <code>DocViewImportHandler</code>).
+ * handled by specialized {@code ContentHandler}s
+ * (i.e. {@code SysViewImportHandler} and {@code DocViewImportHandler}).
  * <p/>
  * The actual task of importing though is delegated to the implementation of
- * the <code>{@link Importer}</code> interface.
+ * the {@code {@link Importer}} interface.
  * <p/>
  * <b>Important Note:</b>
  * <p/>
  * These SAX Event Handlers expect that Namespace URI's and local names are
- * reported in the <code>start/endElement</code> events and that
- * <code>start/endPrefixMapping</code> events are reported
+ * reported in the {@code start/endElement} events and that
+ * {@code start/endPrefixMapping} events are reported
  * (i.e. default SAX2 Namespace processing).
  */
 public class ImportHandler extends DefaultHandler {
-
-    private static Logger log = LoggerFactory.getLogger(ImportHandler.class);
+    private static final Logger log = LoggerFactory.getLogger(ImportHandler.class);
 
     private final Importer importer;
     private final NamespaceHelper helper;
     private final ValueFactory valueFactory;
     protected Locator locator;
-    private TargetImportHandler targetHandler = null;
+    private TargetImportHandler targetHandler;
     private final Map<String, String> tempPrefixMap = new HashMap<String, String>();
 
-    public ImportHandler(Node importTargetNode, Root root, Session session,
-                         SessionDelegate dlg, UserConfiguration userConfig,
-                         AccessControlConfiguration accessControlConfig,
-                         int uuidBehavior, SessionContext sessionContext)
-            throws RepositoryException {
-        this.helper = new NamespaceHelper(session);
-        this.importer = new SessionImporter(importTargetNode, root, session, dlg, helper,
userConfig,
-                accessControlConfig, uuidBehavior, sessionContext);
-        this.valueFactory = session.getValueFactory();
+    public ImportHandler(Node importTargetNode, SessionContext sessionContext, int uuidBehavior)
{
+        this.helper = new NamespaceHelper(sessionContext.getSession());
+        this.importer = new SessionImporter(importTargetNode, sessionContext, helper, uuidBehavior);
+        this.valueFactory = sessionContext.getValueFactory();
     }
 
     //---------------------------------------------------------< ErrorHandler >
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void warning(SAXParseException e) throws SAXException {
         // log exception and carry on...
@@ -90,9 +76,6 @@ public class ImportHandler extends Defau
                 + " while parsing XML stream", e);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void error(SAXParseException e) throws SAXException {
         // log exception and carry on...
@@ -101,9 +84,6 @@ public class ImportHandler extends Defau
                 + " while parsing XML stream: " + e.toString());
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void fatalError(SAXParseException e) throws SAXException {
         // log and re-throw exception
@@ -115,9 +95,6 @@ public class ImportHandler extends Defau
 
     //-------------------------------------------------------< ContentHandler >
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void endDocument() throws SAXException {
         // delegate to target handler
@@ -162,9 +139,6 @@ public class ImportHandler extends Defau
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void startElement(String namespaceURI, String localName, String qName,
                              Attributes atts) throws SAXException {
@@ -188,9 +162,6 @@ public class ImportHandler extends Defau
         targetHandler.startElement(namespaceURI, localName, qName, atts);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void characters(char[] ch, int start, int length) throws SAXException {
         // delegate to target handler
@@ -208,9 +179,6 @@ public class ImportHandler extends Defau
         targetHandler.endElement(namespaceURI, localName, qName);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void setDocumentLocator(Locator locator) {
         this.locator = locator;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java?rev=1456030&r1=1456029&r2=1456030&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/SessionImporter.java
Wed Mar 13 16:27:00 2013
@@ -41,7 +41,6 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
-import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
@@ -56,20 +55,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * <code>SessionImporter</code> ...
+ * {@code SessionImporter} ...
  */
 public class SessionImporter implements Importer {
-
-    private static Logger log = LoggerFactory.getLogger(SessionImporter.class);
+    private static final Logger log = LoggerFactory.getLogger(SessionImporter.class);
 
     private final Session session;
     private final Node importTargetNode;
     private final Root root;
     private final int uuidBehavior;
-    private final SessionContext sessionContext;
 
     private final NamespaceHelper namespaceHelper;
-    private Stack<Node> parents;
+    private final Stack<Node> parents;
 
     /**
      * helper object that keeps track of remapped uuid's and imported reference
@@ -83,26 +80,20 @@ public class SessionImporter implements 
     /**
      * Currently active importer for protected nodes.
      */
-    private ProtectedNodeImporter pnImporter = null;
+    private ProtectedNodeImporter pnImporter;
 
     /**
-     * Creates a new <code>SessionImporter</code> instance.
+     * Creates a new {@code SessionImporter} instance.
      */
     public SessionImporter(Node importTargetNode,
-                           Root root,
-                           Session session,
-                           SessionDelegate dlg,
+                           SessionContext sessionContext,
                            NamespaceHelper helper,
-                           UserConfiguration userConfig,
-                           AccessControlConfiguration accessControlConfig,
-                           int uuidBehavior,
-                           SessionContext sessionContext) throws RepositoryException {
+                           int uuidBehavior) {
         this.importTargetNode = importTargetNode;
-        this.session = session;
-        this.root = root;
+        this.session = sessionContext.getSession();
+        this.root = sessionContext.getSessionDelegate().getRoot();
         this.namespaceHelper = helper;
         this.uuidBehavior = uuidBehavior;
-        this.sessionContext = sessionContext;
 
         refTracker = new ReferenceChangeTracker();
 
@@ -112,12 +103,14 @@ public class SessionImporter implements 
         pItemImporters.clear();
 
         //TODO clarify how to provide ProtectedItemImporters
+        UserConfiguration userConfig = sessionContext.getUserConfiguration();
         NamePathMapper namePathMapper = sessionContext.getNamePathMapper();
         for (ProtectedItemImporter importer : userConfig.getProtectedItemImporters()) {
             if (importer.init(session, root, namePathMapper, false, uuidBehavior, refTracker))
{
                 pItemImporters.add(importer);
             }
         }
+        AccessControlConfiguration accessControlConfig = sessionContext.getAccessControlConfiguration();
         for (ProtectedItemImporter importer : accessControlConfig.getProtectedItemImporters())
{
             if (importer.init(session, root, namePathMapper, false, uuidBehavior, refTracker))
{
                 pItemImporters.add(importer);
@@ -282,16 +275,12 @@ public class SessionImporter implements 
 
     //-------------------------------------------------------------< Importer >
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void start() throws RepositoryException {
         // nop
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void startNode(NodeInfo nodeInfo, List<PropInfo> propInfos)
             throws RepositoryException {
         Node parent = parents.peek();
@@ -474,9 +463,7 @@ public class SessionImporter implements 
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void endNode(NodeInfo nodeInfo) throws RepositoryException {
         Node parent = parents.pop();
         if (parent == null) {
@@ -493,9 +480,7 @@ public class SessionImporter implements 
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void end() throws RepositoryException {
         /**
          * adjust references that refer to uuid's which have been mapped to



Mime
View raw message