private void loadMainClass(ClassLoader classLoader) throws PackageException, ClassNotFoundException { log.info("Loading Hook {}: Main-Class = {}", name, mainClassName); // find main class Class clazz = classLoader.loadClass(mainClassName); 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); } }
private void initHook(Hook hook) throws IOException, PackageException { try { hook.init(); } catch (IOException e) { log.error("Error while initializing hook: {}", e.toString()); hook.destroy(); throw e; } catch (PackageException e) { log.error("Error while initializing hook: {}", e.toString()); hook.destroy(); throw e; } hooks.put(hook.name, hook); log.info("Hook {} registered.", hook.name); }
response.getWriter().print(packageHelper.getErrorJSON(ex.getMessage())); } catch (RepositoryException ex) { log.error("Repository error while creating Instant Package", ex);
/** * Uninstallation not supported for FS based PackageRegistry */ @Override public void uninstallPackage(@Nonnull Session session, @Nonnull RegisteredPackage pkg, @Nonnull ImportOptions opts) throws IOException, PackageException { String msg = "Uninstallation not supported by FS based registry"; log.error(msg); throw new PackageException(msg); }
@Nonnull public ExecutionPlan execute() throws IOException, PackageException { if (isExecuted()) { log.warn("executing plan that was already executed."); return this; } for (PackageTask task: tasks) { if (task instanceof PackageTaskImpl) { ((PackageTaskImpl) task).execute(this); } else { throw new PackageException("task class " + task.getClass().getName() + " is not supported."); } } return this; }
for (TaskBuilder task: tasks) { if (task.id == null || task.type == null) { throw new PackageException("task builder must have package id and type defined.");
/** * {@inheritDoc} */ @Override public void installPackage(@Nonnull Session session, @Nonnull RegisteredPackage pkg, @Nonnull ImportOptions opts, boolean extract) throws IOException, PackageException { // For now FS based persistence only supports extraction but no reversible installation if (!extract) { String msg = "Only extraction supported by FS based registry"; log.error(msg); throw new PackageException(msg); } try (VaultPackage vltPkg = pkg.getPackage()) { vltPkg.extract(session, opts); dispatch(PackageEvent.Type.EXTRACT, pkg.getId(), null); updateInstallState(vltPkg.getId(), FSPackageStatus.EXTRACTED); } catch (RepositoryException e) { throw new IOException(e); } }
Manifest mf = jar.getManifest(); if (mf == null) { throw new PackageException("hook jar file does not have a manifest: " + name); throw new PackageException("hook manifest file does not have a Main-Class entry: " + name); throw new PackageException("hook's main class " + mainClassName + " not found: " + name, cnfe);
String[] segs = Text.explode(name.substring(VaultPackage.PREFIX_INSTALL_HOOK.length()), '.'); if (segs.length == 0 || segs.length > 2 || !"class".equals(segs[1])) { throw new PackageException("Invalid installhook property: " + name); throw new PackageException("I/O Error while registering hooks", e);
in = FileUtils.openInputStream(dst.getFile()); } catch (IOException e) { throw new PackageException(e);
@Nonnull @Override public ExecutionPlan execute() throws IOException, PackageException { if (plan == null) { validate(); } // check if session is present or if no task needs it if (session == null) { for (PackageTask task: plan.getTasks()) { if (task.getType() != PackageTask.Type.REMOVE) { throw new PackageException("Session not set in builder, but " + task + " task requires it."); } } } return plan.with(registry).with(session).with(listener).execute(); }
/** * {@inheritDoc} */ private void validateSubPackages(JcrPackageDefinitionImpl def) throws RepositoryException, PackageException { List<JcrPackage> subs = listPackages(def.getMetaInf().getFilter()); PackageId id = def.getId(); for (JcrPackage p: subs) { // check if not include itself if (p.getDefinition().getId().equals(id)) { throw new PackageException("A package cannot include itself. Check filter definition."); } if (!p.isSealed()) { throw new PackageException("Only sealed (built) sub packages allowed: " + p.getDefinition().getId()); } } }
in = FileUtils.openInputStream(pack.getFile()); } catch (IOException e) { throw new PackageException(e);
/** * Performs the removal. * @param plan the execution plan * @throws IOException if an I/O error occurs * @throws PackageException if a package error occurs */ private void doRemove(ExecutionPlanImpl plan) throws IOException, PackageException { try (RegisteredPackage pkg = plan.getRegistry().open(id)) { if (pkg == null) { throw new NoSuchPackageException("No such package: " + id); } if (pkg.isInstalled()) { throw new PackageException("refusing to remove installed package: " + id); } plan.getRegistry().remove(id); } }
throws PackageException, RepositoryException { if (!pack.isValid()) { throw new PackageException("Package is not valid."); throw new PackageException("Package definition not unwrapped."); throw new PackageException("Node at " + dstPath + " already exists.");
throw new PackageException("Errors during import.");
ctx.setPhase(InstallContext.Phase.PREPARE_FAILED); hooks.execute(ctx); throw new PackageException("Error while executing an install hook during prepare phase."); ctx.setPhase(InstallContext.Phase.INSTALL_FAILED); hooks.execute(ctx); throw new PackageException(e); ctx.setPhase(InstallContext.Phase.INSTALL_FAILED); hooks.execute(ctx); throw new PackageException("Error while executing an install hook during installed phase."); throw new PackageException("Errors during import.");
if (!AdminPermissionChecker.hasAdministrativePermissions(session)) { log.error("Package extraction requires admin session."); throw new PackageException("Package extraction requires admin session (userid not allowed)."); opts.setCndPattern(cndPattern); } catch (PatternSyntaxException e) { throw new PackageException("Specified CND pattern not valid.", e);
throw new PackageException("Package is not valid: " + packageId);
throw new PackageException("Unable to uninstall package. No snapshot present.");