当前位置: 首页>>代码示例>>Java>>正文


Java Lock类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:18,代码来源:RepositoryServiceImpl.java

示例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());
}
 
开发者ID:youseries,项目名称:urule,代码行数:24,代码来源:RepositoryServiceImpl.java

示例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());				
}
 
开发者ID:youseries,项目名称:urule,代码行数:36,代码来源:RepositoryServiceImpl.java

示例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();
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:5,代码来源:NodeImpl.java

示例5: getLock

import javax.jcr.lock.Lock; //导入依赖的package包/类
@Override
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
    throw new UnsupportedRepositoryOperationException();
}
 
开发者ID:TWCable,项目名称:jackalope,代码行数:5,代码来源:NodeImpl.java

示例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.
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:4,代码来源:RegistryVersionHistory.java

示例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.
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:4,代码来源:RegistryVersionHistory.java

示例8: getAllLocks

import javax.jcr.lock.Lock; //导入依赖的package包/类
private Map<String, Lock> getAllLocks() {
    return allLocks;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:4,代码来源:RegistryLockManager.java

示例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());

    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:6,代码来源:RegistryNode.java

示例10: getLock

import javax.jcr.lock.Lock; //导入依赖的package包/类
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {

        return registrySession.getWorkspace().getLockManager().getLock(nodePath);
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:5,代码来源:RegistryNode.java

示例11: getLock

import javax.jcr.lock.Lock; //导入依赖的package包/类
public Lock getLock(String s) throws PathNotFoundException, LockException, AccessDeniedException, RepositoryException {

        return allLocks.get(s);
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:5,代码来源:RegistryLockManager.java


注:本文中的javax.jcr.lock.Lock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。