use of org.expath.pkg.repo.XarSource in project exist by eXist-db.
the class Deploy method installAndDeploy.
private Optional<String> installAndDeploy(final Txn transaction, final String pkgName, final String version, final String repoURI) throws XPathException {
try {
final RepoPackageLoader loader = new RepoPackageLoader(repoURI);
final Deployment deployment = new Deployment();
final XarSource xar = loader.load(pkgName, new PackageLoader.Version(version, false));
if (xar != null) {
return deployment.installAndDeploy(context.getBroker(), transaction, xar, loader);
}
return Optional.empty();
} catch (final MalformedURLException e) {
throw new XPathException(this, EXPathErrorCode.EXPDY005, "Malformed URL: " + repoURI);
} catch (final PackageException | IOException e) {
LOG.error(e.getMessage(), e);
throw new XPathException(this, EXPathErrorCode.EXPDY007, e.getMessage());
}
}
use of org.expath.pkg.repo.XarSource in project exist by eXist-db.
the class Deploy method installAndDeployFromDb.
private Optional<String> installAndDeployFromDb(final Txn transaction, final String path, final String repoURI) throws XPathException {
final XmldbURI docPath = XmldbURI.createInternal(path);
try (final LockedDocument lockedDoc = context.getBroker().getXMLResource(docPath, LockMode.READ_LOCK)) {
if (lockedDoc == null) {
throw new XPathException(this, EXPathErrorCode.EXPDY001, path + " no such .xar", new StringValue(path));
}
final DocumentImpl doc = lockedDoc.getDocument();
if (doc.getResourceType() != DocumentImpl.BINARY_FILE) {
throw new XPathException(this, EXPathErrorCode.EXPDY001, path + " is not a valid .xar", new StringValue(path));
}
RepoPackageLoader loader = null;
if (repoURI != null) {
loader = new RepoPackageLoader(repoURI);
}
final XarSource xarSource = new BinaryDocumentXarSource(context.getBroker().getBrokerPool(), transaction, (BinaryDocument) doc);
final Deployment deployment = new Deployment();
return deployment.installAndDeploy(context.getBroker(), transaction, xarSource, loader);
} catch (PackageException | IOException | PermissionDeniedException e) {
LOG.error(e.getMessage(), e);
throw new XPathException(this, EXPathErrorCode.EXPDY007, "Package installation failed: " + e.getMessage(), new StringValue(e.getMessage()));
}
}
Aggregations