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

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

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

Lock.getLockOwner介绍

[英]Returns the value of the jcr:lockOwner property. This is either the client supplied owner information (see LockManager#lock(String,boolean,boolean,long,String)), an implementation-dependent string identifying the user who either created the lock or who is bound to the session holding the lock, or null if none of these are available. The lock owner's identity is only provided for informational purposes. It does not govern who can perform an unlock or make changes to the locked nodes; that depends entirely upon who the token holder is.
[中]返回jcr:lockOwner属性的值。这是客户机提供的所有者信息(请参阅LockManager#lock(String,boolean,boolean,long,String)),一个依赖于实现的字符串,用于标识创建锁或绑定到持有锁的会话的用户,或者null,如果这些都不可用。锁所有者的身份仅供参考。它不控制谁可以对锁定的节点执行解锁或进行更改;这完全取决于代币持有者是谁。

代码示例

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

@Override
public String getLockOwner() {
  synchronized (session) {
    return lock.getLockOwner();
  }
}

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

/**
 * @see ActiveLock#getOwner()
 */
public String getOwner() {
  return lock.getLockOwner();
}

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

/** {@inheritDoc} */
public String getLockOwner() throws RemoteException {
  return lock.getLockOwner();
}

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

@Override
public String getLockOwner() {
  return delegate.getLockOwner();
}

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

public String getLockOwner() {
  return lock.getLockOwner();
}

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

public String getLockOwner() {
  return lock.getLockOwner();
}

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

@Override
public String getLockOwner( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 String[] tokens = tokenize( lock.getLockOwner() );
 if ( tokens != null ) {
  return unescape( tokens[POSITION_LOCK_OWNER] );
 }
 // return whatever the implementation stored in this property
 return lock.getLockOwner();
}

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

@Override
public Date getLockDate( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 String[] tokens = tokenize( lock.getLockOwner() );
 if ( tokens != null ) {
  long date;
  try {
   date = Long.parseLong( tokens[POSITION_LOCK_DATE] );
   return new Date( date );
  } catch ( NumberFormatException e ) {
   logger.debug( "could not parse lock date; returning null", e ); //$NON-NLS-1$
  }
 }
 return null;
}

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

@Override
public String getLockMessage( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
 throws RepositoryException {
 String[] tokens = tokenize( lock.getLockOwner() );
 if ( tokens != null ) {
  return unescape( tokens[POSITION_LOCK_MESSAGE] );
 }
 return null;
}

代码示例来源:origin: com.bstek.urule/urule-console

private void lockCheck(Node node,User user) throws Exception{
  if(lockManager.isLocked(node.getPath())){
    String lockOwner=lockManager.getLock(node.getPath()).getLockOwner();
    if(lockOwner.equals(user.getUsername())){
      return;
    }
    throw new NodeLockException("【"+node.getName()+"】已被"+lockOwner+"锁定!");
  }
}

代码示例来源:origin: com.bstek.urule/urule-console

private void unlockAllChildNodes(Node node,User user,List<Node> nodeList,String rootPath) throws Exception{
  NodeIterator iter=node.getNodes();
  while(iter.hasNext()){
    Node nextNode=iter.nextNode();
    String absPath=nextNode.getPath();
    if(!lockManager.isLocked(absPath)){
      continue;
    }
    Lock lock=lockManager.getLock(absPath);
    String owner=lock.getLockOwner();
    if(!user.getUsername().equals(owner)){
      throw new NodeLockException("当前目录下有子目录被其它人锁定,您不能执行锁定"+rootPath+"目录");
    }
    nodeList.add(nextNode);
    unlockAllChildNodes(nextNode, user, nodeList, rootPath);
  }
}

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

/**
 * Test expiration of the lock
 */
public synchronized void testOwnerHint()
    throws RepositoryException, NotExecutableException {
  lockedNode.unlock();
  lock = lockMgr.lock(lockedNode.getPath(), isDeep(), isSessionScoped(), Long.MAX_VALUE, "test");
  String owner = lock.getLockOwner();
  if (!"test".equals(lock.getLockOwner())) {
    throw new NotExecutableException();
  } else {
    assertTrue(lockedNode.hasProperty(Property.JCR_LOCK_OWNER));
    assertEquals("test", lockedNode.getProperty(Property.JCR_LOCK_OWNER).getString());
  }
}

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

/**
 * Test if getLockOwner() returns the same value as returned by
 * Session.getUserId at the time that the lock was placed
 */
public void testGetLockOwner() throws Exception {
  // create new node and lock it
  Node n1 = testRootNode.addNode(nodeName1, testNodeType);
  ensureMixinType(n1, mixLockable);
  testRootNode.getSession().save();
  // lock node
  Lock lock = n1.lock(false, true);
  assertEquals("getLockOwner() must return the same value as returned " +
      "by Session.getUserId at the time that the lock was placed",
      testRootNode.getSession().getUserID(),
      lock.getLockOwner());
  n1.unlock();
}

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

public void testNullOwnerHint() throws RepositoryException,
    NotExecutableException {
  assertLockable(testNode);
  Lock l = lockMgr.lock(testPath, true, true, Long.MAX_VALUE, null);
  assertNotNull(l.getLockOwner());
}

代码示例来源:origin: com.bstek.urule/urule-console

private void buildNodeLockInfo(Node node,RepositoryFile file) throws Exception{
  String absPath=node.getPath();
  if(!lockManager.isLocked(absPath)){
    return;
  }
  String owner=lockManager.getLock(absPath).getLockOwner();
  file.setLock(true);
  file.setLockInfo("被"+owner+"锁定");
}

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

/**
 * Test if getLockOwner() returns the same value as returned by
 * Session.getUserId at the time that the lock was placed
 */
public void testGetLockOwnerProperty() throws Exception {
  // create new node and lock it
  Node n1 = testRootNode.addNode(nodeName1, testNodeType);
  ensureMixinType(n1, mixLockable);
  testRootNode.getSession().save();
  // lock node
  Lock lock = n1.lock(false, true);
  if (n1.getSession().getUserID() == null) {
    assertFalse("jcr:lockOwner must not exist if Session.getUserId() returns null",
        n1.hasProperty(jcrLockOwner));
  } else {
    assertEquals("getLockOwner() must return the same value as stored " +
        "in property " + jcrLockOwner + " of the lock holding " +
        "node",
        n1.getProperty(jcrLockOwner).getString(),
        lock.getLockOwner());
  }
  n1.unlock();
}

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

/**
 * Throws {@link LockedException} id node is locked so alter nopde cannot be
 * done
 *
 * @param absPath
 *            abs path to node
 * @throws RepositoryException
 * @throws LockedException
 *             if node is locked
 */
protected void checkIfNodeLocked(final String absPath) throws RepositoryException, LockedException {
  Node node = getNode(absPath);
  // Node can hold nock or can be locked with precedencor
  if (node.isLocked()) {
    javax.jcr.lock.Lock lock = node.getLock();
    String lockOwner = lock.getLockOwner();
    if (!session.getUserID().equals(lockOwner)) {
      final String path = lock.getNode().getPath();
      throw new LockedException(lockOwner, path);
    }
  }
}

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

/**
 * Throws {@link LockedException} id node is locked so alter nopde cannot be
 * done
 *
 * @param absPath
 *            abs path to node
 * @throws RepositoryException
 * @throws LockedException
 *             if node is locked
 */
protected void checkIfNodeLocked(final String absPath) throws RepositoryException, LockedException {
  Node node = getNode(absPath);
  // Node can hold lock or can be locked with precedencor
  if (node.isLocked()) {
    javax.jcr.lock.Lock lock = getLockManager().getLock(absPath);
    String lockOwner = lock.getLockOwner();
    if (!session.getUserID().equals(lockOwner)) {
      final String path = lock.getNode().getPath();
      throw new LockedException(lockOwner, path);
    }
  }
}

代码示例来源: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

/**
 * 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()));
}

相关文章