Package org.apache.jackrabbit.vault.packaging

Examples of org.apache.jackrabbit.vault.packaging.JcrPackageDefinition


        }
        if (!PackageId.isValid(group, name, version)) {
            throw new RepositoryException("Unable to rename package. Illegal package name.");
        }

        JcrPackageDefinition def = pack.getDefinition();
        PackageId id = def.getId();
        PackageId newId = new PackageId(
                group == null ? id.getGroup() : group,
                name == null ? id.getName() : name,
                version == null ? id.getVersion() : Version.create(version)
        );
        String dstPath = newId.getInstallationPath() + ".zip";
        if (id.equals(newId) && pack.getNode().getPath().equals(dstPath)) {
            log.info("Package id not changed. won't rename.");
            return pack;
        }
        def.setId(newId, false);

        // only move if not already at correct location
        if (!pack.getNode().getPath().equals(dstPath)) {
            if (session.nodeExists(dstPath)) {
                throw new PackageException("Node at " + dstPath + " already exists.");
View Full Code Here


                    continue;
                }
                JcrPackageImpl pack = new JcrPackageImpl(child);
                if (pack.isValid()) {
                    // skip packages with illegal names
                    JcrPackageDefinition jDef = pack.getDefinition();
                    if (jDef != null && !jDef.getId().isValid()) {
                        continue;
                    }
                    if (filter == null || filter.contains(child.getPath())) {
                        if (!built || pack.getSize() > 0) {
                            packages.add(pack);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public int compareTo(JcrPackage o) {
        try {
            JcrPackageDefinition d1 = getDefinition();
            JcrPackageDefinition d2 = o.getDefinition();
            return d1.getId().compareTo(d2.getId());
        } catch (Exception e) {
            log.error("error during compare: {}", e.toString());
            return 0;
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean isInstalled() throws RepositoryException {
        JcrPackageDefinition def = getDefinition();
        return def != null && def.getLastUnpacked() != null;
    }
View Full Code Here

            throws RepositoryException, IOException {
        Node node = parent.addNode(Text.getName(pid.getInstallationPath() + ".zip"), JcrConstants.NT_FILE);
        Node content = node.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
        content.addMixin(NT_VLT_PACKAGE);
        Node defNode = content.addNode(NN_VLT_DEFINITION);
        JcrPackageDefinition def = new JcrPackageDefinitionImpl(defNode);
        def.set(JcrPackageDefinition.PN_NAME, pid.getName(), false);
        def.set(JcrPackageDefinition.PN_GROUP, pid.getGroup(), false);
        def.set(JcrPackageDefinition.PN_VERSION, pid.getVersionString(), false);
        def.touch(null, false);
        content.setProperty(JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance());
        content.setProperty(JcrConstants.JCR_MIMETYPE, MIME_TYPE);
        InputStream in = new ByteArrayInputStream(new byte[0]);
        try {
            if (pack != null && pack.getFile() != null) {
                in = FileUtils.openInputStream(pack.getFile());
            }
            // stay jcr 1.0 compatible
            //noinspection deprecation
            content.setProperty(JcrConstants.JCR_DATA, in);
            if (pack != null) {
                def.unwrap(pack, true, false);
            }
            if (autoSave) {
                parent.save();
            }
        } finally {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public boolean verifyId(boolean autoFix, boolean autoSave) throws RepositoryException {
        // check if package id is correct
        JcrPackageDefinition jDef = getDefinition();
        if (jDef == null) {
            return true;
        }
        PackageId id = jDef.getId();
        PackageId cId = new PackageId(node.getPath());
        // compare installation paths since non-conform version numbers might
        // lead to different pids (bug #35564)
        if (id.getInstallationPath().equals(cId.getInstallationPath())) {
            if (autoFix && id.isFromPath()) {
                // if definition has no id set, fix anyways
                jDef.setId(cId, autoSave);
            }
            return true;
        }
        if (autoFix) {
            log.warn("Fixing non-matching id from {} to {}.", id, cId);
            jDef.setId(cId, autoSave);
        }
        return false;
    }
View Full Code Here

        Node content = getContent();
        boolean ok = false;
        try {
            content.addMixin(NT_VLT_PACKAGE);
            Node defNode = content.addNode(NN_VLT_DEFINITION);
            JcrPackageDefinition def = new JcrPackageDefinitionImpl(defNode);
            def.unwrap(pack, true, false);
            node.save();
            ok = true;
        } finally {
            if (!ok) {
                try {
View Full Code Here

            throw new PackageException("Package is not valid.");
        }
        if (pack.getSize() > 0 && !pack.getDefinition().isUnwrapped()) {
            throw new PackageException("Package definition not unwrapped.");
        }
        JcrPackageDefinition def = pack.getDefinition();
        PackageId id = def.getId();
        PackageId newId = new PackageId(
                group == null ? id.getGroup() : group,
                name == null ? id.getName() : name,
                version == null ? id.getVersion() : Version.create(version)
        );
        String dstPath = newId.getInstallationPath() + ".zip";
        if (id.equals(newId) && pack.getNode().getPath().equals(dstPath)) {
            log.info("Package id not changed. won't rename.");
            return pack;
        }
        def.setId(newId, false);

        // only move if not already at correct location
        if (!pack.getNode().getPath().equals(dstPath)) {
            if (session.nodeExists(dstPath)) {
                throw new PackageException("Node at " + dstPath + " already exists.");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.packaging.JcrPackageDefinition

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.