Sequence removed = BooleanValue.FALSE;
boolean force = true;
UserInteractionStrategy interact = new BatchUserInteraction();
String pkgOrPath = args[0].getStringValue();
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);
}
}