Search in sources :

Example 1 with DatabaseConfigurationException

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);
    }
}
Also used : ServletException(javax.servlet.ServletException) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) Database(org.xmldb.api.base.Database) XMLDBException(org.xmldb.api.base.XMLDBException) EXistException(org.exist.EXistException)

Example 2 with DatabaseConfigurationException

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);
}
Also used : ServletException(javax.servlet.ServletException) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) EXistException(org.exist.EXistException)

Example 3 with DatabaseConfigurationException

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();
    }
}
Also used : Configuration(org.exist.util.Configuration) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) EXistException(org.exist.EXistException)

Example 4 with DatabaseConfigurationException

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);
    }
}
Also used : DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) QName(org.exist.dom.QName)

Example 5 with DatabaseConfigurationException

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);
    }
}
Also used : DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Aggregations

DatabaseConfigurationException (org.exist.util.DatabaseConfigurationException)19 EXistException (org.exist.EXistException)8 IOException (java.io.IOException)6 Configuration (org.exist.util.Configuration)6 Path (java.nio.file.Path)5 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4 ServletException (javax.servlet.ServletException)3 QName (org.exist.dom.QName)3 PermissionDeniedException (org.exist.security.PermissionDeniedException)3 ClassLoaderSource (org.exist.source.ClassLoaderSource)3 Source (org.exist.source.Source)3 BrokerPool (org.exist.storage.BrokerPool)3 NodeList (org.w3c.dom.NodeList)3 FileSource (org.exist.source.FileSource)2 DBException (org.exist.storage.btree.DBException)2 BTreeStore (org.exist.storage.index.BTreeStore)2 FunctionReference (org.exist.xquery.value.FunctionReference)2 URI (java.net.URI)1 Files (java.nio.file.Files)1