jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1163162 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Date Tue, 30 Aug 2011 10:17:45 GMT
Author: thomasm
Date: Tue Aug 30 10:17:45 2011
New Revision: 1163162

URL: http://svn.apache.org/viewvc?rev=1163162&view=rev
Log:
Generate a real UUID if necessary.

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1163162&r1=1163161&r2=1163162&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Tue Aug 30 10:17:45 2011
@@ -78,6 +78,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.Callable;
@@ -170,7 +171,7 @@ public class RepositoryServiceImpl exten
             put(OPTION_QUERY_SQL_SUPPORTED, FALSE);
         }
         catch (RepositoryException e) {
-            throw new IllegalStateException(e); // should not happen 
+            throw new IllegalStateException(e); // should not happen
         }
     }};
 
@@ -249,7 +250,7 @@ public class RepositoryServiceImpl exten
         if (workspaceName == null) {
             workspaceName = defaultWorkspace;
         }
-        
+
         SessionInfo s = super.createSessionInfo(credentials, workspaceName);
         createSessionState(s);
         return s;
@@ -469,7 +470,7 @@ public class RepositoryServiceImpl exten
         if (RESERVED_NS.contains(uri)) {
             throw new NamespaceException("Cannot register reserved namespace: " + uri);
         }
-        
+
         namespaces.removeMapping(uri);
         nodeTypeStore.write(namespaces, nodeTypeDefs);
     }
@@ -493,7 +494,7 @@ public class RepositoryServiceImpl exten
     public Subscription createSubscription(SessionInfo sessionInfo, EventFilter[] filters)
throws RepositoryException {
         SubscriptionImpl subscription = new SubscriptionImpl(microKernel, sessionState(sessionInfo));
         subscription.setEventFilters(filters);
-        return subscription;    
+        return subscription;
     }
 
     @Override
@@ -504,7 +505,7 @@ public class RepositoryServiceImpl exten
     @Override
     public EventBundle[] getEvents(Subscription subscription, long timeout)
             throws RepositoryException, InterruptedException {
-        
+
         return subscription(subscription).getEvents(timeout);
     }
 
@@ -545,13 +546,14 @@ public class RepositoryServiceImpl exten
     private String createId(NodeId nodeId, Name childName) {
         int nodeHash = nodeId.hashCode();
         int childHash = childName == null ? 0 : childName.hashCode();
+        // this will result in a very short id, which is good,
+        // but it might not be unique
         String id = Integer.toHexString(nodeHash + childHash);
 
         String rev = microKernel.getHeadRevision();
-        // rehash while id is not unique
-        // TODO review this algorithm, it looks dangerous
         while (jcrUuidIndex.getPath(id, rev) != null) {
-            id = Integer.toHexString(id.hashCode());
+            // generate a 'real' random id while not unique
+            id = UUID.randomUUID().toString();
         }
 
         return id;
@@ -778,7 +780,7 @@ public class RepositoryServiceImpl exten
         private String target(NodeId nodeId) throws RepositoryException {
             String wspName = sessionInfo.getWorkspaceName();
             Path path = getPath(nodeId, wspName);
-            
+
             return JsonBuilder.quote(JsonBuilder.escape(
                     PathUtils.relativize("/", Paths.pathToString(wspName, path))));
         }



Mime
View raw message