use of org.expath.pkg.repo.PackageException in project exist by eXist-db.
the class GetResource method eval.
@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
String pkgName = args[0].getStringValue();
String path = args[1].getStringValue();
Optional<ExistRepository> repo = context.getRepository();
if (repo.isPresent()) {
try {
for (Packages pp : repo.get().getParentRepo().listPackages()) {
final Package pkg = pp.latest();
if (pkg.getName().equals(pkgName)) {
try {
// FileSystemResolver already returns an input stream
StreamSource source = (StreamSource) pkg.getResolver().resolveResource(path);
return Base64BinaryDocument.getInstance(context, source.getInputStream());
} catch (Storage.NotExistException e) {
throw new XPathException(ErrorCodes.FODC0002, "Resource " + path + " does not exist.", e);
}
}
}
} catch (PackageException e) {
throw new XPathException(this, ErrorCodes.FOER0000, "Caught package error while reading expath package");
}
} else {
throw new XPathException("expath repository not available");
}
return Sequence.EMPTY_SEQUENCE;
}
use of org.expath.pkg.repo.PackageException in project exist by eXist-db.
the class ExistPkgExtension method parseDescriptor.
@Override
protected void parseDescriptor(XMLStreamReader parser, Package pkg) throws PackageException {
myXSHelper.ensureNextElement(parser, "package");
final ExistPkgInfo info = new ExistPkgInfo(pkg);
try {
parser.next();
while (parser.getEventType() == XMLStreamConstants.START_ELEMENT) {
if (EXIST_PKG_NS.equals(parser.getNamespaceURI())) {
handleElement(parser, pkg, info);
} else {
// TODO: FIXME: Actually ignore (pass it.)
throw new PackageException("TODO: Ignore elements in other namespace");
}
parser.next();
}
// position to </package>
parser.next();
} catch (final XMLStreamException ex) {
throw new PackageException("Error reading the exist descriptor", ex);
}
pkg.addInfo(getName(), info);
// phase though (during the "xrepo install").
if (!info.getJars().isEmpty()) {
try {
pkg.getResolver().resolveResource(".exist/classpath.txt");
} catch (final NotExistException ex) {
setupPackage(pkg, info);
}
}
}
Aggregations