jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r706419 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ ja...
Date Mon, 20 Oct 2008 21:30:12 GMT
Author: jukka
Date: Mon Oct 20 14:30:12 2008
New Revision: 706419

URL: http://svn.apache.org/viewvc?rev=706419&view=rev
Log:
1.5: Merged revisions 706242 and 706273 (JCR-1248 and JCR-1821)

Added:
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/IsSameTest.java
      - copied unchanged from r706273, jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/IsSameTest.java
Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AccessControlPolicyIteratorAdapter.java
  (props changed)
    jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 20 14:30:12 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273

Propchange: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AccessControlPolicyIteratorAdapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 20 14:30:12 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/commons/iterator/AccessControlPolicyIteratorAdapter.java:631261
-/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AccessControlPolicyIteratorAdapter.java:705938,705961
+/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/AccessControlPolicyIteratorAdapter.java:705938,705961,706242,706273

Modified: jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java?rev=706419&r1=706418&r2=706419&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
Mon Oct 20 14:30:12 2008
@@ -477,7 +477,28 @@
         }
         return buffer.toString();
     }
-
+    
+    /** Escapes all illegal XPath search characters of a string.
+    * <p>Example:<br>
+    * A search string like 'test?' will run into a ParseException
+    * documented in http://issues.apache.org/jira/browse/JCR-1248
+    * 
+    * @param string the string to encode
+    * @return the escaped string    
+    */
+   public static String escapeIllegalXpathSearchChars(String s) {
+       StringBuffer sb = new StringBuffer();
+       sb.append(s.substring(0, (s.length() - 1)));
+       char c = s.charAt(s.length() - 1);
+       // NOTE: keep this in sync with _ESCAPED_CHAR below!
+       if (c == '!' || c == '(' || c == ':' || c == '^' 
+           || c == '[' || c == ']' || c == '\"' || c == '{' 
+           || c == '}' || c == '?') {
+           sb.append('\\');
+       }
+       sb.append(c);
+       return sb.toString();
+   }
     /**
      * Unescapes previously escaped jcr chars.
      * <p/>

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=706419&r1=706418&r2=706419&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Mon Oct 20 14:30:12 2008
@@ -26,6 +26,7 @@
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
@@ -183,11 +184,17 @@
         if (this == otherItem) {
             return true;
         }
+        if (isNode() != otherItem.isNode()) {
+            return false;
+        }
         if (otherItem instanceof ItemImpl) {
             ItemImpl other = (ItemImpl) otherItem;
             if (this.state == other.state) {
                 return true;
             }
+            // check status of the other item.
+            other.checkStatus();
+
             // 2 items may only be the same if the were accessed from Sessions
             // bound to the same workspace
             String otherWspName = other.session.getWorkspace().getName();
@@ -195,6 +202,10 @@
                 // in addition they must provide the same id irrespective of
                 // any transient modifications.
                 if (state.getStatus() != Status.NEW && other.state.getStatus() !=
Status.NEW ) {
+                    // if any ancestor is _invalidated_ force it's reload in
+                    // order to detect id changes.
+                    updateId(state);
+                    updateId(other.state);
                     return state.getWorkspaceId().equals(other.state.getWorkspaceId());
                 }
                 /* else:
@@ -205,7 +216,7 @@
                 - either of the two items does not have a workspace state.
                   therefore the items cannot be the same, since one has been
                   transiently added in one but not the other session.
-                  */
+                */
             }
         }
         return false;
@@ -531,4 +542,22 @@
     String safeGetJCRPath() {
         return LogUtil.safeGetJCRPath(getItemState(), session.getPathResolver());
     }
+
+    /**
+     *
+     * @param state
+     * @throws RepositoryException
+     */
+    private static void updateId(ItemState state) throws RepositoryException {
+        HierarchyEntry he = state.getHierarchyEntry();
+        while (he.getStatus() != Status.INVALIDATED) {
+            he = he.getParent();
+            if (he == null) {
+                // root reached without intermediate invalidated entry
+                return;
+            }
+        }
+        // he is INVALIDATED -> force reloading in order to be aware of id changes
+        he.getItemState();
+    }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=706419&r1=706418&r2=706419&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Mon Oct 20 14:30:12 2008
@@ -94,6 +94,7 @@
         suite.addTestSuite(HierarchyNodeTest.class);
         suite.addTestSuite(LazyItemIteratorTest.class);
         suite.addTestSuite(ExternalModificationTest.class);
+        suite.addTestSuite(IsSameTest.class);
 
         return suite;
     }



Mime
View raw message