jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r520408 [3/3] - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ nodetype/ state/ xml/
Date Tue, 20 Mar 2007 14:35:58 GMT
Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?view=diff&rev=520408&r1=520407&r2=520408
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Tue Mar 20 07:35:56 2007
@@ -28,10 +28,7 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.ItemInfo;
-import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
-import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
+import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
@@ -60,13 +57,13 @@
 
     private final RepositoryService service;
     private final SessionInfo sessionInfo;
-    private final WorkspaceManager wspManager;
+    private final ItemDefinitionProvider definitionProvider;
 
     public WorkspaceItemStateFactory(RepositoryService service, SessionInfo sessionInfo,
-                                     WorkspaceManager wspManager) {
+                                     ItemDefinitionProvider definitionProvider) {
         this.service = service;
         this.sessionInfo = sessionInfo;
-        this.wspManager = wspManager;
+        this.definitionProvider = definitionProvider;
     }
 
     /**
@@ -244,29 +241,10 @@
         }
 
         // retrieve definition
-        NodeTypeRegistry ntReg = wspManager.getNodeTypeRegistry();
-        QNodeDefinition definition = null;
-        NodeEntry parent = entry.getParent();
-        if (parent == null) {
-            // special case for root state
-            definition = wspManager.getNodeTypeRegistry().getRootNodeDef();
-        } else if (parent.isAvailable() && parent.getStatus() == Status.EXISTING)
{
-            // try to retrieve definition if the parent is available
-            try {
-                NodeState parentState = parent.getNodeState();
-                EffectiveNodeType ent = ntReg.getEffectiveNodeType(parentState.getNodeTypeNames());
-                definition = ent.getApplicableNodeDefinition(info.getQName(), info.getNodetype(),
ntReg);
-            } catch (RepositoryException e) {
-                // should not get here
-                log.warn("Internal error", e.getMessage());
-            } catch (NodeTypeConflictException e) {
-                // should not get here
-               log.warn("Internal error", e.getMessage());
-            }
-        }
+        QNodeDefinition definition = definitionProvider.getQNodeDefinition(entry, info);
 
         // now build the nodestate itself
-        NodeState state = new NodeState(entry, info.getNodetype(), info.getMixins(), definition,
Status.EXISTING, true, this, ntReg);
+        NodeState state = new NodeState(entry, info.getNodetype(), info.getMixins(), definition,
Status.EXISTING, true, this, definitionProvider);
 
         // update NodeEntry from the information present in the NodeInfo (prop entries)
         List propNames = new ArrayList();
@@ -308,30 +286,10 @@
             parent.setUniqueID(uniqueID);
         }
 
-        QPropertyDefinition definition = null;
-        // try to retrieve property definition
-        NodeEntry parent = entry.getParent();
-        if (parent.isAvailable() && parent.getStatus() == Status.EXISTING) {
-            try {
-                NodeState parentState = parent.getNodeState();
-                EffectiveNodeType ent = wspManager.getNodeTypeRegistry().getEffectiveNodeType(parentState.getNodeTypeNames());
-                QPropertyDefinition defs[] = ent.getApplicablePropertyDefinitions(info.getQName(),
info.getType(), info.isMultiValued());
-                if (defs.length == 1) {
-                    definition = defs[0];
-                } else {
-                    definition = service.getPropertyDefinition(sessionInfo, entry.getId());
-                }
-            } catch (RepositoryException e) {
-                // should not get here
-                log.warn("Internal error", e.getMessage());
-            } catch (NodeTypeConflictException e) {
-                // should not get here
-                log.warn("Internal error", e.getMessage());
-            }
-        }
+        QPropertyDefinition definition = definitionProvider.getQPropertyDefinition(entry,
info);
 
         // build the PropertyState
-        PropertyState state = new PropertyState(entry, info.isMultiValued(), definition,
Status.EXISTING, true, this, wspManager.getNodeTypeRegistry());
+        PropertyState state = new PropertyState(entry, info.isMultiValued(), definition,
Status.EXISTING, true, this, definitionProvider);
         state.init(info.getType(), info.getValues());
 
         //state.addListener(cache);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?view=diff&rev=520408&r1=520407&r2=520408
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
Tue Mar 20 07:35:56 2007
@@ -31,6 +31,7 @@
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
+import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
 import org.apache.jackrabbit.jcr2spi.operation.AddNode;
 import org.apache.jackrabbit.jcr2spi.operation.Remove;
 import org.apache.jackrabbit.jcr2spi.operation.AddProperty;
@@ -184,16 +185,15 @@
                QNodeDefinition def = existing.getDefinition();
                if (!def.allowsSameNameSiblings()) {
                    // existing doesn't allow same-name siblings, check for conflicts
-                   EffectiveNodeType entExisting = session.getValidator().getEffectiveNodeType(existing);
-                   if (def.isProtected() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
-                   {
+                   EffectiveNodeTypeProvider provider = session.getEffectiveNodeTypeProvider();
+                   EffectiveNodeType entExisting = provider.getEffectiveNodeType(existing);
+                   if (def.isProtected() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
{
                        // skip protected node
                        parents.push(null); // push null onto stack for skipped node
                        log.debug("skipping protected node " + LogUtil.safeGetJCRPath(existing,
session.getNamespaceResolver()));
                        return;
                    }
-                   if (def.isAutoCreated() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
-                   {
+                   if (def.isAutoCreated() && entExisting.includesNodeType(nodeInfo.getNodeTypeName()))
{
                        // this node has already been auto-created, no need to create it
                        nodeState = existing;
                    } else {
@@ -430,14 +430,14 @@
                         // could be single- or multi-valued (n == 1)
                         try {
                             // try single-valued
-                            propDef = session.getValidator().getApplicablePropertyDefinition(newName,
conflicting.getType(), false, parent);
+                            propDef = session.getItemDefinitionProvider().getQPropertyDefinition(parent,
newName, conflicting.getType(), false);
                         } catch (ConstraintViolationException cve) {
                             // try multi-valued
-                            propDef = session.getValidator().getApplicablePropertyDefinition(newName,
conflicting.getType(), true, parent);
+                            propDef = session.getItemDefinitionProvider().getQPropertyDefinition(parent,
newName, conflicting.getType(), true);
                         }
                     } else {
                         // can only be multi-valued (n == 0 || n > 1)
-                        propDef = session.getValidator().getApplicablePropertyDefinition(newName,
conflicting.getType(), true, parent);
+                        propDef = session.getItemDefinitionProvider().getQPropertyDefinition(parent,
newName, conflicting.getType(), true);
                     }
 
                     Operation ap = AddProperty.create(parent, newName, conflicting.getType(),
propDef, conflicting.getValues());
@@ -452,7 +452,7 @@
         }
 
         // do create new nodeState
-        QNodeDefinition def = session.getValidator().getApplicableNodeDefinition(nodeInfo.getName(),
nodeInfo.getNodeTypeName(), parent);
+        QNodeDefinition def = session.getItemDefinitionProvider().getQNodeDefinition(parent,
nodeInfo.getName(), nodeInfo.getNodeTypeName());
         if (def.isProtected()) {
             log.debug("Skipping protected nodeState (" + nodeInfo.getName() + ")");
             return null;
@@ -527,10 +527,10 @@
            // there's no property with that name, find applicable definition
            if (tva.length == 1) {
                // could be single- or multi-valued (n == 1)
-               def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
parentState);
+               def = session.getItemDefinitionProvider().getQPropertyDefinition(parentState,
propName, infoType);
            } else {
                // can only be multi-valued (n == 0 || n > 1)
-               def = session.getValidator().getApplicablePropertyDefinition(propName, infoType,
true, parentState);
+               def = session.getItemDefinitionProvider().getQPropertyDefinition(parentState,
propName, infoType, true);
            }
            if (def.isProtected()) {
                // skip protected property
@@ -660,7 +660,7 @@
         }
         QName[] ntNames = (QName[]) l.toArray(new QName[l.size()]);
         try {
-            EffectiveNodeType ent = session.getValidator().getEffectiveNodeType(ntNames);
+            EffectiveNodeType ent = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(ntNames);
             if (!ent.includesNodeType(QName.MIX_REFERENCEABLE)) {
                 throw new ConstraintViolationException("XML defines jcr:uuid without defining
import node to be referenceable.");
             }



Mime
View raw message