jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1334027 - in /jackrabbit/oak/trunk: oak-it/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/
Date Fri, 04 May 2012 15:19:10 GMT
Author: reschke
Date: Fri May  4 15:19:10 2012
New Revision: 1334027

URL: http://svn.apache.org/viewvc?rev=1334027&view=rev
Log:
OAK-66: add default values, update test exclusions (WIP)

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1334027&r1=1334026&r2=1334027&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Fri May  4 15:19:10 2012
@@ -97,8 +97,6 @@ org.apache.jackrabbit.test.api.SessionRe
 org.apache.jackrabbit.test.api.HasPermissionTest
 org.apache.jackrabbit.test.api.WorkspaceTest
 org.apache.jackrabbit.test.api.ShareableNodeTest
-org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testSimpleVersionable
-org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testChildNodeDef
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyDateTest#testConversions
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyMultipleTest#testReturnFalseBecauseIsProtected
 org.apache.jackrabbit.test.api.nodetype.CanSetPropertyMultipleTest#testReturnFalseBecauseIsNotMultiple

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1334027&r1=1334026&r2=1334027&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Fri May  4 15:19:10 2012
@@ -60,7 +60,7 @@ public class WorkspaceImpl implements Ja
 
         this.sessionDelegate = sessionDelegate;
         this.nsRegistry = nsRegistry;
-        this.nodeTypeManager = new NodeTypeManagerImpl(sessionDelegate.getNamePathMapper());
+        this.nodeTypeManager = new NodeTypeManagerImpl(sessionDelegate.getValueFactory(),
sessionDelegate.getNamePathMapper());
         this.queryManager = new QueryManagerImpl(this, sessionDelegate);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java?rev=1334027&r1=1334026&r2=1334027&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
