Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 1357 invoked from network); 16 Feb 2006 10:49:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Feb 2006 10:49:43 -0000 Received: (qmail 8551 invoked by uid 500); 16 Feb 2006 10:49:41 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 8478 invoked by uid 500); 16 Feb 2006 10:49:40 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 8469 invoked by uid 99); 16 Feb 2006 10:49:40 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2006 02:49:40 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 16 Feb 2006 02:49:33 -0800 Received: (qmail 1034 invoked by uid 65534); 16 Feb 2006 10:49:12 -0000 Message-ID: <20060216104912.1030.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r378221 [3/7] - in /incubator/jackrabbit/trunk: contrib/ contrib/bdb-persistence/ contrib/bdb-persistence/src/java/org/apache/jackrabbit/core/state/bdb/ contrib/jca/ contrib/jcr-server/ contrib/jcrtaglib/ contrib/nt-ns-util/ contrib/orm-per... Date: Thu, 16 Feb 2006 10:48:29 -0000 To: jackrabbit-cvs@incubator.apache.org From: tripod@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAItemManager.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAItemManager.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAItemManager.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XAItemManager.java Thu Feb 16 02:48:20 2006 @@ -18,19 +18,14 @@ import org.apache.jackrabbit.core.state.ItemStateManager; import org.apache.jackrabbit.core.state.NodeState; -import org.apache.jackrabbit.core.state.ItemState; -import org.apache.jackrabbit.core.state.ItemStateException; -import org.apache.jackrabbit.core.version.InternalVersion; import org.apache.jackrabbit.core.version.AbstractVersion; -import org.apache.jackrabbit.core.version.XAVersion; import org.apache.jackrabbit.core.version.AbstractVersionHistory; +import org.apache.jackrabbit.core.version.InternalVersion; import org.apache.jackrabbit.core.version.InternalVersionHistory; +import org.apache.jackrabbit.core.version.XAVersion; import org.apache.jackrabbit.core.version.XAVersionHistory; -import org.apache.jackrabbit.core.version.XAVersionManager; -import org.apache.log4j.Logger; import javax.jcr.RepositoryException; -import javax.jcr.ItemNotFoundException; import javax.jcr.nodetype.NodeDefinition; /** @@ -39,23 +34,18 @@ public class XAItemManager extends ItemManager { /** - * Logger instance. - */ - private static Logger log = Logger.getLogger(XAItemManager.class); - - /** * Create a new instance of this class. * @param itemStateProvider the item state provider associated with * the new instance * @param session the session associated with the new instance * @param rootNodeDef the definition of the root node - * @param rootNodeUUID the UUID of the root node + * @param rootNodeId the id of the root node */ protected XAItemManager(ItemStateManager itemStateProvider, HierarchyManager hierMgr, SessionImpl session, NodeDefinition rootNodeDef, - String rootNodeUUID) { + NodeId rootNodeId) { - super(itemStateProvider, hierMgr, session, rootNodeDef, rootNodeUUID); + super(itemStateProvider, hierMgr, session, rootNodeDef, rootNodeId); } /** @@ -66,7 +56,7 @@ ItemLifeCycleListener[] listeners) throws RepositoryException { InternalVersion version = - session.getVersionManager().getVersion(id.getUUID()); + session.getVersionManager().getVersion(id); return new XAVersion(this, session, id, state, def, listeners, version); } @@ -78,7 +68,7 @@ ItemLifeCycleListener[] listeners) throws RepositoryException { InternalVersionHistory history = - session.getVersionManager().getVersionHistory(id.getUUID()); + session.getVersionManager().getVersionHistory(id); return new XAVersionHistory(this, session, id, state, def, listeners, history); } } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java Thu Feb 16 02:48:20 2006 @@ -158,7 +158,7 @@ protected ItemManager createItemManager(SessionItemStateManager itemStateMgr, HierarchyManager hierMgr) { return new XAItemManager(itemStateMgr, hierMgr, this, - ntMgr.getRootNodeDefinition(), rep.getRootNodeUUID()); + ntMgr.getRootNodeDefinition(), rep.getRootNodeId()); } /** Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java Thu Feb 16 02:48:20 2006 @@ -23,7 +23,6 @@ import org.apache.jackrabbit.core.state.NodeState; import org.apache.jackrabbit.name.NamespaceResolver; import org.apache.jackrabbit.name.QName; -import org.apache.log4j.Logger; import java.util.Iterator; @@ -36,15 +35,16 @@ */ public class ZombieHierarchyManager extends HierarchyManagerImpl { - private static Logger log = Logger.getLogger(ZombieHierarchyManager.class); - + /** + * the attic + */ protected ItemStateManager attic; - public ZombieHierarchyManager(String rootNodeUUID, + public ZombieHierarchyManager(NodeId rootNodeId, ItemStateManager provider, ItemStateManager attic, NamespaceResolver nsResolver) { - super(rootNodeUUID, provider, nsResolver); + super(rootNodeId, provider, nsResolver); this.attic = attic; } @@ -83,13 +83,13 @@ *

* Also allows for removed items. */ - protected String getParentUUID(ItemState state) { + protected NodeId getParentId(ItemState state) { if (state.hasOverlayedState()) { // use 'old' parent in case item has been removed - return state.getOverlayedState().getParentUUID(); + return state.getOverlayedState().getParentId(); } // delegate to base class - return super.getParentUUID(state); + return super.getParentId(state); } /** @@ -121,18 +121,18 @@ * Also allows for removed child node entries. */ protected NodeState.ChildNodeEntry getChildNodeEntry(NodeState parent, - String uuid) { + NodeId id) { // check removed child node entries first Iterator iter = parent.getRemovedChildNodeEntries().iterator(); while (iter.hasNext()) { NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) iter.next(); - if (entry.getUUID().equals(uuid)) { + if (entry.getId().equals(id)) { return entry; } } // no matching removed child node entry found in parent, // delegate to base class - return super.getChildNodeEntry(parent, uuid); + return super.getChildNodeEntry(parent, id); } } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/AbstractLockInfo.java Thu Feb 16 02:48:20 2006 @@ -17,6 +17,7 @@ package org.apache.jackrabbit.core.lock; import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.NodeId; import javax.jcr.Session; @@ -80,11 +81,11 @@ } /** - * Return the UUID of the lock holding node - * @return uuid + * Return the ID of the lock holding node + * @return the id */ - public String getUUID() { - return lockToken.uuid; + public NodeId getId() { + return lockToken.id; } /** Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Thu Feb 16 02:48:20 2006 @@ -16,8 +16,14 @@ */ package org.apache.jackrabbit.core.lock; +import EDU.oswego.cs.dl.util.concurrent.ReentrantLock; import org.apache.commons.collections.map.LinkedMap; -import org.apache.jackrabbit.core.*; +import org.apache.jackrabbit.core.ItemId; +import org.apache.jackrabbit.core.NodeId; +import org.apache.jackrabbit.core.NodeImpl; +import org.apache.jackrabbit.core.PathMap; +import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.SessionListener; import org.apache.jackrabbit.core.fs.FileSystem; import org.apache.jackrabbit.core.fs.FileSystemException; import org.apache.jackrabbit.core.fs.FileSystemResource; @@ -29,11 +35,11 @@ import org.apache.jackrabbit.name.QName; import org.apache.log4j.Logger; +import javax.jcr.ItemNotFoundException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; import javax.jcr.Session; -import javax.jcr.ItemNotFoundException; import javax.jcr.lock.Lock; import javax.jcr.lock.LockException; import javax.jcr.observation.Event; @@ -46,8 +52,6 @@ import java.util.ArrayList; import java.util.Iterator; -import EDU.oswego.cs.dl.util.concurrent.ReentrantLock; - /** * Provides the functionality needed for locking and unlocking nodes. @@ -165,10 +169,8 @@ */ private void reapplyLock(LockToken lockToken) { try { - NodeId id = new NodeId(lockToken.uuid); - - NodeImpl node = (NodeImpl) session.getItemManager().getItem(id); - Path path = getPath(node.getId()); + NodeImpl node = (NodeImpl) session.getItemManager().getItem(lockToken.id); + Path path = getPath(lockToken.id); LockInfo info = new LockInfo(lockToken, false, node.getProperty(QName.JCR_LOCKISDEEP).getBoolean(), @@ -245,7 +247,7 @@ throws LockException, RepositoryException { SessionImpl session = (SessionImpl) node.getSession(); - LockInfo info = new LockInfo(new LockToken(node.internalGetUUID()), + LockInfo info = new LockInfo(new LockToken(node.getNodeId()), isSessionScoped, isDeep, session.getUserID()); acquire(); @@ -332,11 +334,11 @@ * @return lock info or null if node is not locked * @throws RepositoryException if an error occurs */ - public AbstractLockInfo getLockInfo(String uuid) throws RepositoryException { + public AbstractLockInfo getLockInfo(NodeId id) throws RepositoryException { acquire(); try { - Path path = getPath(new NodeId(uuid)); + Path path = getPath(id); PathMap.Element element = lockMap.map(path, false); AbstractLockInfo info = (AbstractLockInfo) element.get(); @@ -383,8 +385,7 @@ throw new LockException("Node not locked: " + node.safeGetJCRPath()); } if (element.hasPath(path) || info.deep) { - Node lockHolder = (Node) session.getItemManager().getItem( - new NodeId(info.getUUID())); + Node lockHolder = (Node) session.getItemManager().getItem(info.getId()); return new LockImpl(info, lockHolder); } else { throw new LockException("Node not locked: " + node.safeGetJCRPath()); @@ -489,7 +490,7 @@ LockToken lockToken = LockToken.parse(lt); NodeImpl node = (NodeImpl) this.session.getItemManager(). - getItem(new NodeId(lockToken.uuid)); + getItem(lockToken.id); PathMap.Element element = lockMap.map(node.getPrimaryPath(), true); if (element != null) { AbstractLockInfo info = (AbstractLockInfo) element.get(); @@ -518,7 +519,7 @@ LockToken lockToken = LockToken.parse(lt); NodeImpl node = (NodeImpl) this.session.getItemManager(). - getItem(new NodeId(lockToken.uuid)); + getItem(lockToken.id); PathMap.Element element = lockMap.map(node.getPrimaryPath(), true); if (element != null) { AbstractLockInfo info = (AbstractLockInfo) element.get(); @@ -555,7 +556,9 @@ try { lockMapLock.acquire(); break; - } catch (InterruptedException e) {} + } catch (InterruptedException e) { + // ignore + } } } @@ -601,9 +604,9 @@ private class HierarchyEvent { /** - * UUID recorded in event + * ID recorded in event */ - public final String uuid; + public final NodeId id; /** * Path recorded in event @@ -629,12 +632,12 @@ /** * Create a new instance of this class. * - * @param uuid uuid + * @param id id * @param path path * @param type event type */ - public HierarchyEvent(String uuid, Path path, int type) { - this.uuid = uuid; + public HierarchyEvent(NodeId id, Path path, int type) { + this.id = id; this.path = path; this.type = type; } @@ -719,7 +722,7 @@ HierarchyEvent he; try { - he = new HierarchyEvent(event.getChildUUID(), + he = new HierarchyEvent(event.getChildId(), Path.create(event.getPath(), nsResolver, true), event.getType()); } catch (MalformedPathException e) { @@ -730,11 +733,11 @@ continue; } - HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.uuid); + HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.id); if (heExisting != null) { heExisting.merge(he); } else { - eventMap.put(he.uuid, he); + eventMap.put(he.id, he); } } return eventMap.values().iterator(); @@ -764,8 +767,8 @@ for (int i = 0; i < infos.size(); i++) { LockInfo info = (LockInfo) infos.get(i); try { - NodeImpl node = (NodeImpl) session.getItemManager().getItem( - new NodeId(info.getUUID())); + NodeImpl node = (NodeImpl) session.getItemManager(). + getItem(info.getId()); lockMap.put(node.getPrimaryPath(), info); } catch (RepositoryException e) { info.setLive(false); @@ -798,7 +801,6 @@ } } catch (PathNotFoundException e) { log.warn("Unable to determine path of added node's parent.", e); - return; } finally { release(); } @@ -821,7 +823,6 @@ } } catch (PathNotFoundException e) { log.warn("Unable to determine path of moved node's parent.", e); - return; } finally { release(); } @@ -843,7 +844,6 @@ } } catch (PathNotFoundException e) { log.warn("Unable to determine path of removed node's parent.", e); - return; } finally { release(); } @@ -886,8 +886,7 @@ setLockHolder(session); } try { - NodeImpl node = (NodeImpl) session.getItemManager().getItem( - new NodeId(getUUID())); + NodeImpl node = (NodeImpl) session.getItemManager().getItem(getId()); node.unlock(); } catch (RepositoryException e) { log.warn("Unable to unlock session-scoped lock on node '" Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockToken.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockToken.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockToken.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/LockToken.java Thu Feb 16 02:48:20 2006 @@ -16,23 +16,25 @@ */ package org.apache.jackrabbit.core.lock; +import org.apache.jackrabbit.core.NodeId; + /** * Lock token */ class LockToken { /** - * UUID of node holding lock + * ID of node holding lock */ - public final String uuid; + public final NodeId id; /** * Create a new instance of this class. Used when creating new locks upon * a request. - * @param uuid uuid + * @param id the id. */ - public LockToken(String uuid) { - this.uuid = uuid; + public LockToken(NodeId id) { + this.id = id; } /** @@ -51,7 +53,7 @@ if (getCheckDigit(uuid) != s.charAt(s.length() - 1)) { throw new IllegalArgumentException("Bad check digit."); } - return new LockToken(uuid); + return new LockToken(NodeId.valueOf(uuid)); } /** @@ -61,9 +63,9 @@ */ public String toString() { StringBuffer buf = new StringBuffer(); - buf.append(uuid); + buf.append(id.toString()); buf.append('-'); - buf.append(getCheckDigit(uuid)); + buf.append(getCheckDigit(id.toString())); return buf.toString(); } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XAEnvironment.java Thu Feb 16 02:48:20 2006 @@ -3,6 +3,7 @@ import org.apache.jackrabbit.core.TransactionException; import org.apache.jackrabbit.core.NodeImpl; import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.NodeId; import org.apache.log4j.Logger; import javax.jcr.RepositoryException; @@ -90,17 +91,16 @@ public AbstractLockInfo lock(NodeImpl node, boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException { - String uuid = node.internalGetUUID(); + NodeId id = node.getNodeId(); // check negative set first - LockInfo info = (LockInfo) unlockedNodesMap.get(uuid); + LockInfo info = (LockInfo) unlockedNodesMap.get(id); if (info != null) { - // if settings are compatible, this is effectively a no-op if (info.deep == isDeep && info.sessionScoped == isSessionScoped) { - unlockedNodesMap.remove(uuid); + unlockedNodesMap.remove(id); operations.remove(info); - return lockMgr.getLockInfo(uuid); + return lockMgr.getLockInfo(id); } } @@ -110,13 +110,13 @@ } // create a new lock info for this node - info = new LockInfo(node, new LockToken(node.internalGetUUID()), + info = new LockInfo(node, new LockToken(id), isSessionScoped, isDeep, node.getSession().getUserID()); SessionImpl session = (SessionImpl) node.getSession(); info.setLockHolder(session); info.setLive(true); session.addLockToken(info.lockToken.toString(), false); - lockedNodesMap.put(uuid, info); + lockedNodesMap.put(id, info); operations.add(info); return info; @@ -129,23 +129,23 @@ * @throws RepositoryException if an error occurs */ public void unlock(NodeImpl node) throws LockException, RepositoryException { - String uuid = node.internalGetUUID(); + NodeId id = node.getNodeId(); // check positive set first - AbstractLockInfo info = (LockInfo) lockedNodesMap.get(uuid); + AbstractLockInfo info = (LockInfo) lockedNodesMap.get(id); if (info != null) { - lockedNodesMap.remove(uuid); + lockedNodesMap.remove(id); operations.remove(info); info.setLive(false); } else { info = getLockInfo(node); - if (info == null || info.getUUID() != uuid) { + if (info == null || !info.getId().equals(id)) { throw new LockException("Node not locked."); } else if (info.getLockHolder() != node.getSession()) { throw new LockException("Node not locked by this session."); } info = new LockInfo(node, info); - unlockedNodesMap.put(uuid, info); + unlockedNodesMap.put(id, info); operations.add(info); } @@ -171,10 +171,10 @@ * @throws RepositoryException if an error occurs */ public AbstractLockInfo getLockInfo(NodeImpl node) throws RepositoryException { - String uuid = node.internalGetUUID(); + NodeId id = node.getNodeId(); // check negative set - if (unlockedNodesMap.containsKey(uuid)) { + if (unlockedNodesMap.containsKey(id)) { return null; } @@ -182,9 +182,9 @@ if (!lockedNodesMap.isEmpty()) { NodeImpl current = node; for (;;) { - LockInfo info = (LockInfo) lockedNodesMap.get(current.internalGetUUID()); + LockInfo info = (LockInfo) lockedNodesMap.get(current.getId()); if (info != null) { - if (info.getUUID() == uuid || info.deep) { + if (info.getId().equals(id) || info.deep) { return info; } break; @@ -196,7 +196,7 @@ } } // ask parent - return lockMgr.getLockInfo(uuid); + return lockMgr.getLockInfo(id); } /** Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/lock/XALockManager.java Thu Feb 16 02:48:20 2006 @@ -16,19 +16,17 @@ */ package org.apache.jackrabbit.core.lock; +import org.apache.jackrabbit.core.InternalXAResource; import org.apache.jackrabbit.core.NodeImpl; import org.apache.jackrabbit.core.SessionImpl; -import org.apache.jackrabbit.core.NodeId; -import org.apache.jackrabbit.core.TransactionException; import org.apache.jackrabbit.core.TransactionContext; -import org.apache.jackrabbit.core.InternalXAResource; +import org.apache.jackrabbit.core.TransactionException; import org.apache.jackrabbit.name.Path; -import org.apache.log4j.Logger; -import javax.jcr.lock.Lock; -import javax.jcr.lock.LockException; import javax.jcr.RepositoryException; import javax.jcr.Session; +import javax.jcr.lock.Lock; +import javax.jcr.lock.LockException; /** * Session-local lock manager that implements the semantical changes inside @@ -38,11 +36,6 @@ public class XALockManager implements LockManager, InternalXAResource { /** - * Logger instance for this class - */ - private static final Logger log = Logger.getLogger(XALockManager.class); - - /** * Attribute name for XA Environment. */ private static final String XA_ENV_ATTRIBUTE_NAME = "XALockManager.XAEnv"; @@ -80,7 +73,7 @@ public Lock lock(NodeImpl node, boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException { - AbstractLockInfo info = null; + AbstractLockInfo info; if (isInXA()) { info = xaEnv.lock(node, isDeep, isSessionScoped); } else { @@ -93,18 +86,17 @@ * {@inheritDoc} */ public Lock getLock(NodeImpl node) throws LockException, RepositoryException { - AbstractLockInfo info = null; + AbstractLockInfo info; if (isInXA()) { info = xaEnv.getLockInfo(node); } else { - info = lockMgr.getLockInfo(node.internalGetUUID()); + info = lockMgr.getLockInfo(node.getNodeId()); } if (info == null) { throw new LockException("Node not locked: " + node.safeGetJCRPath()); } SessionImpl session = (SessionImpl) node.getSession(); - NodeImpl holder = (NodeImpl) session.getItemManager().getItem( - new NodeId(info.getUUID())); + NodeImpl holder = (NodeImpl) session.getItemManager().getItem(info.getId()); return new XALock(this, info, holder); } @@ -123,27 +115,24 @@ * {@inheritDoc} */ public boolean holdsLock(NodeImpl node) throws RepositoryException { - AbstractLockInfo info = null; + AbstractLockInfo info; if (isInXA()) { info = xaEnv.getLockInfo(node); } else { - info = lockMgr.getLockInfo(node.internalGetUUID()); - } - if (info != null && info.getUUID().equals(node.internalGetUUID())) { - return true; + info = lockMgr.getLockInfo(node.getNodeId()); } - return false; + return info != null && info.getId().equals(node.getId()); } /** * {@inheritDoc} */ public boolean isLocked(NodeImpl node) throws RepositoryException { - AbstractLockInfo info = null; + AbstractLockInfo info; if (isInXA()) { info = xaEnv.getLockInfo(node); } else { - info = lockMgr.getLockInfo(node.internalGetUUID()); + info = lockMgr.getLockInfo(node.getNodeId()); } return info != null; } @@ -152,11 +141,11 @@ * {@inheritDoc} */ public void checkLock(NodeImpl node) throws LockException, RepositoryException { - AbstractLockInfo info = null; + AbstractLockInfo info; if (isInXA()) { info = xaEnv.getLockInfo(node); } else { - info = lockMgr.getLockInfo(node.internalGetUUID()); + info = lockMgr.getLockInfo(node.getNodeId()); } if (info != null && info.getLockHolder() != node.getSession()) { throw new LockException("Node locked."); Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java Thu Feb 16 02:48:20 2006 @@ -61,12 +61,12 @@ /** * the root node id (usually the id of /jcr:system/jcr:nodeTypes) */ - private final String rootNodeId; + private final NodeId rootNodeId; /** * the id of the roots parent (usually id of /jcr:system) */ - private final String parentId; + private final NodeId parentId; /** * the system session to generate the observation events @@ -89,7 +89,7 @@ */ public VirtualNodeTypeStateManager( NodeTypeRegistry ntReg, DelegatingObservationDispatcher obs, - String rootNodeId, String parentId) { + NodeId rootNodeId, NodeId parentId) { this.ntReg = ntReg; this.obsDispatcher = obs; this.rootNodeId = rootNodeId; @@ -99,7 +99,7 @@ /** * returns the virtual node state provider for the node type states. - * @return + * @return the virtual item state provider */ public synchronized VirtualItemStateProvider getVirtualItemStateProvider() { if (virtProvider == null) { @@ -129,7 +129,7 @@ } if (systemSession != null) { // generate observation events - NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(new NodeId(rootNodeId)); + NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId); NodeImpl child = root.getNode(ntName); List events = new ArrayList(); recursiveAdd(events, root, child); @@ -156,7 +156,7 @@ try { if (systemSession != null) { // generated observation events - NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(new NodeId(rootNodeId)); + NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId); NodeImpl child = root.getNode(ntName); List events = new ArrayList(); recursiveRemove(events, root, child); @@ -183,9 +183,9 @@ throws RepositoryException { events.add(EventState.childNodeAdded( - parent.internalGetUUID(), + parent.getNodeId(), parent.getPrimaryPath(), - node.internalGetUUID(), + node.getNodeId(), node.getPrimaryPath().getNameElement(), (NodeTypeImpl) parent.getPrimaryNodeType(), parent.getMixinTypeNames(), @@ -196,7 +196,7 @@ while (iter.hasNext()) { PropertyImpl prop = (PropertyImpl) iter.nextProperty(); events.add(EventState.propertyAdded( - node.internalGetUUID(), + (NodeId) node.getId(), node.getPrimaryPath(), prop.getPrimaryPath().getNameElement(), (NodeTypeImpl) node.getPrimaryNodeType(), @@ -223,9 +223,9 @@ throws RepositoryException { events.add(EventState.childNodeRemoved( - parent.internalGetUUID(), + parent.getNodeId(), parent.getPrimaryPath(), - node.internalGetUUID(), + node.getNodeId(), node.getPrimaryPath().getNameElement(), (NodeTypeImpl) parent.getPrimaryNodeType(), parent.getMixinTypeNames(), Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Thu Feb 16 02:48:20 2006 @@ -17,7 +17,6 @@ package org.apache.jackrabbit.core.nodetype.virtual; import org.apache.jackrabbit.core.NodeId; -import org.apache.jackrabbit.core.nodetype.ItemDef; import org.apache.jackrabbit.core.nodetype.NodeDef; import org.apache.jackrabbit.core.nodetype.NodeDefId; import org.apache.jackrabbit.core.nodetype.NodeTypeDef; @@ -49,15 +48,16 @@ /** * the parent id */ - private final String parentId; + private final NodeId parentId; /** * @param ntReg * @param rootNodeId * @param parentId */ - public VirtualNodeTypeStateProvider(NodeTypeRegistry ntReg, String rootNodeId, String parentId) { - super(ntReg, new NodeId(rootNodeId)); + public VirtualNodeTypeStateProvider(NodeTypeRegistry ntReg, + NodeId rootNodeId, NodeId parentId) { + super(ntReg, rootNodeId); this.parentId = parentId; try { getRootState(); @@ -72,14 +72,14 @@ * currently we have no dynamic ones, we just recreate the entire nodetypes tree */ protected VirtualNodeState createRootNodeState() throws RepositoryException { - VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId.getUUID(), QName.REP_NODETYPES, null); + VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, QName.REP_NODETYPES, null); NodeDefId id = ntReg.getEffectiveNodeType(QName.REP_SYSTEM).getApplicableChildNodeDef(QName.JCR_NODETYPES, QName.REP_NODETYPES).getId(); root.setDefinitionId(id); QName[] ntNames = ntReg.getRegisteredNodeTypes(); for (int i = 0; i < ntNames.length; i++) { NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntNames[i]); VirtualNodeState ntState = createNodeTypeState(root, ntDef); - root.addChildNodeEntry(ntNames[i], ntState.getUUID()); + root.addChildNodeEntry(ntNames[i], ntState.getNodeId()); // add as hard reference root.addStateReference(ntState); } @@ -108,7 +108,7 @@ VirtualNodeState root = (VirtualNodeState) getRootState(); NodeTypeDef ntDef = ntReg.getNodeTypeDef(ntName); VirtualNodeState ntState = createNodeTypeState(root, ntDef); - root.addChildNodeEntry(ntName, ntState.getUUID()); + root.addChildNodeEntry(ntName, ntState.getNodeId()); // add as hard reference root.addStateReference(ntState); @@ -150,9 +150,11 @@ * @return * @throws RepositoryException */ - private VirtualNodeState createNodeTypeState(VirtualNodeState parent, NodeTypeDef ntDef) throws RepositoryException { - String uuid = calculateStableUUID(ntDef.getName().toString()); - VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), uuid, QName.NT_NODETYPE); + private VirtualNodeState createNodeTypeState(VirtualNodeState parent, + NodeTypeDef ntDef) + throws RepositoryException { + NodeId id = new NodeId(calculateStableUUID(ntDef.getName().toString())); + VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, QName.NT_NODETYPE); // add properties ntState.setPropertyValue(QName.JCR_NODETYPENAME, InternalValue.create(ntDef.getName())); @@ -167,7 +169,7 @@ PropDef[] propDefs = ntDef.getPropertyDefs(); for (int i = 0; i < propDefs.length; i++) { VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i); - ntState.addChildNodeEntry(QName.JCR_PROPERTYDEFINITION, pdState.getUUID()); + ntState.addChildNodeEntry(QName.JCR_PROPERTYDEFINITION, pdState.getNodeId()); // add as hard reference ntState.addStateReference(pdState); } @@ -176,7 +178,7 @@ NodeDef[] cnDefs = ntDef.getChildNodeDefs(); for (int i = 0; i < cnDefs.length; i++) { VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i); - ntState.addChildNodeEntry(QName.JCR_CHILDNODEDEFINITION, cnState.getUUID()); + ntState.addChildNodeEntry(QName.JCR_CHILDNODEDEFINITION, cnState.getNodeId()); // add as hard reference ntState.addStateReference(cnState); } @@ -196,8 +198,9 @@ PropDef propDef, NodeTypeDef ntDef, int n) throws RepositoryException { - String uuid = calculateStableUUID(ntDef.getName().toString() + "/" + QName.JCR_PROPERTYDEFINITION.toString() + "/" + n); - VirtualNodeState pState = createNodeState(parent, QName.JCR_PROPERTYDEFINITION, uuid, QName.NT_PROPERTYDEFINITION); + NodeId id = new NodeId(calculateStableUUID( + ntDef.getName().toString() + "/" + QName.JCR_PROPERTYDEFINITION.toString() + "/" + n)); + VirtualNodeState pState = createNodeState(parent, QName.JCR_PROPERTYDEFINITION, id, QName.NT_PROPERTYDEFINITION); // add properties if (!propDef.definesResidual()) { pState.setPropertyValue(QName.JCR_NAME, InternalValue.create(propDef.getName())); @@ -231,8 +234,9 @@ NodeDef cnDef, NodeTypeDef ntDef, int n) throws RepositoryException { - String uuid = calculateStableUUID(ntDef.getName().toString() + "/" + QName.JCR_CHILDNODEDEFINITION.toString() + "/" + n); - VirtualNodeState pState = createNodeState(parent, QName.JCR_CHILDNODEDEFINITION, uuid, QName.NT_CHILDNODEDEFINITION); + NodeId id = new NodeId(calculateStableUUID( + ntDef.getName().toString() + "/" + QName.JCR_CHILDNODEDEFINITION.toString() + "/" + n)); + VirtualNodeState pState = createNodeState(parent, QName.JCR_CHILDNODEDEFINITION, id, QName.NT_CHILDNODEDEFINITION); // add properties if (!cnDef.definesResidual()) { pState.setPropertyValue(QName.JCR_NAME, InternalValue.create(cnDef.getName())); @@ -259,11 +263,11 @@ * @return * @throws RepositoryException */ - private static String calculateStableUUID(String name) throws RepositoryException { + private static UUID calculateStableUUID(String name) throws RepositoryException { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digest = md.digest(name.getBytes("utf-8")); - return new UUID(digest).toString(); + return new UUID(digest); } catch (NoSuchAlgorithmException e) { throw new RepositoryException(e); } catch (UnsupportedEncodingException e) { @@ -273,7 +277,7 @@ /** * @inheritDoc - */ + */ public boolean setNodeReferences(NodeReferences refs) { return false; } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ChangeLogBasedHierarchyMgr.java Thu Feb 16 02:48:20 2006 @@ -20,6 +20,7 @@ import org.apache.jackrabbit.core.HierarchyManagerImpl; import org.apache.jackrabbit.core.ItemId; import org.apache.jackrabbit.core.ZombieHierarchyManager; +import org.apache.jackrabbit.core.NodeId; import org.apache.jackrabbit.core.state.ChangeLog; import org.apache.jackrabbit.core.state.ItemState; import org.apache.jackrabbit.core.state.ItemStateException; @@ -52,20 +53,20 @@ * Creates a new ChangeLogBasedHierarchyMgr that overlays * manager with changes and uses the deleted * map of the changes as an attic ItemStateManager. - * @param rootNodeUUID the uuid of the root node. + * @param rootNodeId the id of the root node. * @param manager the item state manager. * @param changes the changes that will be applied on the item state manager. * @param resolver the namespace resolver of the current session. */ - ChangeLogBasedHierarchyMgr(String rootNodeUUID, + ChangeLogBasedHierarchyMgr(NodeId rootNodeId, ItemStateManager manager, ChangeLog changes, NamespaceResolver resolver) { - super(rootNodeUUID, + super(rootNodeId, new ChangeLogItemStateManager(manager, changes), resolver); zombieHierMgr = - new ZombieHierarchyManager(rootNodeUUID, provider, + new ZombieHierarchyManager(rootNodeId, provider, new AtticItemStateManager(changes), resolver); } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java Thu Feb 16 02:48:20 2006 @@ -17,11 +17,9 @@ package org.apache.jackrabbit.core.observation; import org.apache.jackrabbit.core.ItemId; -import org.apache.jackrabbit.core.NodeId; -import org.apache.jackrabbit.core.PropertyId; import org.apache.jackrabbit.core.SessionImpl; -import org.apache.jackrabbit.core.state.ItemState; import org.apache.jackrabbit.core.security.AccessManager; +import org.apache.jackrabbit.core.state.ItemState; import org.apache.log4j.Logger; import javax.jcr.RepositoryException; @@ -148,14 +146,7 @@ } // check read permission - ItemId targetId; - if (state.getChildUUID() == null) { - // target is a property - targetId = new PropertyId(state.getParentUUID(), state.getChildRelPath().getName()); - } else { - // target is a node - targetId = new NodeId(state.getChildUUID()); - } + ItemId targetId = state.getTargetId(); boolean granted = false; try { granted = session.getAccessManager().isGranted(targetId, AccessManager.READ); @@ -166,7 +157,7 @@ if (denied == null) { denied = new HashSet(); } - denied.add(state.getId()); + denied.add(targetId); } } } @@ -220,19 +211,12 @@ if (state.getType() == Event.NODE_ADDED || state.getType() == Event.PROPERTY_ADDED || state.getType() == Event.PROPERTY_CHANGED) { - ItemId targetId; - if (state.getChildUUID() == null) { - // target is a property - targetId = new PropertyId(state.getParentUUID(), state.getChildRelPath().getName()); - } else { - // target is a node - targetId = new NodeId(state.getChildUUID()); - } + ItemId targetId = state.getTargetId(); if (!session.getAccessManager().isGranted(targetId, AccessManager.READ)) { if (denied == null) { denied = new HashSet(); } - denied.add(state.getId()); + denied.add(targetId); } } } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventFilter.java Thu Feb 16 02:48:20 2006 @@ -18,6 +18,7 @@ import org.apache.jackrabbit.core.ItemManager; import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.NodeId; import org.apache.jackrabbit.core.nodetype.NodeTypeImpl; import org.apache.jackrabbit.name.MalformedPathException; import org.apache.jackrabbit.name.Path; @@ -69,7 +70,7 @@ /** * Only allow Nodes with the specified uuids. */ - private final String[] uuids; + private final NodeId[] ids; /** * Only allow Nodes with the specified {@link javax.jcr.nodetype.NodeType}s. @@ -93,9 +94,9 @@ * path. * @param isDeep if true also allow events for {@link * Item}s below absPath. - * @param uuids only allow events for {@link javax.jcr.Node}s with - * specified UUIDs. If null is passed no - * restriction regarding UUID is applied. + * @param ids only allow events for {@link javax.jcr.Node}s with + * specified NodeIDs. If null is passed no + * restriction regarding NodeIds is applied. * @param nodeTypes only allow events for specified {@link * javax.jcr.nodetype.NodeType}s. If null no * node type restriction is applied. @@ -108,7 +109,7 @@ long eventTypes, Path path, boolean isDeep, - String[] uuids, + NodeId[] ids, NodeTypeImpl[] nodeTypes, boolean noLocal) { @@ -117,7 +118,7 @@ this.eventTypes = eventTypes; this.path = path; this.isDeep = isDeep; - this.uuids = uuids; + this.ids = ids; this.noLocal = noLocal; this.nodeTypes = nodeTypes; } @@ -169,11 +170,11 @@ } // check UUIDs - String parentUUID = eventState.getParentUUID(); - if (uuids != null) { + NodeId parentId= eventState.getParentId(); + if (ids != null) { boolean match = false; - for (int i = 0; i < uuids.length && !match; i++) { - match |= parentUUID.equals(uuids[i]); + for (int i = 0; i < ids.length && !match; i++) { + match |= parentId.equals(ids[i]); } if (!match) { return true; Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java Thu Feb 16 02:48:20 2006 @@ -17,6 +17,7 @@ package org.apache.jackrabbit.core.observation; import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.NodeId; import org.apache.jackrabbit.name.MalformedPathException; import org.apache.jackrabbit.name.NoPrefixDeclaredException; import org.apache.jackrabbit.name.Path; @@ -112,19 +113,19 @@ * * @return the uuid of the parent node. */ - public String getParentUUID() { - return eventState.getParentUUID(); + public NodeId getParentId() { + return eventState.getParentId(); } /** - * Returns the UUID of a child node operation. + * Returns the id of a child node operation. * If this Event was generated for a property * operation this method returns null. * - * @return the UUID of a child node operation. + * @return the id of a child node operation. */ - public String getChildUUID() { - return eventState.getChildUUID(); + public NodeId getChildId() { + return eventState.getChildId(); } /** Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventState.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventState.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventState.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventState.java Thu Feb 16 02:48:20 2006 @@ -38,9 +38,9 @@ private final int type; /** - * The UUID of the parent node associated with this event. + * The Id of the parent node associated with this event. */ - private final String parentUUID; + private final NodeId parentId; /** * The path of the parent node associated with this event. @@ -52,7 +52,7 @@ * {@link javax.jcr.observation.Event#NODE_ADDED} or * {@link javax.jcr.observation.Event#NODE_REMOVED}. */ - private final String childUUID; + private final NodeId childId; /** * The relative path of the child item associated with this event. @@ -89,11 +89,10 @@ * Creates a new EventState instance. * * @param type the type of this event. - * @param parentUUID the uuid of the parent node associated with this - * event. + * @param parentId the id of the parent node associated with this event. * @param parentPath the path of the parent node associated with this * event. - * @param childUUID the uuid of the child node associated with this event. + * @param childId the id of the child node associated with this event. * If the event type is one of: PROPERTY_ADDED, * PROPERTY_CHANGED or PROPERTY_REMOVED * this parameter must be null. @@ -104,27 +103,27 @@ * @param session the {@link javax.jcr.Session} that caused this event. */ private EventState(int type, - String parentUUID, + NodeId parentId, Path parentPath, - String childUUID, + NodeId childId, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { int mask = (Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED); if ((type & mask) > 0) { - if (childUUID != null) { - throw new IllegalArgumentException("childUUID only allowed for Node events."); + if (childId != null) { + throw new IllegalArgumentException("childId only allowed for Node events."); } } else { - if (childUUID == null) { - throw new IllegalArgumentException("childUUID must not be null for Node events."); + if (childId == null) { + throw new IllegalArgumentException("childId must not be null for Node events."); } } this.type = type; - this.parentUUID = parentUUID; + this.parentId = parentId; this.parentPath = parentPath; - this.childUUID = childUUID; + this.childId = childId; this.childRelPath = childPath; this.nodeType = nodeType; this.mixins = mixins; @@ -137,28 +136,28 @@ * Creates a new {@link javax.jcr.observation.Event} of type * {@link javax.jcr.observation.Event#NODE_ADDED}. * - * @param parentUUID the uuid of the parent node associated with + * @param parentId the id of the parent node associated with * this EventState. * @param parentPath the path of the parent node associated with * this EventState. - * @param childUUID the uuid of the child node associated with this event. + * @param childId the id of the child node associated with this event. * @param childPath the relative path of the child node that was added. * @param nodeType the node type of the parent node. * @param mixins mixins assigned to the parent node. * @param session the session that added the node. * @return an EventState instance. */ - public static EventState childNodeAdded(String parentUUID, + public static EventState childNodeAdded(NodeId parentId, Path parentPath, - String childUUID, + NodeId childId, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { return new EventState(Event.NODE_ADDED, - parentUUID, + parentId, parentPath, - childUUID, + childId, childPath, nodeType, mixins, @@ -169,28 +168,28 @@ * Creates a new {@link javax.jcr.observation.Event} of type * {@link javax.jcr.observation.Event#NODE_REMOVED}. * - * @param parentUUID the uuid of the parent node associated with + * @param parentId the id of the parent node associated with * this EventState. * @param parentPath the path of the parent node associated with * this EventState. - * @param childUUID the uuid of the child node associated with this event. + * @param childId the id of the child node associated with this event. * @param childPath the relative path of the child node that was removed. * @param nodeType the node type of the parent node. * @param mixins mixins assigned to the parent node. * @param session the session that removed the node. * @return an EventState instance. */ - public static EventState childNodeRemoved(String parentUUID, + public static EventState childNodeRemoved(NodeId parentId, Path parentPath, - String childUUID, + NodeId childId, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { return new EventState(Event.NODE_REMOVED, - parentUUID, + parentId, parentPath, - childUUID, + childId, childPath, nodeType, mixins, @@ -201,7 +200,7 @@ * Creates a new {@link javax.jcr.observation.Event} of type * {@link javax.jcr.observation.Event#PROPERTY_ADDED}. * - * @param parentUUID the uuid of the parent node associated with + * @param parentId the id of the parent node associated with * this EventState. * @param parentPath the path of the parent node associated with * this EventState. @@ -211,14 +210,14 @@ * @param session the session that added the property. * @return an EventState instance. */ - public static EventState propertyAdded(String parentUUID, + public static EventState propertyAdded(NodeId parentId, Path parentPath, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { return new EventState(Event.PROPERTY_ADDED, - parentUUID, + parentId, parentPath, null, childPath, @@ -231,7 +230,7 @@ * Creates a new {@link javax.jcr.observation.Event} of type * {@link javax.jcr.observation.Event#PROPERTY_REMOVED}. * - * @param parentUUID the uuid of the parent node associated with + * @param parentId the id of the parent node associated with * this EventState. * @param parentPath the path of the parent node associated with * this EventState. @@ -241,14 +240,14 @@ * @param session the session that removed the property. * @return an EventState instance. */ - public static EventState propertyRemoved(String parentUUID, + public static EventState propertyRemoved(NodeId parentId, Path parentPath, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { return new EventState(Event.PROPERTY_REMOVED, - parentUUID, + parentId, parentPath, null, childPath, @@ -261,7 +260,7 @@ * Creates a new {@link javax.jcr.observation.Event} of type * {@link javax.jcr.observation.Event#PROPERTY_CHANGED}. * - * @param parentUUID the uuid of the parent node associated with + * @param parentId the id of the parent node associated with * this EventState. * @param parentPath the path of the parent node associated with * this EventState. @@ -271,14 +270,14 @@ * @param session the session that changed the property. * @return an EventState instance. */ - public static EventState propertyChanged(String parentUUID, + public static EventState propertyChanged(NodeId parentId, Path parentPath, Path.PathElement childPath, NodeTypeImpl nodeType, Set mixins, Session session) { return new EventState(Event.PROPERTY_CHANGED, - parentUUID, + parentId, parentPath, null, childPath, @@ -299,8 +298,8 @@ * * @return the uuid of the parent node. */ - public String getParentUUID() { - return parentUUID; + public NodeId getParentId() { + return parentId; } /** @@ -313,14 +312,14 @@ } /** - * Returns the UUID of a child node operation. + * Returns the Id of a child node operation. * If this EventState was generated for a property * operation this method returns null. * - * @return the UUID of a child node operation. + * @return the id of a child node operation. */ - public String getChildUUID() { - return childUUID; + public NodeId getChildId() { + return childId; } /** @@ -375,13 +374,13 @@ * * @return the ItemId. */ - ItemId getId() { - if (childUUID == null) { + ItemId getTargetId() { + if (childId == null) { // property event - return new PropertyId(parentUUID, childRelPath.getName()); + return new PropertyId(parentId, childRelPath.getName()); } else { // node event - return new NodeId(childUUID); + return childId; } } @@ -394,7 +393,7 @@ if (stringValue == null) { StringBuffer sb = new StringBuffer(); sb.append("EventState: ").append(valueOf(type)); - sb.append(", Parent: ").append(parentUUID); + sb.append(", Parent: ").append(parentId); sb.append(", Child: ").append(childRelPath); sb.append(", UserId: ").append(session.getUserID()); stringValue = sb.toString(); @@ -411,8 +410,8 @@ int h = hashCode; if (h == 0) { h = 37; - h = 37 * h + (int) type; - h = 37 * h + parentUUID.hashCode(); + h = 37 * h + type; + h = 37 * h + parentId.hashCode(); h = 37 * h + childRelPath.hashCode(); h = 37 * h + session.hashCode(); hashCode = h; @@ -435,7 +434,7 @@ if (obj instanceof EventState) { EventState other = (EventState) obj; return this.type == other.type - && this.parentUUID.equals(other.parentUUID) + && this.parentId.equals(other.parentId) && this.childRelPath.equals(other.childRelPath) && this.session.equals(other.session); } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Thu Feb 16 02:48:20 2006 @@ -96,19 +96,19 @@ * Creates {@link EventState} instances from ItemState * changes. * - * @param rootNodeUUID the UUID of the root node. + * @param rootNodeId the id of the root node. * @param changes the changes on ItemStates. * @param provider an ItemStateProvider to provide ItemState * of items that are not contained in the changes collection. * @throws ItemStateException if an error occurs while creating events * states for the item state changes. */ - public void createEventStates(String rootNodeUUID, ChangeLog changes, ItemStateManager provider) throws ItemStateException { + public void createEventStates(NodeId rootNodeId, ChangeLog changes, ItemStateManager provider) throws ItemStateException { // create a hierarchy manager, that is based on the ChangeLog and // the ItemStateProvider // todo use CachingHierarchyManager ? ChangeLogBasedHierarchyMgr hmgr = - new ChangeLogBasedHierarchyMgr(rootNodeUUID, provider, changes, + new ChangeLogBasedHierarchyMgr(rootNodeId, provider, changes, session.getNamespaceResolver()); /** @@ -117,7 +117,7 @@ * a very good reason for it! Some internal SynchronousEventListener * implementations depend on the order of the events fired. * LockManagerImpl for example expects that for any given path a - * childNodeRemoved event is fired before a childNodeAdded event. + * childNodeRemoved event is fired before a childNodeAdded event. */ // 1. modified items @@ -146,40 +146,40 @@ NodeState n = (NodeState) state; if (n.hasOverlayedState()) { - String oldParentUUID = n.getOverlayedState().getParentUUID(); - String newParentUUID = n.getParentUUID(); - if (newParentUUID != null && - !oldParentUUID.equals(newParentUUID)) { + NodeId oldParentId = n.getOverlayedState().getParentId(); + NodeId newParentId = n.getParentId(); + if (newParentId != null && + !oldParentId.equals(newParentId)) { // node moved // generate node removed & node added event NodeState oldParent; try { - oldParent = (NodeState) changes.get(new NodeId(oldParentUUID)); + oldParent = (NodeState) changes.get(oldParentId); } catch (NoSuchItemStateException e) { // old parent has been deleted, retrieve from // shared item state manager - oldParent = (NodeState) provider.getItemState(new NodeId(oldParentUUID)); + oldParent = (NodeState) provider.getItemState(oldParentId); } NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session); Set mixins = oldParent.getMixinTypeNames(); - Path newPath = getPath(n.getId(), hmgr); - Path oldPath = getZombiePath(n.getId(), hmgr); + Path newPath = getPath(n.getNodeId(), hmgr); + Path oldPath = getZombiePath(n.getNodeId(), hmgr); if (!oldPath.equals(newPath)) { - events.add(EventState.childNodeRemoved(oldParentUUID, + events.add(EventState.childNodeRemoved(oldParentId, getParent(oldPath), - n.getUUID(), + n.getNodeId(), oldPath.getNameElement(), oldParentNodeType, mixins, session)); - NodeState newParent = (NodeState) changes.get(new NodeId(newParentUUID)); + NodeState newParent = (NodeState) changes.get(newParentId); NodeTypeImpl newParentNodeType = getNodeType(newParent, session); mixins = newParent.getMixinTypeNames(); - events.add(EventState.childNodeAdded(newParentUUID, + events.add(EventState.childNodeAdded(newParentId, getParent(newPath), - n.getUUID(), + n.getNodeId(), newPath.getNameElement(), newParentNodeType, mixins, @@ -192,8 +192,8 @@ NodeState parent = null; try { // root node does not have a parent UUID - if (state.getParentUUID() != null) { - parent = (NodeState) changes.get(new NodeId(state.getParentUUID())); + if (state.getParentId() != null) { + parent = (NodeState) changes.get(state.getParentId()); } } catch (NoSuchItemStateException e) { // should never happen actually. this would mean @@ -207,7 +207,7 @@ NodeState.ChildNodeEntry moved = null; for (Iterator removedNodes = parent.getRemovedChildNodeEntries().iterator(); removedNodes.hasNext();) { NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry) removedNodes.next(); - if (child.getUUID().equals(n.getUUID())) { + if (child.getId().equals(n.getNodeId())) { // found node re-added with different name moved = child; } @@ -230,16 +230,16 @@ log.error(msg); throw new ItemStateException(msg, e); } - events.add(EventState.childNodeRemoved(parent.getUUID(), + events.add(EventState.childNodeRemoved(parent.getNodeId(), parentPath, - n.getUUID(), + n.getNodeId(), oldPath.getNameElement(), nodeType, mixins, session)); - events.add(EventState.childNodeAdded(parent.getUUID(), + events.add(EventState.childNodeAdded(parent.getNodeId(), parentPath, - n.getUUID(), + n.getNodeId(), newPath.getNameElement(), nodeType, mixins, @@ -260,28 +260,28 @@ NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry) ro.next(); QName name = child.getName(); int index = (child.getIndex() != 1) ? child.getIndex() : 0; - Path parentPath = getPath(n.getId(), hmgr); + Path parentPath = getPath(n.getNodeId(), hmgr); Path.PathElement addedElem = Path.create(name, index).getNameElement(); // get removed index NodeState overlayed = (NodeState) n.getOverlayedState(); - NodeState.ChildNodeEntry entry = overlayed.getChildNodeEntry(child.getUUID()); + NodeState.ChildNodeEntry entry = overlayed.getChildNodeEntry(child.getId()); if (entry == null) { - throw new ItemStateException("Unable to retrieve old child index for item: " + child.getUUID()); + throw new ItemStateException("Unable to retrieve old child index for item: " + child.getId()); } int oldIndex = (entry.getIndex() != 1) ? entry.getIndex() : 0; Path.PathElement removedElem = Path.create(name, oldIndex).getNameElement(); - events.add(EventState.childNodeRemoved(n.getUUID(), + events.add(EventState.childNodeRemoved(n.getNodeId(), parentPath, - child.getUUID(), + child.getId(), removedElem, nodeType, mixins, session)); - events.add(EventState.childNodeAdded(n.getUUID(), + events.add(EventState.childNodeAdded(n.getNodeId(), parentPath, - child.getUUID(), + child.getId(), addedElem, nodeType, mixins, @@ -291,10 +291,10 @@ } else { // property changed Path path = getPath(state.getId(), hmgr); - NodeState parent = (NodeState) provider.getItemState(new NodeId(state.getParentUUID())); + NodeState parent = (NodeState) provider.getItemState(state.getParentId()); NodeTypeImpl nodeType = getNodeType(parent, session); Set mixins = parent.getMixinTypeNames(); - events.add(EventState.propertyChanged(state.getParentUUID(), + events.add(EventState.propertyChanged(state.getParentId(), getParent(path), path.getNameElement(), nodeType, @@ -310,13 +310,13 @@ if (state.isNode()) { // node deleted NodeState n = (NodeState) state; - NodeState parent = (NodeState) provider.getItemState(new NodeId(n.getParentUUID())); + NodeState parent = (NodeState) provider.getItemState(n.getParentId()); NodeTypeImpl nodeType = getNodeType(parent, session); Set mixins = parent.getMixinTypeNames(); Path path = getZombiePath(state.getId(), hmgr); - events.add(EventState.childNodeRemoved(n.getParentUUID(), + events.add(EventState.childNodeRemoved(n.getParentId(), getParent(path), - n.getUUID(), + n.getNodeId(), path.getNameElement(), nodeType, mixins, @@ -325,12 +325,12 @@ // property removed // only create an event if node still exists try { - NodeState n = (NodeState) changes.get(new NodeId(state.getParentUUID())); + NodeState n = (NodeState) changes.get(state.getParentId()); // node state exists -> only property removed NodeTypeImpl nodeType = getNodeType(n, session); Set mixins = n.getMixinTypeNames(); Path path = getZombiePath(state.getId(), hmgr); - events.add(EventState.propertyRemoved(state.getParentUUID(), + events.add(EventState.propertyRemoved(state.getParentId(), getParent(path), path.getNameElement(), nodeType, @@ -349,7 +349,7 @@ if (state.isNode()) { // node created NodeState n = (NodeState) state; - NodeId parentId = new NodeId(n.getParentUUID()); + NodeId parentId = n.getParentId(); NodeState parent; // unknown if parent node is also new if (provider.hasItemState(parentId)) { @@ -359,21 +359,21 @@ } NodeTypeImpl nodeType = getNodeType(parent, session); Set mixins = parent.getMixinTypeNames(); - Path path = getPath(n.getId(), hmgr); - events.add(EventState.childNodeAdded(n.getParentUUID(), + Path path = getPath(n.getNodeId(), hmgr); + events.add(EventState.childNodeAdded(parentId, getParent(path), - n.getUUID(), + n.getNodeId(), path.getNameElement(), nodeType, mixins, session)); } else { // property created / set - NodeState n = (NodeState) changes.get(new NodeId(state.getParentUUID())); + NodeState n = (NodeState) changes.get(state.getParentId()); NodeTypeImpl nodeType = getNodeType(n, session); Set mixins = n.getMixinTypeNames(); Path path = getPath(state.getId(), hmgr); - events.add(EventState.propertyAdded(state.getParentUUID(), + events.add(EventState.propertyAdded(state.getParentId(), getParent(path), path.getNameElement(), nodeType, @@ -456,7 +456,7 @@ } catch (Exception e) { // also catch eventual runtime exceptions here // should never happen actually - String msg = "Item " + node.getId() + " has unknown node type: " + node.getNodeTypeName(); + String msg = "Item " + node.getNodeId() + " has unknown node type: " + node.getNodeTypeName(); log.error(msg); throw new ItemStateException(msg, e); } Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java Thu Feb 16 02:48:20 2006 @@ -154,7 +154,7 @@ while (next == null && actualEvents.hasNext()) { state = (EventState) actualEvents.next(); // check denied set - if (denied == null || !denied.contains(state.getId())) { + if (denied == null || !denied.contains(state.getTargetId())) { try { next = filter.blocks(state) ? null : new EventImpl(filter.getSession(), state); } catch (RepositoryException e) { Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=378221&r1=378220&r2=378221&view=diff ============================================================================== --- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (original) +++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java Thu Feb 16 02:48:20 2006 @@ -15,6 +15,7 @@ import org.apache.jackrabbit.core.ItemManager; import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.NodeId; import org.apache.jackrabbit.core.nodetype.NodeTypeImpl; import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl; import org.apache.jackrabbit.name.MalformedPathException; @@ -116,13 +117,20 @@ log.debug(msg); throw new RepositoryException(msg, mpe); } + NodeId[] ids = null; + if (uuid != null) { + ids = new NodeId[uuid.length]; + for (int i=0; iUUID from the search index. - * @param uuid the UUID of the node to delete. + * Deletes the Node with id from the search index. + * @param id the id of the node to delete. * @throws IOException if an error occurs while deleting the node. */ - void deleteNode(String uuid) throws IOException; + void deleteNode(NodeId id) throws IOException; /** * Updates the index in an atomic operation. Some nodes may be removed and * added again in the same updateNodes() call, which is equivalent to an * node update. * - * @param remove Iterator of uuid Strings of nodes to delete + * @param remove Iterator of NodeIds of nodes to delete * @param add Iterator of NodeState instance to add to the * index. * @throws RepositoryException if an error occurs while indexing a node. * @throws IOException if an error occurs while updating the index. */ - void updateNodes(Iterator remove, Iterator add) + void updateNodes(NodeIdIterator remove, NodeStateIterator add) throws RepositoryException, IOException; /**