Package org.apache.jackrabbit.vault.packaging

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


     * {@inheritDoc}
     */
    public void uninstall(ImportOptions opts) throws RepositoryException, PackageException, IOException {
        JcrPackage snap = getSnapshot();
        if (snap == null) {
            throw new PackageException("Unable to uninstall package. No snapshot present.");
        }
        if (opts.getListener() != null) {
            opts.getListener().onMessage(ProgressTrackerListener.Mode.TEXT, "Uninstalling package from snapshot " + snap.getDefinition().getId(), "");
        }
        Session s = getNode().getSession();
View Full Code Here


        if (ctx.getPhase() == InstallContext.Phase.INSTALLED) {
            try {
                ctx.getSession().getNode("/testroot").setProperty("TestHook", ctx.getPhase().toString());
                ctx.getSession().save();
            } catch (RepositoryException e) {
                throw new PackageException(e);
            }
        }
    }
View Full Code Here

                case PREPARE_FAILED:
                    doPrepareFailed(ctx);
                    break;
            }
        } catch (RepositoryException e) {
            throw new PackageException(e);
        }
    }
View Full Code Here

    private void doPrepare(InstallContext ctx) throws PackageException, RepositoryException {
        // read the properties from the package
        Properties props = ctx.getPackage().getMetaInf().getProperties();
        String copyFrom = props.getProperty(PROP_COPY_FROM, "");
        if (copyFrom.length() == 0) {
            throw new PackageException("hook-example needs " + PROP_COPY_FROM + " property set in properties.xml");
        }
        String copyTo = props.getProperty(PROP_COPY_TO, "");
        if (copyTo.length() == 0) {
            throw new PackageException("hook-example needs " + PROP_COPY_TO + " property set in properties.xml");
        }
        testNodePath = props.getProperty(PROP_TEST_NODE, "");
        if (testNodePath.length() == 0) {
            throw new PackageException("hook-example needs " + PROP_TEST_NODE + " property set in properties.xml");
        }
        copyTo += "_" + System.currentTimeMillis();
        ctx.getSession().getWorkspace().copy(copyFrom, copyTo);
        log.info("hook-example copied {} to {}", copyFrom, copyTo);
View Full Code Here

    public void execute(InstallContext context) throws PackageException {
        try {
            context.getSession().getNode("/testroot").setProperty("TestHook2", context.getPhase().toString());
            context.getSession().save();
        } catch (RepositoryException e) {
            throw new PackageException(e);
        }
    }
View Full Code Here

    public void execute(InstallContext context) throws PackageException {
        try {
            context.getSession().getNode("/testroot").setProperty("TestHook1", context.getPhase().toString());
            context.getSession().save();
        } catch (RepositoryException e) {
            throw new PackageException(e);
        }
    }
View Full Code Here

                while (names.hasMoreElements()) {
                    String name = names.nextElement().toString();
                    if (name.startsWith(VaultPackage.PREFIX_INSTALL_HOOK)) {
                        String[] segs = Text.explode(name.substring(VaultPackage.PREFIX_INSTALL_HOOK.length()), '.');
                        if (segs.length == 0 || segs.length > 2 || !segs[1].equals("class")) {
                            throw new PackageException("Invalid installhook property: " + name);
                        }
                        Hook hook = new Hook(segs[0], props.getProperty(name), classLoader);
                        initHook(hook);
                    }
                }
            }
        } catch (IOException e) {
            throw new PackageException("I/O Error while registering hooks", e);
        }
    }
View Full Code Here

            if (jarFile != null) {
                // open jar file and get manifest
                JarFile jar = new JarFile(jarFile);
                Manifest mf = jar.getManifest();
                if (mf == null) {
                    throw new PackageException("hook jar file does not have a manifest: " + name);
                }
                mainClassName = mf.getMainAttributes().getValue("Main-Class");
                if (mainClassName == null) {
                    throw new PackageException("hook manifest file does not have a Main-Class entry: " + name);
                }
                classLoader = URLClassLoader.newInstance(
                    new URL[]{jarFile.toURL()},
                    parentClassLoader);
            } else {
View Full Code Here

            // find main class
            Class clazz;
            try {
                clazz = classLoader.loadClass(mainClassName);
            } catch (ClassNotFoundException e) {
                throw new PackageException("hook's main class " + mainClassName + " not found: " + name, e);
            }
            if (!InstallHook.class.isAssignableFrom(clazz)) {
                throw new PackageException("hook's main class " + mainClassName + " does not implement the InstallHook interface: " + name);
            }
            // create instance
            try {
                hook = (InstallHook) clazz.newInstance();
            } catch (Exception e) {
                throw new PackageException("hook's main class " + mainClassName + " could not be instantiated.", e);
            }
        }
View Full Code Here

        }

        if (requiresRoot() || hooks.hasHooks()) {
            if (!AdminPermissionChecker.hasAdministrativePermissions(session)) {
                log.error("Package extraction requires admin session.");
                throw new PackageException("Package extraction requires admin session (userid not allowed).");
            }
        }

        Importer importer = new Importer(opts);
        AccessControlHandling ac = getACHandling();
        if (opts.getAccessControlHandling() == null) {
            opts.setAccessControlHandling(ac);
        }
        String cndPattern = getProperty(NAME_CND_PATTERN);
        if (cndPattern != null) {
            try {
                opts.setCndPattern(cndPattern);
            } catch (PatternSyntaxException e) {
                throw new PackageException("Specified CND pattern not valid.", e);
            }
        }

        return new InstallContextImpl(session.getRootNode(), this, importer, hooks);
    }
View Full Code Here

TOP

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

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.