本文整理匯總了Java中javax.jcr.lock.Lock類的典型用法代碼示例。如果您正苦於以下問題:Java Lock類的具體用法?Java Lock怎麽用?Java Lock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Lock類屬於javax.jcr.lock包,在下文中一共展示了Lock類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: unlockAllChildNodes
import javax.jcr.lock.Lock; //導入依賴的package包/類
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);
}
}
示例2: unlockPath
import javax.jcr.lock.Lock; //導入依賴的package包/類
@Override
public void unlockPath(String path,User user) throws Exception{
path = processPath(path);
int pos=path.indexOf(":");
if(pos!=-1){
path=path.substring(0,pos);
}
Node rootNode=getRootNode();
if (!rootNode.hasNode(path)) {
throw new RuleException("File [" + path + "] not exist.");
}
Node fileNode = rootNode.getNode(path);
String absPath=fileNode.getPath();
if(!lockManager.isLocked(absPath)){
throw new NodeLockException("當前文件未鎖定,不需要解鎖!");
}
Lock lock=lockManager.getLock(absPath);
String owner=lock.getLockOwner();
if(!owner.equals(user.getUsername())){
throw new NodeLockException("當前文件由【"+owner+"】鎖定,您無權解鎖!");
}
lockManager.unlock(lock.getNode().getPath());
}
示例3: lockPath
import javax.jcr.lock.Lock; //導入依賴的package包/類
@Override
public void lockPath(String path,User user) throws Exception{
path = processPath(path);
int pos=path.indexOf(":");
if(pos!=-1){
path=path.substring(0,pos);
}
Node rootNode=getRootNode();
if (!rootNode.hasNode(path)) {
throw new RuleException("File [" + path + "] not exist.");
}
Node fileNode = rootNode.getNode(path);
String topAbsPath=fileNode.getPath();
if(lockManager.isLocked(topAbsPath)){
String owner=lockManager.getLock(topAbsPath).getLockOwner();
throw new NodeLockException("【"+path+"】已被"+owner+"鎖定,您不能進行再次鎖定!");
}
List<Node> nodeList=new ArrayList<Node>();
unlockAllChildNodes(fileNode, user, nodeList, path);
for(Node node:nodeList){
if(!lockManager.isLocked(node.getPath())){
continue;
}
Lock lock=lockManager.getLock(node.getPath());
lockManager.unlock(lock.getNode().getPath());
}
if(!fileNode.isNodeType(NodeType.MIX_LOCKABLE)){
if (!fileNode.isCheckedOut()) {
versionManager.checkout(fileNode.getPath());
}
fileNode.addMixin("mix:lockable");
session.save();
}
lockManager.lock(topAbsPath, true, true, Long.MAX_VALUE, user.getUsername());
}
示例4: lock
import javax.jcr.lock.Lock; //導入依賴的package包/類
@Override
public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
throw new UnsupportedRepositoryOperationException();
}
示例5: getLock
import javax.jcr.lock.Lock; //導入依賴的package包/類
@Override
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
throw new UnsupportedRepositoryOperationException();
}
示例6: lock
import javax.jcr.lock.Lock; //導入依賴的package包/類
public Lock lock(boolean b, boolean b1) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
示例7: getLock
import javax.jcr.lock.Lock; //導入依賴的package包/類
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
示例8: getAllLocks
import javax.jcr.lock.Lock; //導入依賴的package包/類
private Map<String, Lock> getAllLocks() {
return allLocks;
}
示例9: lock
import javax.jcr.lock.Lock; //導入依賴的package包/類
public Lock lock(boolean b, boolean b1) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
return registrySession.getWorkspace().getLockManager().lock(nodePath, b, b1, 10, this.getName());
}
示例10: getLock
import javax.jcr.lock.Lock; //導入依賴的package包/類
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
return registrySession.getWorkspace().getLockManager().getLock(nodePath);
}
示例11: getLock
import javax.jcr.lock.Lock; //導入依賴的package包/類
public Lock getLock(String s) throws PathNotFoundException, LockException, AccessDeniedException, RepositoryException {
return allLocks.get(s);
}