Package org.apache.jackrabbit.vault.fs.api

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


    public static void main(String[] args) throws RepositoryException, URISyntaxException, IOException {
        RepositoryAddress address = new RepositoryAddress("http://localhost:8080/server/root");
        Repository repo = new RepositoryProvider().getRepository(address);
        Session session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));

        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


    }

    public VaultFile getRemoteDirectory(VltContext ctx) throws VltException {
        assertControlled();
        try {
            VaultFileSystem fs = ctx.getFileSystem(ctx.getMountpoint());
            return fs.getFile(entries.getPath());
        } catch (IOException e) {
            throw new VltException("Unable to get remote directory.", e);
        } catch (RepositoryException e) {
            throw new VltException("Unable to get remote directory.", e);
        }
View Full Code Here

        return s;
    }

    public VaultFileSystem getFileSystem(RepositoryAddress mountpoint)
            throws VltException {
        VaultFileSystem fs = fileSystems.get(mountpoint);
        if (fs == null) {
            try {
                // check if export root already defines config and filter
                DefaultWorkspaceFilter filter = null;
                VaultFsConfig config = null;
View Full Code Here

        this.defaultFilter = defaultFilter;
    }

    public void close() {
        for (RepositoryAddress addr: fileSystems.keySet()) {
            VaultFileSystem fs = fileSystems.get(addr);
            try {
                fs.unmount();
            } catch (RepositoryException e) {
                log.warn("Error while unmounting fs.", e);
            }
        }
        fileSystems.clear();
View Full Code Here

                    addr = new RepositoryAddress(
                            Text.escapePath("/" + defNode.getSession().getWorkspace().getName() + rootPath));
                } catch (URISyntaxException e) {
                    throw new IllegalArgumentException(e);
                }
                VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, "/definition", defNode.getSession());
                exporter.setRelativePaths(true);
                exporter.setRootPath("");
                exporter.createDirectory(Constants.META_DIR + "/definition");
                exporter.export(jcrfs.getRoot(), Constants.META_DIR + "/definition");
                jcrfs.unmount();
            } catch (Exception e) {
                log.error("Error during post processing", e);
            } finally {
                try {
                    // revert removed properties
View Full Code Here

public class CmdDump extends AbstractJcrFsCommand {

    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
            throws Exception {
        String path = (String) cl.getValue(argPath);
        VaultFileSystem fs = ctx.getVaultFsApp().getVaultFileSystem();
        if (fs == null) {
            VaultFsApp.log.info("Not mounted.");
        } else if (path != null && !path.equals("")) {
            if (cl.hasOption(optConfig) || cl.hasOption(optFilter)) {
                ConsoleFile f = ctx.getCurrentFile();
                File file;
                if (f instanceof PlatformFile) {
                    f = f.getFile(path, false);
                    file = (File) f.unwrap();
                } else {
                    file = ctx.getVaultFsApp().getPlatformFile(path, false);
                }
                if (cl.hasOption(optConfig)) {
                    IOUtils.copy(
                        fs.getConfig().getSource(),
                        FileUtils.openOutputStream(file)
                    );
                    VaultFsApp.log.info("VaultFs config written to {}", file.getPath());
                } else {
                    IOUtils.copy(
                        fs.getWorkspaceFilter().getSource(),
                        FileUtils.openOutputStream(file)
                    );
                    VaultFsApp.log.info("VaultFs workspace filter written to {}", file.getPath());
                }
            } else {
                Object f = ctx.getCurrentFile().getFile(path, false).unwrap();
                if (f instanceof Dumpable) {
                    DumpContext dCtx = new DumpContext(new PrintWriter(System.out));
                    ((Dumpable) f).dump(dCtx, true);
                    dCtx.flush();
                } else {
                    VaultFsApp.log.info("Object not dumpable: {}", f);
                }
            }
        } else {
            fs.getAggregateManager().dumpConfig(new PrintWriter(System.out));
        }
    }
View Full Code Here

        }
        MetaInf metaInf = opts.getMetaInf();
        if (metaInf == null) {
            metaInf = new DefaultMetaInf();
        }
        VaultFileSystem jcrfs = Mounter.mount(metaInf.getConfig(), metaInf.getFilter(), addr, opts.getRootPath(), s);
        JarExporter exporter = new JarExporter(out);
        exporter.setProperties(metaInf.getProperties());
        if (opts.getListener() != null) {
            exporter.setVerbose(opts.getListener());
        }
        if (opts.getPostProcessor() != null) {
            exporter.export(jcrfs.getRoot(), true);
            opts.getPostProcessor().process(exporter);
            exporter.close();
        } else {
            exporter.export(jcrfs.getRoot());
        }
        jcrfs.unmount();
    }
View Full Code Here

                    addr = new RepositoryAddress(
                            Text.escapePath("/" + defNode.getSession().getWorkspace().getName() + rootPath));
                } catch (URISyntaxException e) {
                    throw new IllegalArgumentException(e);
                }
                VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, "/definition", defNode.getSession());
                exporter.setRelativePaths(true);
                exporter.setRootPath("");
                exporter.createDirectory(Constants.META_DIR + "/definition");
                exporter.export(jcrfs.getRoot(), Constants.META_DIR + "/definition");
                jcrfs.unmount();
            } catch (Exception e) {
                log.error("Error during post processing", e);
            } finally {
                try {
                    // revert removed properties
View Full Code Here

        return s;
    }

    public VaultFileSystem getFileSystem(RepositoryAddress mountpoint)
            throws VltException {
        VaultFileSystem fs = fileSystems.get(mountpoint);
        if (fs == null) {
            try {
                // check if export root already defines config and filter
                DefaultWorkspaceFilter filter = null;
                VaultFsConfig config = null;
View Full Code Here

        this.defaultFilter = defaultFilter;
    }

    public void close() {
        for (RepositoryAddress addr: fileSystems.keySet()) {
            VaultFileSystem fs = fileSystems.get(addr);
            try {
                fs.unmount();
            } catch (RepositoryException e) {
                log.warn("Error while unmounting fs.", e);
            }
        }
        fileSystems.clear();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.fs.api.VaultFileSystem

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.