Search in sources :

Example 1 with UserInteractionStrategy

use of org.expath.pkg.repo.UserInteractionStrategy in project exist by eXist-db.

the class RemoveFunction method eval.

public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    Sequence removed = BooleanValue.TRUE;
    boolean force = false;
    UserInteractionStrategy interact = new BatchUserInteraction();
    String pkg = args[0].getStringValue();
    try {
        Optional<ExistRepository> repo = getContext().getRepository();
        if (repo.isPresent()) {
            Repository parent_repo = repo.get().getParentRepo();
            parent_repo.removePackage(pkg, force, interact);
            repo.get().reportAction(ExistRepository.Action.UNINSTALL, pkg);
            context.getBroker().getBrokerPool().getXQueryPool().clear();
        } else {
            throw new XPathException("expath repository not available");
        }
    } catch (PackageException | XPathException pe) {
        return BooleanValue.FALSE;
    // /TODO: _repo.removePackage seems to throw PackageException
    // throw new XPathException("Problem removing package " + pkg + " in expath repository, check that eXist-db has access permissions to expath repository file directory  ", pe);
    }
    return removed;
}
Also used : Repository(org.expath.pkg.repo.Repository) ExistRepository(org.exist.repo.ExistRepository) UserInteractionStrategy(org.expath.pkg.repo.UserInteractionStrategy) XPathException(org.exist.xquery.XPathException) PackageException(org.expath.pkg.repo.PackageException) BatchUserInteraction(org.expath.pkg.repo.tui.BatchUserInteraction) ExistRepository(org.exist.repo.ExistRepository)

Aggregations

ExistRepository (org.exist.repo.ExistRepository)1 XPathException (org.exist.xquery.XPathException)1 PackageException (org.expath.pkg.repo.PackageException)1 Repository (org.expath.pkg.repo.Repository)1 UserInteractionStrategy (org.expath.pkg.repo.UserInteractionStrategy)1 BatchUserInteraction (org.expath.pkg.repo.tui.BatchUserInteraction)1