return true;
}
xqueryResourcePath = xqueryResourcePath.trim();
LOG.info("org.exist.security.openid.verify_logging_script = \"" + xqueryResourcePath + "\"");
BrokerPool pool = null;
DBBroker broker = null;
try {
DocumentImpl resource = null;
Source source = null;
pool = BrokerPool.getInstance();
broker = pool.get(principal);
if (broker == null) {
LOG.error("Unable to retrieve DBBroker for " + principal.getMetadataValue(AXSchemaType.ALIAS_USERNAME));
return false;
}
XmldbURI pathUri = XmldbURI.create(xqueryResourcePath);
resource = broker.getXMLResource(pathUri, Lock.READ_LOCK);
if(resource != null) {
LOG.info("Resource " + xqueryResourcePath + " exists.");
source = new DBSource(broker, (BinaryDocument)resource, true);
} else {
LOG.info("Resource " + xqueryResourcePath + " does not exist.");
LOG.info("pathURI " + pathUri );
return true;
}
XQuery xquery = broker.getXQueryService();
if (xquery == null) {
LOG.error("broker unable to retrieve XQueryService");
return false;
}
XQueryContext context = xquery.newContext(AccessContext.REST);
CompiledXQuery compiled = xquery.compile(context, source);
Properties outputProperties = new Properties();
Sequence result = xquery.execute(compiled, null, outputProperties);
LOG.info("XQuery execution results: " + result.toString());
} catch (Exception e) {
LOG.error("Exception while executing OpenID registration script for " + principal.getMetadataValue(AXSchemaType.ALIAS_USERNAME), e);
return false;
}
finally {
if (pool != null)
pool.release(broker);
}
return true;
}