use of org.expath.pkg.repo.Repository in project exist by eXist-db.
the class ListFunction method eval.
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
ValueSequence result = new ValueSequence();
Optional<ExistRepository> repo = getContext().getRepository();
if (repo.isPresent()) {
try {
Repository parent_repo = repo.get().getParentRepo();
for (Packages pkg : parent_repo.listPackages()) {
String name = pkg.name();
result.add(new StringValue(name));
}
} catch (Exception ex) {
throw new XPathException("Problem listing packages in expath repository ", ex);
}
return result;
} else {
throw new XPathException("expath repository not available");
}
}
use of org.expath.pkg.repo.Repository 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;
}
Aggregations