javax.jcr.Node.isLocked()方法的使用及代码示例

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

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

Node.isLocked介绍

[英]Returns true if this node is locked either as a result of a lock held by this node or by a deep lock on a node above this node; otherwise returns false. This includes the case where a repository does not support locking (in which case all nodes are "unlocked" by default).
[中]如果由于该节点持有的锁或该节点上方的节点上的深锁导致该节点被锁定,则返回true;否则返回false。这包括存储库不支持锁定的情况(在这种情况下,默认情况下所有节点都“解锁”)。

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.javascript

public boolean jsFunction_getLocked() {
  try {
    return node.isLocked();
  } catch (RepositoryException re) {
    return false;
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public boolean isLocked() throws RepositoryException {
  return this.node.isLocked();
}

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

@Override
public boolean canOperateOnNode(final Node node) throws Exception {
  return !node.isLocked();
}

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

/** {@inheritDoc} */
public boolean isLocked() throws RepositoryException, RemoteException {
  try {
    return node.isLocked();
  } catch (RepositoryException ex) {
    throw getRepositoryException(ex);
  }
}

代码示例来源:origin: info.magnolia.publishing/magnolia-publishing-core

private void logLockStatus(Node node, boolean isLock) throws RepositoryException {
    if (log.isDebugEnabled()) {
      // this log obtains too much data to processed all the time when not enabled
      log.debug("{} {} {}locked {}:{}", node.getSession(), isLock ^ node.isLocked() ? "DIDN'T" : "DID", isLock ? "" : "un", node.getSession().getWorkspace().getName(), node.getPath());
    }
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-console-frontend

private boolean isLocked() {
  try {
    final Node node = getModelObject();
    return node != null && node.isLocked();
  } catch (RepositoryException e) {
    log.error("An error occurred determining if node is locked.", e);
    return false;
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-plugins

private boolean isLocked() {
  try {
    final Node node = getModelObject();
    return node != null && node.isLocked();
  } catch (RepositoryException e) {
    log.error("An error occurred determining if node is locked.", e);
    return false;
  }
}

代码示例来源:origin: info.magnolia.publishing/magnolia-publishing-core

private void unlock(Node node) throws RepositoryException {
  if (node != null && node.isLocked()) {
    node.getSession().getWorkspace().getLockManager().unlock(node.getPath());
    logLockStatus(node, false);
  }
}

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

/**
 * @see javax.jcr.lock.LockManager#isLocked(String)
 */
public boolean isLocked(String absPath) throws RepositoryException {
  Node n = itemManager.getNode(resolver.getQPath(absPath));
  return n.isLocked();
}

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

public boolean isLocked(final String absPath) {
  try {
    final Node node = getNode(absPath);
    return node.isLocked();
  } catch (RepositoryException e) {
    // node.isLocked() RepositoryException if an error occurs.
    throw new org.apache.jackrabbit.ocm.exception.RepositoryException("An exception was thrown while checking the lock at path : " + absPath, e);
  }
}

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

/**
 * @see javax.jcr.lock.LockManager#isLocked(String)
 */
public boolean isLocked(String absPath) throws RepositoryException {
  Node n = itemManager.getNode(resolver.getQPath(absPath));
  return n.isLocked();
}

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

/**
 * Test {@link LockManager#isLocked(String)} and {@link javax.jcr.Node#isLocked()}.
 *
 * @throws RepositoryException If an exception occurs.
 */
public void testNodeIsLocked() throws RepositoryException {
  assertTrue("Node must be locked after lock creation.", lockedNode.isLocked());
  assertTrue("Node must be locked after lock creation.", lockMgr.isLocked(lockedNode.getPath()));
}

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

public static boolean isLocked( final PentahoJcrConstants pentahoJcrConstants, final Node node )
 throws RepositoryException {
 Assert.notNull( node );
 if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
  // frozen nodes are never locked
  return false;
 }
 boolean locked = node.isLocked();
 if ( locked ) {
  Assert.isTrue( node.isNodeType( pentahoJcrConstants.getMIX_LOCKABLE() ) );
 }
 return locked;
}

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

/**
 * {@inheritDoc}
 */
public void addLockTokenToSessionIfNecessary( final Session session, final PentahoJcrConstants pentahoJcrConstants,
  final Serializable fileId ) throws RepositoryException {
 Node fileNode = session.getNodeByIdentifier( fileId.toString() );
 if ( fileNode.isLocked() ) {
  LockManager lockManager = session.getWorkspace().getLockManager();
  Lock lock = lockManager.getLock( fileNode.getPath() );
  String lockToken = getLockToken( session, pentahoJcrConstants, lock );
  lockManager.addLockToken( lockToken );
 }
}

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

/**
 * {@inheritDoc}
 */
public void removeLockTokenFromSessionIfNecessary( final Session session,
  final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId ) throws RepositoryException {
 Node fileNode = session.getNodeByIdentifier( fileId.toString() );
 if ( fileNode.isLocked() ) {
  LockManager lockManager = session.getWorkspace().getLockManager();
  Lock lock = lockManager.getLock( fileNode.getPath() );
  String lockToken = getLockToken( session, pentahoJcrConstants, lock );
  lockManager.removeLockToken( lockToken );
 }
}

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

public void testIsLockedNewChild() throws RepositoryException {
  Node newChild = lockedNode.addNode(nodeName3, testNodeType);
  assertEquals("New child node must be locked according to isDeep flag.", isDeep(),
      newChild.isLocked());
  assertEquals("New child node must be locked according to isDeep flag.", isDeep(),
      lockMgr.isLocked(newChild.getPath()));
}

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

public Object doInJcr( final Session session ) throws RepositoryException {
  Item item = session.getItem( absPath );
  Assert.isTrue( item.isNode() );
  return ( (Node) item ).isLocked();
 }
} );

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

public void testReorder() throws Exception {
  testRootNode.addNode(nodeName2);
  testRootNode.addNode(nodeName3);
  testRootNode.save();
  // move last node in front of first
  testRootNode.orderBefore(lockedNode.getName(), nodeName3);
  testRootNode.save();
  assertTrue("Node must remain locked upon reordering", testRootNode.getNode(lockedNode.getName()).isLocked());
}

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

public void execute(Session session, Node test) throws RepositoryException {
    Node n = test.addNode("test");
    n.addMixin(mixLockable);
    session.save();
    for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
      if (n.isLocked()) {
        n.unlock();
      }
      n.lock(false, true);
    }
  }
}, CONCURRENCY);

代码示例来源:origin: ModeShape/modeshape

private void assertLocking( Session session, String path, boolean locked ) throws Exception {
  Node node = session.getNode(path);
  if (locked) {
    assertTrue(node.isLocked());
    assertTrue(node.hasProperty(JcrLexicon.LOCK_IS_DEEP.getString()));
    assertTrue(node.hasProperty(JcrLexicon.LOCK_OWNER.getString()));
  } else {
    assertFalse(node.isLocked());
    assertFalse(node.hasProperty(JcrLexicon.LOCK_IS_DEEP.getString()));
    assertFalse(node.hasProperty(JcrLexicon.LOCK_OWNER.getString()));
  }
}

相关文章

微信公众号

最新文章

更多