ExistRepository repo = getContext().getRepository();
Repository parent_repo = repo.getParentRepo();
try {
Package pkg;
if (isCalledAs("install")) {
// download .xar from a URI
URI uri = _getURI(pkgOrPath);
pkg = parent_repo.installPackage(uri, force, interact);
repo.reportAction(ExistRepository.Action.INSTALL, pkg.getName());
} else {
// .xar is stored as a binary resource
BinaryDocument doc = null;
try {
doc = _getDocument(pkgOrPath);
File file = ((NativeBroker)context.getBroker()).getCollectionBinaryFileFsPath(doc.getURI());
LOG.debug("Installing file: " + file.getAbsolutePath());
pkg = parent_repo.installPackage(file, force, interact);
repo.reportAction(ExistRepository.Action.INSTALL, pkg.getName());
} finally {
if (doc != null)
doc.getUpdateLock().release(Lock.READ_LOCK);
}
}
ExistPkgInfo info = (ExistPkgInfo) pkg.getInfo("exist");
if (info != null && !info.getJars().isEmpty())
ClasspathHelper.updateClasspath(context.getBroker().getBrokerPool(), pkg);
// TODO: expath libs do not provide a way to see if there were any XQuery modules installed at all
context.getBroker().getBrokerPool().getXQueryPool().clear();
removed = BooleanValue.TRUE;