Package org.apache.jackrabbit.vault.vlt

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


            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);
            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


            } else {
                infos.setDirsAsFiles(true);
                infos.addAll(localFiles);
            }
        } catch (IOException e) {
            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) {
View Full Code Here

                    break;
                case INIT:
                    init(ctx, s);
            }
        } catch (RepositoryException e) {
            throw new VltException("Error while performing command", e);
        } finally {
            if (s != null) {
                s.logout();
            }
        }
View Full Code Here

            ctx.getStdout().printf("Starting initialization of sync service in a non vlt checkout directory %s for %s%n",
                    localDir.getAbsolutePath(),
                    mountPoint);
            // check if empty
            if (localDir.listFiles().length > 0) {
                throw new VltException("Aborting initialization since directory is not empty.");
            }
            // check if config is present, assume installed
            Config cfg = new Config(s);
            if (!cfg.load(ctx)) {
                force = true;
View Full Code Here

                resource = url;
                break;
            }
        }
        if (resource == null) {
            throw new VltException("Unable to find vault-sync.jar library.");
        }
        String jarName = Text.getName(resource.getPath());
        ctx.getStdout().println("Preparing to install " + jarName + "...");

        Node root = s.getRootNode();
        for (String name: INSTALL_ROOT) {
            root = JcrUtils.getOrAddFolder(root, name);
        }
        // check if already a bundle is installed
        for (Node child: JcrUtils.getChildNodes(root)) {
            if (child.getName().startsWith("vault-sync-")) {
                if (force) {
                    ctx.getStdout().println("Detected existing bundle: " + child.getName() + ". Updating");
                    break;
                } else {
                    ctx.getStdout().println("Detected existing bundle: " + child.getName() + ". Aborting installation. Specify --force to update.");
                    return;
                }
            }
        }
        InputStream in = null;
        try {
            in = resource.openStream();
            if (root.hasNode(jarName)) {
                root.getNode(jarName).remove();
            }
            JcrUtils.putFile(root, jarName, "application/octet-stream", in, Calendar.getInstance());
        } catch (IOException e) {
            throw new VltException("Error while installing bundle", e);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
View Full Code Here

                infos.add(localDir);
            } else {
                infos.addAll(localFiles);
            }
        } 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()) {
View Full Code Here

    protected static XmlEntry load(Element elem)
            throws VltException {
        assert elem.getNodeName().equals(EN_ENTRY);
        String name = elem.getAttribute(AN_NAME);
        if (name == null) {
            throw new VltException("entry has no '" + AN_NAME + "' attribute");
        }
        String path = elem.hasAttribute(AN_PATH) ? elem.getAttribute(AN_PATH) : null;
        String ap = elem.hasAttribute(AN_AGGREGATE_PATH) ? elem.getAttribute(AN_AGGREGATE_PATH) : null;

        XmlEntry entry = new XmlEntry(name, ap, path);
View Full Code Here

                DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document = builder.parse(source);
            Element doc = document.getDocumentElement();
            if (!doc.getNodeName().equals(EN_ENTRIES)) {
                throw new VltException(source.getSystemId(), "<entries> expected.");
            }
            // get uri
            String path = doc.getAttribute(AN_PATH);
            XmlEntries entries = new XmlEntries(path);

            // get entries
            NodeList nodes = doc.getChildNodes();
            for (int i=0; i<nodes.getLength(); i++) {
                Node node = nodes.item(i);
                if (node instanceof Element) {
                    Element elem = (Element) node;
                    if (elem.getNodeName().equals(XmlEntry.EN_ENTRY)) {
                        XmlEntry entry = XmlEntry.load(elem);
                        entries.entries.put(entry.getName(), entry);
                    } else {
                        throw new VltException(source.getSystemId(),
                                "<entry> expected in <entries> element.");
                    }
                }
            }
            entries.dirty = false;
            return entries;
        } catch (ParserConfigurationException e) {
            throw new VltException(source.getSystemId(),
                    "Unable to create configuration XML parser", e);
        } catch (SAXException e) {
            throw new VltException(source.getSystemId(),
                    "Configuration file syntax error.", e);
        } catch (IOException e) {
            throw new VltException(source.getSystemId(),
                    "Configuration file could not be read.", e);
        }
    }
View Full Code Here

                    }
                }
            }
            return entries;
        } catch (IOException e) {
            throw new VltException("Error while reading entries.", e);
        }
    }
View Full Code Here

            throws VltException {
        Type type;
        try {
            type = Type.valueOf(elem.getNodeName().toUpperCase());
        } catch (IllegalArgumentException e) {
            throw new VltException("unknown entry type '" + elem.getNodeName() + "'");
        }
        XmlEntryInfo entry = new XmlEntryInfo(type);
        if (elem.hasAttribute(AN_NAME)) {
            entry.setName(elem.getAttribute(AN_NAME));
        }
View Full Code Here

TOP

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

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.