Java Code Examples for javax.jcr.Node#isCheckedOut()

The following examples show how to use javax.jcr.Node#isCheckedOut() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryServiceImpl.java    From urule with Apache License 2.0 5 votes vote down vote up
@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());				
}
 
Example 2
Source File: RepositoryServiceImpl.java    From urule with Apache License 2.0 5 votes vote down vote up
public void deleteFile(String path,User user) throws Exception{
	if(!permissionService.fileHasWritePermission(path)){
		throw new NoPermissionException();
	}
	repositoryInteceptor.deleteFile(path);
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	String[] subpaths = path.split("/");
	Node fileNode = rootNode;
	for (String subpath : subpaths) {
		if (StringUtils.isEmpty(subpath)) {
			continue;
		}
		String subDirs[] = subpath.split("\\.");
		for (String dir : subDirs) {
			if (StringUtils.isEmpty(dir)) {
				continue;
			}
			if (!fileNode.hasNode(dir)) {
				continue;
			}
			fileNode = fileNode.getNode(dir);
			lockCheck(fileNode,user);
			if (!fileNode.isCheckedOut()) {
				versionManager.checkout(fileNode.getPath());
			}
		}
	}
	fileNode = rootNode.getNode(path);
	lockCheck(fileNode,user);
	if (!fileNode.isCheckedOut()) {
		versionManager.checkout(fileNode.getPath());
	}
	fileNode.remove();
	session.save();
}
 
Example 3
Source File: NodeNameList.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
public boolean restoreOrder(Node parent) throws RepositoryException {
    // assume needsReorder check is performed
    // quick check if node is checked out
    if (!parent.isCheckedOut()) {
        log.warn("Unable to restore order of a checked-in node: " + parent.getPath());
        return false;
    }
    int size = names.size();
    String last = null;
    ArrayList<String> list = new ArrayList<String>(names);
    ListIterator<String> iter = list.listIterator(size);
    while (iter.hasPrevious()) {
        String prev = iter.previous();
        if (parent.hasNode(prev)) {
            log.trace("ordering {} before {}", prev, last);
            try {
                parent.orderBefore(prev, last);
            } catch (Exception e) {
                // probably an error in jcr2spi
                String path = parent.getPath() + "/" + prev;
                log.warn("Ignoring unexpected error during reorder of {}: {}", path, e.toString());
            }
            last = prev;
        }
    }
    return true;
}
 
Example 4
Source File: FolderArtifactHandler.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
private void ensureCheckedOut(Node node, ImportInfoImpl info) throws RepositoryException {
    boolean isCheckedOut = !node.isNodeType(JcrConstants.MIX_VERSIONABLE) || node.isCheckedOut();
    if (!isCheckedOut) {
        info.registerToVersion(node.getPath());
        try {
            node.checkout();
        } catch (RepositoryException e) {
            info.log.warn("error while checkout node (ignored)", e);
        }
    }
}
 
Example 5
Source File: DocViewSAXImporter.java    From jackrabbit-filevault with Apache License 2.0 4 votes vote down vote up
private VersioningState(StackElement stack, Node node) throws RepositoryException {
    this.stack = stack;
    this.node = node;
    isCheckedOut = node == null || !node.isNodeType(JcrConstants.MIX_VERSIONABLE) || node.isCheckedOut();
    isParentCheckedOut = stack.isCheckedOut();
}
 
Example 6
Source File: DocViewSAXImporter.java    From jackrabbit-filevault with Apache License 2.0 4 votes vote down vote up
public StackElement(Node node, boolean isNew) throws RepositoryException {
    this.node = node;
    this.isNew = isNew;
    isCheckedOut = node == null || !node.isNodeType(JcrConstants.MIX_VERSIONABLE) || node.isCheckedOut();
}