Package org.apache.jackrabbit.vault.vlt

Examples of org.apache.jackrabbit.vault.vlt.VltDirectory


                dc.flush();
            }

            String path = PathUtil.getRelativeFilePath(ctx.getCwd().getPath(), localDir.getPath());
            ctx.printMessage("Checking out " + vaultFile.getPath() + " to " + path);
            VltDirectory dir = new VltDirectory(ctx, localDir);
            if (dir.isControlled()) {
                if (!force) {
                    throw dir.getContext().error(dir.getPath(), "already under vault control.");
                }
            } else {
                dir.control(vaultFile.getPath(), vaultFile.getAggregate().getPath());
            }
            ctx.setMountpoint(vaultFile.getAggregate().getManager().getMountpoint());
            // re-open parent dir to avoid problems with zip-meta-dirs
            dir = new VltDirectory(ctx, localDir);
            Update up = new Update(localDir, null, false);
            up.setOnlyControlled(true);
            up.setForce(force);
            dir.applyWithRemote(up, Collections.<String>emptyList(), false);
            ctx.printMessage("Checkout done.");
        } catch (IOException e) {
            throw new VltException(localDir.getPath(), "Error during checkout", e);
        } catch (RepositoryException e) {
            throw new VltException(remoteDir, "Error during checkout", e);
View Full Code Here


        FileAction action = file.add(force);
        dir.getContext().printAction(file, action);

        // if file is a directory, put under version control
        if (file.canDescend()) {
            VltDirectory child = file.descend();
            if (!child.isControlled()) {
                // this is a bit a hack
                child.control(dir.getEntries().getPath() + "/" + file.getName(), null);
            }
        }
    }
View Full Code Here

            dir = file.getParentFile();
        }
        String path = dir.getCanonicalPath();
        Info info = infos.get(path);
        if (info == null) {
            info = new Info(new VltDirectory(ctx, dir));
            infos.put(path, info);
        }
        if (file != null) {
            info.names.add(file.getName());
        }
View Full Code Here

            throw new VltException("Unable to commit changes.", e);
        }

        // get common ancestor
        String localRoot = infos.getRootPath();
        VltDirectory root = new VltDirectory(ctx, new File(localRoot));
        // mount fs at the top most directory
        if (root.isControlled()) {
            ctx.setFsRoot(root);
        }
        int rootLen = ctx.getFsRoot().length();

        // create transaction with all changes
        VaultFsTransaction tx = ctx.getFileSystem(ctx.getMountpoint()).startTransaction();
        ctx.printMessage("Collecting commit information...");
        for (VltTree.Info i: infos.infos()) {
            i.dir.prepareCommit(tx, i.names, nonRecursive, force);
        }

        // do commit (assuming all files from the same repo)
        ctx.printMessage("Transmitting file data...");
        List<TransactionImpl.Info> txInfos;
        try {
            txInfos = new ArrayList<TransactionImpl.Info>(tx.commit());
        } catch (Exception e) {
            throw new VltException("Error while committing", e);
        }
        // sort them deepest first
        Collections.sort(txInfos, new Comparator<TransactionImpl.Info>(){
            private final PathComparator pc = new PathComparator();
            public int compare(TransactionImpl.Info o1, TransactionImpl.Info o2) {
                return -pc.compare(o1.getPath(), o2.getPath());
            }
        });

        // updating entries
        infos.clear();
        for (TransactionImpl.Info info: txInfos) {
            if (info.getType() == TransactionImpl.Type.ERROR) {
                ctx.printMessage("Could not process " + info.getPath());
                continue;
            }
            String fileName = Text.getName(info.getPath());
            // get vlt directory
            String dirPath = Text.getRelativeParent(info.getPath(), 1);
            if (dirPath.length() > rootLen && !localRoot.endsWith(dirPath)) {
                // calculate the fs-root relative path, in case the repo was not mounted at jcr:root
                dirPath = dirPath.substring(rootLen + 1);
            } else if (dirPath.length() < rootLen) {
                // dir path outside of the mounted repo. special case
                dirPath = "";
                fileName = "";
            } else {
                dirPath = "";
            }
            File localDir = new File(localRoot, dirPath);
            if (!localDir.exists()) {
                // directory was already deleted, just print message and continue
                File file = new File(localDir, fileName);
                ctx.printAction(file.getPath(), FileAction.DELETED, null);
                continue;
            }

            VltDirectory dir = new VltDirectory(ctx, localDir);

            // check if local file is a directory
            File localFile = new File(localDir, fileName);
            if (localFile.isDirectory()) {
                dir = new VltDirectory(ctx, localFile);
            } else {
                dir.updateComitted(info.getPath(), fileName);
            }

            // remember directory
            infos.put(dir);
        }
View Full Code Here

    public Debug(File localDir) {
        this.localDir = localDir;
    }

    public void run(VltContext ctx) throws VltException {
        VltDirectory root = new VltDirectory(ctx, localDir);
        // mount fs at the top most directory
        if (root.isControlled()) {
            ctx.setFsRoot(root);
        }
        Session s = ctx.getFileSystem(ctx.getMountpoint()).getAggregateManager().getSession();
        byte[] buf = new byte[0x5000];
        try {
View Full Code Here

            }
        } catch (IOException e) {
            throw new VltException("Unable to perform command.", e);
        }
        // get common ancestor
        VltDirectory root = new VltDirectory(ctx, new File(infos.getRootPath()));
        // mount fs at the top most directory
        if (root.isControlled()) {
            ctx.setFsRoot(root);
        }
        // define globally ignored
        ctx.setGlobalIgnored(new Ignored(ctx, root.getDirectory()));

        run(ctx, infos);
    }
View Full Code Here

        }
        return this;
    }

    private void addIgnores(File dir, File file) throws VltException, IOException {
        VltDirectory d = new VltDirectory(ctx, dir);
        String root = d.getAggregatePath();
        if (root == null) {
            root = dir.getAbsolutePath().substring(rootLength);
            root = PlatformNameFormat.getRepositoryPath(root);
            log.info("Unable to detect correct repository path for {}. guessed: {}", dir.getPath(), root);
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.vlt.VltDirectory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.