jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r953623 - in /jackrabbit/branches/1.6/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ItemManager.java test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
Date Fri, 11 Jun 2010 09:35:53 GMT
Author: ckoell
Date: Fri Jun 11 09:35:52 2010
New Revision: 953623

URL: http://svn.apache.org/viewvc?rev=953623&view=rev
Log:
JCR-2652 Can no longer set a Date property using a Long value

Modified:
    jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/branches/1.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java

Modified: jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=953623&r1=953622&r2=953623&view=diff
==============================================================================
--- jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Fri Jun 11 09:35:52 2010
@@ -19,18 +19,15 @@ package org.apache.jackrabbit.core;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.core.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.NodeDefinitionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateListener;
-import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
@@ -53,8 +50,6 @@ import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.nodetype.PropertyDefinition;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -222,7 +217,7 @@ public class ItemManager implements Dump
         try {
             NodeImpl parent = (NodeImpl) getItem(state.getParentId());
             return parent.getApplicablePropertyDefinition(
-                    state.getName(), state.getType(), state.isMultiValued(), true);
+                    state.getName(), state.getType(), state.isMultiValued(), false);
         } catch (ItemNotFoundException e) {
             // parent probably removed, get it from attic
         }

Modified: jackrabbit/branches/1.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java?rev=953623&r1=953622&r2=953623&view=diff
==============================================================================
--- jackrabbit/branches/1.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
(original)
+++ jackrabbit/branches/1.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
Fri Jun 11 09:35:52 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
@@ -26,6 +27,8 @@ import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.ConstraintViolationException;
 
 public class NodeTypeTest extends AbstractJCRTest {
 
@@ -67,5 +70,26 @@ public class NodeTypeTest extends Abstra
         assertEquals(PropertyType.BINARY, value.getType());
         assertEquals(def, value.getString());
     }
+    
+    /**
+     * Tests if it is possible to set a Long Value to a Date property
+     * @see JCR-2652
+     */
+	public void testSetNonExactTypedPropertyValue() throws RepositoryException {
+		Node node = testRootNode.addNode("foo", JcrConstants.NT_RESOURCE);
+		ValueFactory vf = superuser.getValueFactory();
+		Value value = vf.createValue("1234", 3);
+		// Attempt to use the LongValue to set a Date property
+		try {
+			node.setProperty(JcrConstants.JCR_LASTMODIFIED, value);
+			// Mandatory Properties will be set for JcrConstants.NT_RESOURCE
+			node.setProperty(JcrConstants.JCR_DATA, "value");
+			node.setProperty(JcrConstants.JCR_MIMETYPE, "text/plain");
+		} catch (ConstraintViolationException e) {
+            fail("No ConstraintViolation should happen if a LongValue is set to a Date property");
+		}
+		superuser.save();
+		assertNotNull(node.getProperty(JcrConstants.JCR_LASTMODIFIED));
+	}
 
 }



Mime
View raw message