jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1364650 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java
Date Mon, 23 Jul 2012 14:37:56 GMT
Author: mduerig
Date: Mon Jul 23 14:37:55 2012
New Revision: 1364650

URL: http://svn.apache.org/viewvc?rev=1364650&view=rev
Log:
null check

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java?rev=1364650&r1=1364649&r2=1364650&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeUtil.java
Mon Jul 23 14:37:55 2012
@@ -24,17 +24,15 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
+import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Lists;
-
 /**
  * Utility class for accessing typed content of a node.
  */
@@ -121,8 +119,13 @@ class NodeUtil {
     }
 
     public void setName(String name, String value) {
+        String oakName = mapper.getOakName(value);
+        if (oakName == null) {
+            throw new IllegalArgumentException("Invalid name:" + name);
+        }
+
         tree.setProperty(name, factory.createValue(
-                mapper.getOakName(value), PropertyType.NAME));
+                oakName, PropertyType.NAME));
     }
 
     public String[] getNames(String name, String... defaultValues) {
@@ -139,8 +142,13 @@ class NodeUtil {
     public void setNames(String name, String... values) {
         List<CoreValue> cvs = new ArrayList<CoreValue>(values.length);
         for (String value : values) {
+            String oakName = mapper.getOakName(value);
+            if (oakName == null) {
+                throw new IllegalArgumentException("Invalid name:" + name);
+            }
+
             cvs.add(factory.createValue(
-                    mapper.getOakName(value), PropertyType.NAME));
+                    oakName, PropertyType.NAME));
         }
         tree.setProperty(name, cvs);
     }



Mime
View raw message