javax.jcr.lock.Lock.getNode()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中javax.jcr.lock.Lock.getNode()方法的一些代码示例,展示了Lock.getNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock.getNode()方法的具体详情如下:
包路径:javax.jcr.lock.Lock
类名称:Lock
方法名:getNode

Lock.getNode介绍

[英]Returns the lock holding node. Note that N.getLock().getNode() (where N is a locked node) will only return N if N is the lock holder. If N is in the subgraph of the lock holder, H, then this call will return H.
[中]返回锁保持节点。请注意,N.getLock().getNode()(其中N是锁定节点)仅在N是锁持有者时返回N。如果N位于锁持有者H的子图中,则此调用将返回H

代码示例

代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine

@Override
public Node getNode() {
  synchronized (session) {
    return lock.getNode();
  }
}

代码示例来源:origin: org.apache/jackrabbit-ocm

public Node getNode() {
  return lock.getNode();
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm

public Node getNode() {
  return lock.getNode();
}

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public Node getNode() {
  return NodeFacade.wrap(delegate.getNode(), session);
}

代码示例来源:origin: apache/jackrabbit

/** {@inheritDoc} */
public RemoteNode getNode() throws RemoteException {
  return getRemoteNode(lock.getNode());
}

代码示例来源:origin: pentaho/pentaho-platform

/**
 * Removes a lock token so that it can never be associated with anyone's session again. (To be called after the
 * file has been unlocked and therefore the token associated with the lock is unnecessary.)
 */
public void removeLockToken( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 Node lockTokensNode = getOrCreateLockTokensNode( session, pentahoJcrConstants, lock );
 NodeIterator nodes = lockTokensNode.getNodes( lock.getNode().getIdentifier() );
 if ( nodes.hasNext() ) {
  nodes.nextNode().remove();
 }
 session.save();
}

代码示例来源:origin: pentaho/pentaho-platform

/**
 * Returns all lock tokens belonging to the session's user. Lock tokens can then be added to the session by
 * calling {@code Session.addLockToken(token)}.
 * 
 * <p>
 * Callers should call {#link {@link #canUnlock(Session, PentahoJcrConstants, Lock)} if the token is being
 * retrieved for the purpose of an unlock.
 * </p>
 */
protected String getLockToken( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 Node lockTokensNode = getOrCreateLockTokensNode( session, pentahoJcrConstants, lock );
 NodeIterator nodes = lockTokensNode.getNodes( lock.getNode().getIdentifier() );
 Assert.isTrue( nodes.hasNext() );
 return nodes.nextNode().getProperty( pentahoJcrConstants.getPHO_LOCKTOKEN() ).getString();
}

代码示例来源:origin: pentaho/pentaho-platform

/**
 * Stores a lock token associated with the session's user.
 */
protected void addLockToken( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 Node lockTokensNode = getOrCreateLockTokensNode( session, pentahoJcrConstants, lock );
 Node newLockTokenNode =
   lockTokensNode.addNode( lock.getNode().getIdentifier(), pentahoJcrConstants.getPHO_NT_LOCKTOKENSTORAGE() );
 newLockTokenNode.setProperty( pentahoJcrConstants.getPHO_LOCKEDNODEREF(), lock.getNode() );
 newLockTokenNode.setProperty( pentahoJcrConstants.getPHO_LOCKTOKEN(), lock.getLockToken() );
 session.save();
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test {@link javax.jcr.lock.Lock#getNode()}.
 *
 * @throws RepositoryException If an exception occurs.
 */
public void testLockHoldingNode() throws RepositoryException {
  assertTrue("Lock.getNode() must be lockholding node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: apache/jackrabbit

public void testGetNodeOnLockObtainedFromNewChild() throws RepositoryException {
  Node newChild = lockedNode.addNode(nodeName3, testNodeType);
  javax.jcr.lock.Lock lock = newChild.getLock();
  assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: apache/jackrabbit

public void testGetNodeOnLockObtainedFromChild() throws RepositoryException {
  javax.jcr.lock.Lock lock = childNode.getLock();
  assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: apache/jackrabbit

public static String getDavLocktoken(Lock lock) throws RepositoryException {
  String jcrLockToken = lock.getLockToken();
  if (jcrLockToken == null) {
    return SESSPREFIX + Text.escape(lock.getNode().getIdentifier());
  } else {
    return OPENPREFIX + Text.escape(jcrLockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testLockHoldingNode() throws RepositoryException {
  assertTrue("Lock.getNode() must be lockholding node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: apache/jackrabbit

public void testGetNodeOnLockObtainedFromNewChild() throws RepositoryException {
  Node newChild = lockedNode.addNode(nodeName3, testNodeType);
  Lock lock = newChild.getLock();
  assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: apache/jackrabbit

/**
 * Creates a new lock info for the given JCR lock object.
 *
 * @param lock the lock.
 * @param idFactory the id factory.
 * @throws RepositoryException if an error occurs while the node from the
 * given lock or while creating the node id.
 */
private LockInfoImpl(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
  super(lock.getLockToken(), lock.getLockOwner(), lock.isDeep(),
      lock.isSessionScoped(), lock.getSecondsRemaining(), lock.isLockOwningSession(), 
      idFactory.createNodeId(lock.getNode()));
}

代码示例来源:origin: apache/jackrabbit

public void testGetNodeOnLockObtainedFromChild() throws RepositoryException {
  Lock lock = childNode.getLock();
  assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr

/**
 * Creates a new lock info for the given JCR lock object.
 *
 * @param lock the lock.
 * @param idFactory the id factory.
 * @throws RepositoryException if an error occurs while the node from the
 * given lock or while creating the node id.
 */
private LockInfoImpl(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
  super(lock.getLockToken(), lock.getLockOwner(), lock.isDeep(),
      lock.isSessionScoped(), lock.getSecondsRemaining(), lock.isLockOwningSession(), 
      idFactory.createNodeId(lock.getNode()));
}

代码示例来源:origin: apache/jackrabbit

/**
 * @see javax.jcr.Node#holdsLock()
 */
public boolean holdsLock() throws RepositoryException {
  // lock can be inherited from a parent > do not check for node being lockable.
  checkStatus();
  if (isNew() || !isNodeType(NameConstants.MIX_LOCKABLE)) {
    // a node that is new or not lockable never holds a lock
    return false;
  } else {
    LockStateManager lMgr = session.getLockStateManager();
    return (lMgr.isLocked(getNodeState()) && lMgr.getLock(getNodeState()).getNode().isSame(this));
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi

/**
 * @see javax.jcr.Node#holdsLock()
 */
public boolean holdsLock() throws RepositoryException {
  // lock can be inherited from a parent > do not check for node being lockable.
  checkStatus();
  if (isNew() || !isNodeType(NameConstants.MIX_LOCKABLE)) {
    // a node that is new or not lockable never holds a lock
    return false;
  } else {
    LockStateManager lMgr = session.getLockStateManager();
    return (lMgr.isLocked(getNodeState()) && lMgr.getLock(getNodeState()).getNode().isSame(this));
  }
}

代码示例来源:origin: apache/jackrabbit

public void testParentChildLock2() throws Exception {
  childNode.addMixin(mixLockable);
  testRootNode.save();
  try {
    Lock l = childNode.lock(false, isSessionScoped());
    assertTrue("child node must still hold lock", l.getNode().isSame(childNode));
  } finally {
    childNode.unlock();
  }
}

相关文章