Examples of VaultFile


Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

     * @throws IOException
     * @throws RepositoryException
     */
    private List<Aggregate> findAggregateChain(ResourceProxy resource) throws IOException, RepositoryException {

        VaultFile vaultFile = fs.getFile(PlatformNameFormat.getPlatformPath(resource.getPath()));

        if (vaultFile == null || vaultFile.getAggregate() == null) {
                // this file might be a leaf aggregate of a vaultfile higher in the resource path ; so look for a
                // parent higher

            String parentPath = Text.getRelativeParent(resource.getPath(), 1);
            while (!parentPath.equals("/")) {
                VaultFile parentFile = fs.getFile(PlatformNameFormat.getPlatformPath(parentPath));

                if (parentFile != null) {
                    Aggregate parentAggregate = parentFile.getAggregate();
                    ArrayList<Aggregate> parents = new ArrayList<Aggregate>();
                    parents.add(parentAggregate);
                    List<Aggregate> chain = lookForAggregateInLeaves(resource, parentAggregate, parents);
                    if (chain != null) {
                        return chain;
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

        VaultFileSystem fs = Mounter.mount(null, null, address, "/", session);

        String[] attempts = new String[] { "/rep:policy", "/var" };

        for (String attempt : attempts) {
            VaultFile vaultFile = fs.getFile(attempt);

            System.out.println(attempt + " -> " + vaultFile);
        }

        for (String attempt : attempts) {

            attempt = PlatformNameFormat.getPlatformPath(attempt) + EXTENSION_XML;

            VaultFile vaultFile = fs.getFile(attempt);

            System.out.println(attempt + " -> " + vaultFile);
        }

    }
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

        }
        try {
            if (remoteDir == null) {
                remoteDir = "/";
            }
            VaultFile vaultFile = ctx.getFileSystem(mountPoint).getFile(remoteDir);
            if (vaultFile == null) {
                throw new VltException(remoteDir, "Error during checkout. Remote directory does not exit.");
            }
            // store filter and config
            if (!force) {
                DefaultMetaInf inf = (DefaultMetaInf) ctx.getMetaInf();
                inf.setConfig(vaultFile.getFileSystem().getConfig());
                inf.setFilter(vaultFile.getFileSystem().getWorkspaceFilter());
                inf.save(ctx.getExportRoot().getMetaDir());
            }
            if (ctx.isVerbose()) {
                DumpContext dc = new DumpContext(new PrintWriter(ctx.getStdout()));
                dc.println("Filter");
                ctx.getMetaInf().getFilter().dump(dc, true);
                dc.outdent();
                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);
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

    public void prepareCommit(VaultFsTransaction tx, Collection<String> names,
                              boolean nonRecursive, boolean force)
            throws VltException {
        assertControlled();
        VaultFile remoteDir = getRemoteDirectory(ctx);
        if (remoteDir == null) {
            throw ctx.error(getPath(), "Remote directory does not exist.");
        }
        if (names.isEmpty()) {
            // add all files in this directory
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

    }

    public void updateComitted(String path, String fileName) throws VltException {
        assertControlled();
        VltFile file = files().getFile(fileName);
        VaultFile remote;
        try {
            VaultFile rd = getRemoteDirectory(ctx);
            remote = rd == null ? null : rd.getChild(fileName);
        } catch (RepositoryException e) {
            throw ctx.exception(dir.getPath(), "Error while retrieving remote directory.", e);
        }
        if (file == null && remote == null) {
            // removed and file gone
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

    }

    private void prepareCommit(VaultFsTransaction tx, VaultFile remoteDir,
                               VltFile file, boolean nonRecursive, boolean force)
            throws VltException {
        VaultFile remoteFile;
        try {
            remoteFile = remoteDir == null
                    ? null
                    : remoteDir.getChild(file.getName());
        } catch (RepositoryException e) {
            throw ctx.exception(file.getPath(), "Error while retrieving status", e);
        }

        if (file.status(remoteFile) != FileAction.VOID && !force) {
            throw ctx.error(file.getPath(), "Some files need to be updated first." +
                    " Specify --force to overwrite remote files.");
        }
        try {
            switch (file.getStatus()) {
                case MODIFIED:
                    FileInputSource fis = new FileInputSource(file.getFile());
                    if (file.isBinary()) {
                        fis.setLineSeparator(LineOutputStream.LS_BINARY);
                    }
                    tx.modify(remoteFile, fis);
                    ctx.printMessage("sending....", file);
                    break;
                case DELETED:
                    tx.delete(remoteFile);
                    ctx.printMessage("deleting...", file);
                    break;
                case ADDED:
                    String path = this.getEntries().getPath();
                    if (path.endsWith("/")) {
                        path += file.getName();
                    } else {
                        path += "/" + file.getName();
                    }
                    if (file.canDescend()) {
                        tx.mkdir(path);
                    } else {
                        fis = new FileInputSource(file.getFile());
                        if (file.isBinary()) {
                            fis.setLineSeparator(LineOutputStream.LS_BINARY);
                        }
                        VaultFileOutput out = tx.add(path, fis);
                        // set the content type hint
                        out.setContentType(file.getContentType());
                    }
                    ctx.printMessage("adding.....", file);
                    break;
                default:
                    // ignore
            }
        } catch (IOException e) {
            ctx.exception(file.getPath(), "Error while preparing commit.", e);
        } catch (RepositoryException e) {
            ctx.exception(file.getPath(), "Error while preparing commit.", e);
        }

        if (file.canDescend() && !nonRecursive) {
            VltDirectory dir = file.descend();
            if (dir.isControlled()) {
                // add all files in this directory
                VaultFile remDir = dir.getRemoteDirectory(ctx);
                for (VltFile child: dir.getFiles()) {
                    dir.prepareCommit(tx, remDir, child, nonRecursive, force);
                }
                dir.saveEntries();
            }
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

            }
        } else {
            try {
                for (String name: names) {
                    VltFile file = files.getFile(name);
                    VaultFile remoteFile = remoteDir.getChild(name);
                    applyWithRemote(action, file, remoteFile, nonRecursive);
                }
            } catch (RepositoryException e) {
                throw new VltException("Error while retrieving file.", e);
            }
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

        String jcrPath = (String) cl.getValue(argJcrPath);
        String name = (String) cl.getValue(argLocalPath);

        ConsoleFile wo = ctx.getFile(jcrPath, true);
        if (wo instanceof VaultFsCFile) {
            VaultFile file = (VaultFile) wo.unwrap();
            if (name == null) {
                name = file.getName();
            }
            File local = ctx.getVaultFsApp().getPlatformFile(name, false);
            doGet(file, local, forced);
        } else {
            throw new ExecutionException("'get' only possible in jcr fs context");
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

                throw new ExecutionException("getRelated. needs path argument.");
            }
            String path = (String) args.get(0);
            ConsoleFile wo = ctx.getFile(path, true);
            if (wo instanceof VaultFsCFile) {
                VaultFile file = (VaultFile) wo.unwrap();
                Collection<? extends VaultFile> related = file.getRelated();
                if (related == null) {
                    System.out.println("(null)");                   
                } else {
                    for (VaultFile f: related) {
                        System.out.println(f.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.api.VaultFile

    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
        String jcrPath = (String) cl.getValue(argJcrPath);

        ConsoleFile wo = ctx.getFile(jcrPath, true);
        if (wo instanceof VaultFsCFile) {
            VaultFile file = (VaultFile) wo.unwrap();
            file.invalidate();
        } else {
            throw new ExecutionException("'cat' only possible in jcr fs context");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.