jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1359714 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype: NodeTypeManagerDelegate.java NodeTypeManagerImpl.java PropertyDefinitionDelegate.java PropertyDefinitionImpl.java
Date Tue, 10 Jul 2012 14:56:20 GMT
Author: reschke
Date: Tue Jul 10 14:56:20 2012
New Revision: 1359714

URL: http://svn.apache.org/viewvc?rev=1359714&view=rev
Log:
OAK-66: untangle CoreValueFactory from NodeTypeManagerDelegate

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.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/PropertyDefinitionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java?rev=1359714&r1=1359713&r2=1359714&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerDelegate.java
Tue Jul 10 14:56:20 2012
@@ -34,12 +34,9 @@ import org.apache.jackrabbit.commons.cnd
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeTypeDefinitionBuilder;
 import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder;
 import org.apache.jackrabbit.commons.cnd.ParseException;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.CoreValueFactory;
 
 public class NodeTypeManagerDelegate {
 
-    private final CoreValueFactory cvf;
     private final List<NodeTypeDelegate> typeDelegates;
 
     private static final Map<String, String> nsdefaults;
@@ -53,9 +50,7 @@ public class NodeTypeManagerDelegate {
         nsdefaults = Collections.unmodifiableMap(tmp);
     }
 
-    public NodeTypeManagerDelegate(CoreValueFactory cvf) throws RepositoryException {
-        this.cvf = cvf;
-
+    public NodeTypeManagerDelegate() throws RepositoryException {
         try {
             InputStream stream = NodeTypeManagerImpl.class.getResourceAsStream("builtin_nodetypes.cnd");
             Reader reader = new InputStreamReader(stream, "UTF-8");
@@ -245,17 +240,10 @@ public class NodeTypeManagerDelegate {
 
         public PropertyDefinitionDelegate getPropertyDefinitionDelegate() throws RepositoryException
{
 
-            CoreValue[] defaultCoreValues = new CoreValue[defaultValues.size()];
-
-            for (int i = 0; i < defaultCoreValues.length; i++) {
-                // TODO: need name mapping?
-                defaultCoreValues[i] = cvf.createValue(defaultValues.get(i), requiredType);
-            }
-
             name = ndtb.convertNameToOak(name);
 
             return new PropertyDefinitionDelegate(name, autocreate, isMandatory, onParent,
isProtected, requiredType, isMultiple,
-                    defaultCoreValues);
+                    defaultValues);
         }
 
         @Override

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=1359714&r1=1359713&r2=1359714&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
Tue Jul 10 14:56:20 2012
@@ -49,7 +49,7 @@ public class NodeTypeManagerImpl impleme
     public NodeTypeManagerImpl(SessionDelegate sd) throws RepositoryException {
         this.vf = sd.getValueFactory();
         this.mapper = sd.getNamePathMapper();
-        this.ntmd = new NodeTypeManagerDelegate(sd.getValueFactory().getCoreValueFactory());
+        this.ntmd = new NodeTypeManagerDelegate();
     }
 
     private void init() {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java?rev=1359714&r1=1359713&r2=1359714&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/PropertyDefinitionDelegate.java
Tue Jul 10 14:56:20 2012
@@ -16,24 +16,24 @@
  */
 package org.apache.jackrabbit.oak.jcr.nodetype;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
+import java.util.List;
 
 public class PropertyDefinitionDelegate extends ItemDefinitionDelegate {
 
     private final int requiredType;
     private final boolean multiple;
-    private final CoreValue[] defaultCoreValues;
+    private final List<String> defaultValues;
 
     protected PropertyDefinitionDelegate(String name, boolean autoCreated, boolean mandatory,
int onParentVersion,
-            boolean isProtected, int requiredType, boolean multiple, CoreValue[] defaultCoreValues)
{
+            boolean isProtected, int requiredType, boolean multiple, List<String> defaultValues)
{
         super(name, autoCreated, mandatory, onParentVersion, isProtected);
         this.requiredType = requiredType;
         this.multiple = multiple;
-        this.defaultCoreValues = defaultCoreValues;
+        this.defaultValues = defaultValues;
     }
 
-    public CoreValue[] getDefaultCoreValues() {
-        return defaultCoreValues;
+    public List<String> getDefaultValues() {
+        return defaultValues;
     }
 
     public int getRequiredType() {

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=1359714&r1=1359713&r2=1359714&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
Tue Jul 10 14:56:20 2012
@@ -16,13 +16,17 @@
  */
 package org.apache.jackrabbit.oak.jcr.nodetype;
 
+import java.util.List;
+
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition {
 
@@ -30,6 +34,8 @@ class PropertyDefinitionImpl extends Ite
 
     private final ValueFactoryImpl vfac;
 
+    private static final Logger log = LoggerFactory.getLogger(PropertyDefinitionImpl.class);
+
     public PropertyDefinitionImpl(NodeType type, NameMapper mapper, ValueFactoryImpl vfac,
PropertyDefinitionDelegate delegate) {
         super(type, mapper, delegate);
         this.vfac = vfac;
@@ -48,10 +54,15 @@ class PropertyDefinitionImpl extends Ite
 
     @Override
     public Value[] getDefaultValues() {
-        CoreValue[] defaults = dlg.getDefaultCoreValues();
-        Value[] result = new Value[defaults.length];
-        for (int i = 0; i < defaults.length; i++) {
-            result[i] = vfac.createValue(defaults[i]);
+        List<String> defaults = dlg.getDefaultValues();
+        Value[] result = new Value[defaults.size()];
+        for (int i = 0; i < defaults.size(); i++) {
+            try {
+                result[i] = vfac.createValue(defaults.get(i), dlg.getRequiredType());
+            } catch (ValueFormatException e) {
+                log.error("Converting value " + defaults.get(i), e);
+                return null;
+            }
         }
         return result;
     }



Mime
View raw message