jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1147193 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: NodeImpl.java StaleProperty.java
Date Fri, 15 Jul 2011 15:34:30 GMT
Author: mduerig
Date: Fri Jul 15 15:34:30 2011
New Revision: 1147193

URL: http://svn.apache.org/viewvc?rev=1147193&view=rev
Log:
JCR-3024: [SPI] Node.setProperty with null value throws ItemNotFoundException

Added:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/StaleProperty.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=1147193&r1=1147192&r2=1147193&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Fri Jul 15 15:34:30 2011
@@ -16,43 +16,7 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Binary;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.Item;
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.ItemVisitor;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeDefinition;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionException;
-import javax.jcr.version.VersionHistory;
-
+import org.apache.jackrabbit.commons.AbstractProperty;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.lock.LockStateManager;
@@ -87,6 +51,45 @@ import org.apache.jackrabbit.value.Value
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Binary;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.ItemVisitor;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * <code>NodeImpl</code>...
  */
@@ -247,8 +250,7 @@ public class NodeImpl extends ItemImpl i
             prop.setValue(v);
         } else {
             if (value == null) {
-                // create and remove property is not valid // TODO: correct?
-                throw new ItemNotFoundException("Cannot remove a non-existing property.");
+                return new StaleProperty();
             } else {
                 // new property to be added
                 prop = createProperty(propName, value, type);

Added: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/StaleProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/StaleProperty.java?rev=1147193&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/StaleProperty.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/StaleProperty.java
Fri Jul 15 15:34:30 2011
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.jcr2spi;
+
+import org.apache.jackrabbit.commons.AbstractProperty;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Binary;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.VersionException;
+import java.math.BigDecimal;
+
+/**
+ * This implementation of {@link Property} throws an {@link InvalidItemStateException} on
+ * all method calls.
+ */
+public class StaleProperty extends AbstractProperty {
+    public void setValue(Binary value) throws ValueFormatException, VersionException, LockException,
ConstraintViolationException, RepositoryException {
+        throw createIISE();
+    }
+
+    public void setValue(BigDecimal value) throws ValueFormatException, VersionException,
LockException, ConstraintViolationException, RepositoryException {
+        throw createIISE();
+    }
+
+    public Value getValue() throws ValueFormatException, RepositoryException {
+        throw createIISE();
+    }
+
+    public Value[] getValues() throws ValueFormatException, RepositoryException {
+        throw createIISE();
+    }
+
+    public Binary getBinary() throws ValueFormatException, RepositoryException {
+        throw createIISE();
+    }
+
+    public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
+        throw createIISE();
+    }
+
+    public PropertyDefinition getDefinition() throws RepositoryException {
+        throw createIISE();
+    }
+
+    public boolean isMultiple() throws RepositoryException {
+        throw createIISE();
+    }
+
+    public String getName() throws RepositoryException {
+        throw createIISE();
+    }
+
+    public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
{
+        throw createIISE();
+    }
+
+    public Session getSession() throws RepositoryException {
+        throw createIISE();
+    }
+
+    public boolean isNew() {
+        return false;
+    }
+
+    public boolean isModified() {
+        return false;
+    }
+
+    public boolean isSame(Item otherItem) throws RepositoryException {
+        throw createIISE();
+    }
+
+    public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException,
InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException,
NoSuchNodeTypeException, RepositoryException {
+        throw createIISE();
+    }
+
+    public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException
{
+        throw createIISE();
+    }
+
+    private InvalidItemStateException createIISE() {
+        return new InvalidItemStateException("property does not exist anymore");
+    }
+}



Mime
View raw message