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

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

本文整理了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

  1. public boolean jsFunction_getLocked() {
  2. try {
  3. return node.isLocked();
  4. } catch (RepositoryException re) {
  5. return false;
  6. }
  7. }

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

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

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

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

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

  1. /** {@inheritDoc} */
  2. public boolean isLocked() throws RepositoryException, RemoteException {
  3. try {
  4. return node.isLocked();
  5. } catch (RepositoryException ex) {
  6. throw getRepositoryException(ex);
  7. }
  8. }

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

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

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

  1. private boolean isLocked() {
  2. try {
  3. final Node node = getModelObject();
  4. return node != null && node.isLocked();
  5. } catch (RepositoryException e) {
  6. log.error("An error occurred determining if node is locked.", e);
  7. return false;
  8. }
  9. }

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

  1. private boolean isLocked() {
  2. try {
  3. final Node node = getModelObject();
  4. return node != null && node.isLocked();
  5. } catch (RepositoryException e) {
  6. log.error("An error occurred determining if node is locked.", e);
  7. return false;
  8. }
  9. }

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

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

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

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

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

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

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

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

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

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

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

  1. public static boolean isLocked( final PentahoJcrConstants pentahoJcrConstants, final Node node )
  2. throws RepositoryException {
  3. Assert.notNull( node );
  4. if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
  5. // frozen nodes are never locked
  6. return false;
  7. }
  8. boolean locked = node.isLocked();
  9. if ( locked ) {
  10. Assert.isTrue( node.isNodeType( pentahoJcrConstants.getMIX_LOCKABLE() ) );
  11. }
  12. return locked;
  13. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void addLockTokenToSessionIfNecessary( final Session session, final PentahoJcrConstants pentahoJcrConstants,
  5. final Serializable fileId ) throws RepositoryException {
  6. Node fileNode = session.getNodeByIdentifier( fileId.toString() );
  7. if ( fileNode.isLocked() ) {
  8. LockManager lockManager = session.getWorkspace().getLockManager();
  9. Lock lock = lockManager.getLock( fileNode.getPath() );
  10. String lockToken = getLockToken( session, pentahoJcrConstants, lock );
  11. lockManager.addLockToken( lockToken );
  12. }
  13. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void removeLockTokenFromSessionIfNecessary( final Session session,
  5. final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId ) throws RepositoryException {
  6. Node fileNode = session.getNodeByIdentifier( fileId.toString() );
  7. if ( fileNode.isLocked() ) {
  8. LockManager lockManager = session.getWorkspace().getLockManager();
  9. Lock lock = lockManager.getLock( fileNode.getPath() );
  10. String lockToken = getLockToken( session, pentahoJcrConstants, lock );
  11. lockManager.removeLockToken( lockToken );
  12. }
  13. }

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

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

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

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

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

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

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

  1. public void execute(Session session, Node test) throws RepositoryException {
  2. Node n = test.addNode("test");
  3. n.addMixin(mixLockable);
  4. session.save();
  5. for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
  6. if (n.isLocked()) {
  7. n.unlock();
  8. }
  9. n.lock(false, true);
  10. }
  11. }
  12. }, CONCURRENCY);

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

  1. private void assertLocking( Session session, String path, boolean locked ) throws Exception {
  2. Node node = session.getNode(path);
  3. if (locked) {
  4. assertTrue(node.isLocked());
  5. assertTrue(node.hasProperty(JcrLexicon.LOCK_IS_DEEP.getString()));
  6. assertTrue(node.hasProperty(JcrLexicon.LOCK_OWNER.getString()));
  7. } else {
  8. assertFalse(node.isLocked());
  9. assertFalse(node.hasProperty(JcrLexicon.LOCK_IS_DEEP.getString()));
  10. assertFalse(node.hasProperty(JcrLexicon.LOCK_OWNER.getString()));
  11. }
  12. }

相关文章