jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r124087 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
Date Tue, 04 Jan 2005 10:34:15 GMT
Author: tripod
Date: Tue Jan  4 02:34:13 2005
New Revision: 124087

URL: http://svn.apache.org/viewcvs?view=rev&rev=124087
Log:
- adapting Node.isCheckedOut() behaviour to spec 0.16 (--> no exception if non-versionable)
Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&rev=124087&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java&r1=124086&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java&r2=124087
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java	Tue Jan 
4 02:34:13 2005
@@ -1088,7 +1088,7 @@
         NodeImpl parentNode = (NodeImpl) getParent();
 
         // check if versioning allows write
-        if (!parentNode.safeIsCheckedOut()) {
+        if (!parentNode.isCheckedOut(false)) {
             String msg = parentNode.safeGetJCRPath() + ": cannot remove a child of a checked-in
node";
             log.error(msg);
             throw new VersionException(msg);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&rev=124087&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java&r1=124086&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java&r2=124087
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java	Tue Jan 
4 02:34:13 2005
@@ -209,8 +209,8 @@
             log.error(msg);
             throw new RepositoryException(msg);
         }
-        // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        // check if versioning allows write (only cheep call)
+        if (!isCheckedOut(false)) {
             String msg = "Cannot set the value of a property of a checked-in node " + safeGetJCRPath()
+ "/" + name.toString();
             log.error(msg);
             throw new VersionException(msg);
@@ -524,8 +524,8 @@
             // no name collision
         }
 
-        // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        // check if versioning allows write (only cheep call)
+        if (!isCheckedOut(false)) {
             String msg = safeGetJCRPath() + ": cannot add a child to a checked-in node";
             log.error(msg);
             throw new VersionException(msg);
@@ -1201,8 +1201,8 @@
             throw new ItemNotFoundException(safeGetJCRPath() + " has no child node with name
" + destName);
         }
 
-        // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        // check if versioning allows write (only cheep call)
+        if (!isCheckedOut(false)) {
             String msg = safeGetJCRPath() + ": cannot change child node ordering of a checked-in
node";
             log.error(msg);
             throw new VersionException(msg);
@@ -1748,7 +1748,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        if (!isCheckedOut(true)) {
             String msg = safeGetJCRPath() + ": cannot add a mixin node type to a checked-in
node";
             log.error(msg);
             throw new ConstraintViolationException(msg);
@@ -1857,7 +1857,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        if (!isCheckedOut(true)) {
             String msg = safeGetJCRPath() + ": cannot remove a mixin node type from a checked-in
node";
             log.error(msg);
             throw new ConstraintViolationException(msg);
@@ -1974,7 +1974,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!safeIsCheckedOut()) {
+        if (!isCheckedOut(true)) {
             return false;
         }
 
@@ -2499,23 +2499,31 @@
     }
 
     /**
+     * Same as {@link javax.jcr.Node#isCheckedOut()} but if <code>inherit</code>
+     * is <code>true</code>, a non-versionable node will return the checked out
+     * state of its parent.
+     *
+     * @param inherit
+     *
      * @see Node#isCheckedOut()
      */
-    public boolean isCheckedOut()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
-        checkVersionable();
-        return getProperty(VersionManager.PROPNAME_IS_CHECKED_OUT).getBoolean();
+    public boolean isCheckedOut(boolean inherit) throws RepositoryException {
+        // search nearest ancestor that is versionable
+        NodeImpl node = this;
+        while (!node.hasProperty(VersionManager.PROPNAME_IS_CHECKED_OUT)) {
+            if (node.isRepositoryRoot() || !inherit) {
+                return true;
+            }
+            node = (NodeImpl) node.getParent();
+        }
+        return node.getProperty(VersionManager.PROPNAME_IS_CHECKED_OUT).getBoolean();
     }
 
     /**
-     * Same as {@link #isCheckedOut()} but without UnsupportedException.
+     * @see Node#isCheckedOut()
      */
-    public boolean safeIsCheckedOut() throws RepositoryException {
-        // what if this node is not versionable but has OPV==Copy?
-        // do we need to search ancestors for a verionable node?
-        return hasProperty(VersionManager.PROPNAME_IS_CHECKED_OUT)
-                ? getProperty(VersionManager.PROPNAME_IS_CHECKED_OUT).getBoolean()
-                : true;
+    public boolean isCheckedOut() throws RepositoryException {
+        return isCheckedOut(false);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&rev=124087&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java&r1=124086&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java&r2=124087
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java	(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java	Tue Jan
 4 02:34:13 2005
@@ -190,7 +190,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -243,7 +243,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -533,7 +533,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -578,7 +578,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -618,7 +618,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -669,7 +669,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -713,7 +713,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -764,7 +764,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -804,7 +804,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -856,7 +856,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 
@@ -896,7 +896,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             String msg = "Cannot alter the value of a property of a checked-in node " + safeGetJCRPath();
             log.error(msg);
             throw new VersionException(msg);
@@ -942,7 +942,7 @@
         sanityCheck();
 
         // check if versioning allows write
-        if (!((NodeImpl) getParent()).safeIsCheckedOut()) {
+        if (!((NodeImpl) getParent()).isCheckedOut(false)) { // only cheep call yet
             throw new VersionException("Cannot alter the value of a property of a checked-in
node " + safeGetJCRPath());
         }
 

Mime
View raw message