use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class AbstractExistHttpServlet method doDatabaseStartup.
private void doDatabaseStartup(Configuration configuration) throws ServletException {
if (configuration == null) {
throw new ServletException("Database has not been " + "configured");
}
getLog().info("Configuring eXist instance");
try {
if (!BrokerPool.isConfigured()) {
BrokerPool.configure(1, 5, configuration);
}
} catch (final EXistException | DatabaseConfigurationException e) {
throw new ServletException(e.getMessage(), e);
}
try {
getLog().info("Registering XMLDB driver");
final Class<?> clazz = Class.forName("org.exist.xmldb.DatabaseImpl");
final Database database = (Database) clazz.newInstance();
DatabaseManager.registerDatabase(database);
} catch (final ClassNotFoundException | XMLDBException | IllegalAccessException | InstantiationException e) {
getLog().info("ERROR", e);
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class AbstractExistHttpServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
// prepare the database
try {
setPool(getOrCreateBrokerPool(config));
} catch (final EXistException e) {
throw new ServletException("No database instance available");
} catch (final DatabaseConfigurationException e) {
throw new ServletException("Unable to configure database instance: " + e.getMessage(), e);
}
// general eXist Servlet config
doGeneralExistServletConfig(config);
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class Repair method startDB.
private void startDB() {
try {
Configuration config = new Configuration();
BrokerPool.configure(1, 5, config);
pool = BrokerPool.getInstance();
} catch (DatabaseConfigurationException | EXistException e) {
e.printStackTrace();
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class LuceneIndexConfig method parseQName.
protected static QName parseQName(String name, Map<String, String> namespaces) throws DatabaseConfigurationException {
boolean isAttribute = false;
if (name.startsWith("@")) {
isAttribute = true;
name = name.substring(1);
}
try {
String prefix = QName.extractPrefix(name);
String localName = QName.extractLocalName(name);
String namespaceURI = "";
if (prefix != null) {
namespaceURI = namespaces.get(prefix);
if (namespaceURI == null) {
throw new DatabaseConfigurationException("No namespace defined for prefix: " + prefix + " in index definition");
}
}
final QName qname;
if (isAttribute) {
qname = new QName(localName, namespaceURI, prefix, ElementValue.ATTRIBUTE);
} else {
qname = new QName(localName, namespaceURI, prefix);
}
return qname;
} catch (QName.IllegalQNameException e) {
throw new DatabaseConfigurationException("Lucene index configuration error: " + e.getMessage(), e);
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class IndexSpec method read.
/**
* Read index configurations from an "index" element node.
* The node should have zero or more "create" nodes.
* The "create" elements add a {@link GeneralRangeIndexSpec} to the current configuration.
*
* @param index index configuration
* @param broker the eXist-db DBBroker
* @throws DatabaseConfigurationException in response to an eXist-db configuration error
*/
public void read(DBBroker broker, Element index) throws DatabaseConfigurationException {
final Map<String, String> namespaces = getNamespaceMap(index);
final NodeList childNodes = index.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
final Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (CREATE_ELEMENT.equals(node.getLocalName())) {
final Element elem = (Element) node;
final String type = elem.getAttribute(TYPE_ATTRIB);
if (elem.hasAttribute(QNAME_ATTRIB)) {
final String qname = elem.getAttribute(QNAME_ATTRIB);
final QNameRangeIndexSpec qnIdx = new QNameRangeIndexSpec(namespaces, qname, type);
qnameSpecs.put(qnIdx.getQName(), qnIdx);
} else if (elem.hasAttribute(PATH_ATTRIB)) {
final String path = elem.getAttribute(PATH_ATTRIB);
final GeneralRangeIndexSpec valueIdx = new GeneralRangeIndexSpec(namespaces, path, type);
addValueIndex(valueIdx);
} else {
final String error_message = "Configuration error: element " + elem.getNodeName() + " must have attribute " + PATH_ATTRIB + " or " + QNAME_ATTRIB;
throw new DatabaseConfigurationException(error_message);
}
}
}
}
// the default index config from conf.xml)
if (broker != null) {
customIndexSpecs = broker.getIndexController().configure(childNodes, namespaces);
}
}
Aggregations