Fri May  4 15:19:10 2012
@@ -46,6 +46,8 @@ import org.apache.jackrabbit.commons.cnd
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder;
 import org.apache.jackrabbit.commons.cnd.ParseException;
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 
 public class NodeTypeManagerImpl implements NodeTypeManager {
@@ -55,14 +57,14 @@ public class NodeTypeManagerImpl impleme
 
     private final Map<String, NodeType> typemap = new HashMap<String, NodeType>();
 
-    public NodeTypeManagerImpl(NameMapper mapper) throws RepositoryException {
+    public NodeTypeManagerImpl(ValueFactoryImpl vf, NameMapper mapper) throws RepositoryException
{
         this.mapper = mapper;
 
         try {
             InputStream stream = NodeTypeManagerImpl.class.getResourceAsStream("builtin_nodetypes.cnd");
             Reader reader = new InputStreamReader(stream, "UTF-8");
             try {
-                DefinitionBuilderFactory<NodeType, Map<String, String>> dbf =
new DefinitionBuilderFactoryImpl(this, mapper);
+                DefinitionBuilderFactory<NodeType, Map<String, String>> dbf =
new DefinitionBuilderFactoryImpl(this, vf, mapper);
                 CompactNodeTypeDefReader<NodeType, Map<String, String>> cndr
= new CompactNodeTypeDefReader<NodeType, Map<String, String>>(
                         reader, null, dbf);
 
@@ -181,27 +183,29 @@ public class NodeTypeManagerImpl impleme
         private Map<String, String> nsmap = new HashMap<String, String>();
 
         private final NodeTypeManager ntm;
+        private final ValueFactoryImpl vf;
         private final NameMapper mapper;
 
-        public DefinitionBuilderFactoryImpl(NodeTypeManager ntm, NameMapper mapper) {
+        public DefinitionBuilderFactoryImpl(NodeTypeManager ntm, ValueFactoryImpl vf, NameMapper
mapper) {
             this.ntm = ntm;
+            this.vf = vf;
             this.mapper = mapper;
         }
 
         @Override
         public Map<String, String> getNamespaceMapping() {
-            return this.nsmap;
+            return nsmap;
         }
 
         @Override
         public org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeTypeDefinitionBuilder<NodeType>
newNodeTypeDefinitionBuilder()
                 throws RepositoryException {
-            return new NodeTypeDefinitionBuilderImpl(this.ntm, this.mapper);
+            return new NodeTypeDefinitionBuilderImpl(ntm, vf, mapper);
         }
 
         @Override
         public void setNamespace(String prefix, String uri) throws RepositoryException {
-            this.nsmap.put(prefix, uri);
+            nsmap.put(prefix, uri);
         }
 
         @Override
@@ -216,13 +220,15 @@ public class NodeTypeManagerImpl impleme
         private List<NodeDefinitionBuilderImpl> childNodeDefinitions = new ArrayList<NodeDefinitionBuilderImpl>();
 
         private final NodeTypeManager ntm;
+        private final ValueFactoryImpl vf;
         private final NameMapper mapper;
 
         private String primaryItemName;
         private List<String> declaredSuperTypes = new ArrayList<String>();
 
-        public NodeTypeDefinitionBuilderImpl(NodeTypeManager ntm, NameMapper mapper) {
+        public NodeTypeDefinitionBuilderImpl(NodeTypeManager ntm, ValueFactoryImpl vf, NameMapper
mapper) {
             this.ntm = ntm;
+            this.vf = vf;
             this.mapper = mapper;
         }
 
@@ -253,7 +259,7 @@ public class NodeTypeManagerImpl impleme
                     .size()]), primaryItemName, isMixin, isAbstract, isOrderable);
 
             for (PropertyDefinitionBuilderImpl pdb : propertyDefinitions) {
-                result.addPropertyDefinition(pdb.getPropertyDefinition(result, mapper));
+                result.addPropertyDefinition(pdb.getPropertyDefinition(result, vf, mapper));
             }
 
             for (NodeDefinitionBuilderImpl ndb : childNodeDefinitions) {
@@ -322,9 +328,16 @@ public class NodeTypeManagerImpl impleme
             this.ndtb = ntdb;
         }
 
-        public PropertyDefinition getPropertyDefinition(NodeType nt, NameMapper mapper) {
-            return new PropertyDefinitionImpl(nt, mapper, name, autocreate, isMandatory,
onParent, isProtected, requiredType,
-                    isMultiple);
+        public PropertyDefinition getPropertyDefinition(NodeType nt, ValueFactoryImpl vf,
NameMapper mapper) {
+            
+            CoreValue[] defaultCoreValues = new CoreValue[defaultValues.size()];
+            
+            for (int i = 0; i < defaultCoreValues.length; i++) {
+                defaultCoreValues[i] = vf.getCoreValueFactory().createValue(defaultValues.get(i),
requiredType);
+            }
+            
+            return new PropertyDefinitionImpl(nt, mapper, vf, name, autocreate, isMandatory,
onParent, isProtected, requiredType,
+                    isMultiple, defaultCoreValues);
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java?rev=1334027&r1=1334026&r2=1334027&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java
Fri May  4 15:19:10 2012
@@ -20,23 +20,29 @@ import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
 
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.jcr.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 
 class PropertyDefinitionImpl
         extends ItemDefinitionImpl implements PropertyDefinition {
 
     private final int requiredType;
-
     private final boolean multiple;
+    private final CoreValue[] defaultCoreValues;
 
+    private final ValueFactoryImpl vfac;
+    
     public PropertyDefinitionImpl(
-            NodeType type, NameMapper mapper, String name, boolean autoCreated,
+            NodeType type, NameMapper mapper, ValueFactoryImpl vfac, String name, boolean
autoCreated,
             boolean mandatory, int onParentRevision, boolean isProtected,
-            int requiredType, boolean multiple) {
+            int requiredType, boolean multiple, CoreValue[] defaultCoreValues) {
         super(type, mapper, name, autoCreated,
                 mandatory, onParentRevision, isProtected);
+        this.vfac = vfac;
         this.requiredType = requiredType;
         this.multiple = multiple;
+        this.defaultCoreValues = defaultCoreValues;
     }
 
     @Override
@@ -51,7 +57,11 @@ class PropertyDefinitionImpl
 
     @Override
     public Value[] getDefaultValues() {
-        return new Value[0];
+        Value[] defaults = new Value[defaultCoreValues.length];
+        for (int i = 0; i < defaults.length; i++) {
+            defaults[i] = vfac.createValue(defaultCoreValues[i]);
+        }
+        return defaults;
     }
 
     @Override



Mime
View raw message