jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r515264 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
Date Tue, 06 Mar 2007 19:31:06 GMT
Author: jukka
Date: Tue Mar  6 11:31:05 2007
New Revision: 515264

URL: http://svn.apache.org/viewvc?view=rev&rev=515264
Log:
JCR-742: Implemented AbstractProperty.remove(). Added a warning about the use of getParent().

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java?view=diff&rev=515264&r1=515263&r2=515264
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractProperty.java
Tue Mar  6 11:31:05 2007
@@ -41,7 +41,6 @@
  *   <li>{@link Item#isNew()}</li>
  *   <li>{@link Item#isSame(Item)}</li>
  *   <li>{@link Item#refresh(boolean)}</li>
- *   <li>{@link Item#remove()}</li>
  *   <li>{@link Item#save()}</li>
  * </ul>
  * <p>
@@ -51,9 +50,16 @@
  *   <li>{@link Property#getValue()}</li>
  *   <li>{@link Property#getValues()}</li>
  * </ul>
+ * <p>
+ * <strong>NOTE:</strong> Many of the default method implementations in
+ * this base class rely on the parent node being accessible through the
+ * {@link Item#getParent()} call. It is possible (though unlikely) that
+ * access controls deny access to a containing node even though a property
+ * is accessible. In such cases the default method implementations in this
+ * class <em>will not work</em>.
  */
 public abstract class AbstractProperty extends AbstractItem
-        implements Property {
+        implements Item, Property {
 
     //----------------------------------------------------------------< Item >
 
@@ -97,6 +103,18 @@
         return false;
     }
 
+    /**
+     * Removes this property.
+     * <p>
+     * The default implementation calls {@link Node#setProperty(String, Value)}
+     * with a <code>null</code> value on the parent node.
+     *
+     * @throws RepositoryException if an error occurs
+     */
+    public void remove() throws RepositoryException {
+        getParent().setProperty(getName(), (Value) null);
+    }
+
     //------------------------------------------------------------< Property >
 
     /**
@@ -199,12 +217,12 @@
      */
     public Node getNode() throws RepositoryException {
         Session session = getSession();
-        String uuid = getString();
-        if (getType() != PropertyType.REFERENCE) {
-            uuid = session.getValueFactory().createValue(
-                    uuid, PropertyType.REFERENCE).getString();
+        Value value = getValue();
+        if (value.getType() != PropertyType.REFERENCE) {
+            value = session.getValueFactory().createValue(
+                    value.getString(), PropertyType.REFERENCE);
         }
-        return session.getNodeByUUID(uuid);
+        return session.getNodeByUUID(value.getString());
     }
 
     /**



Mime
View raw message