Search in sources :

Example 1 with XMLProperties

use of org.jivesoftware.util.XMLProperties in project Openfire by igniterealtime.

the class ArchiveIndexer method loadPropertiesFile.

/**
     * Loads a property manager for search properties if it isn't already
     * loaded. If an XML file for the search properties isn't already
     * created, it will attempt to make a file with default values.
     */
private void loadPropertiesFile(File searchDir) throws IOException {
    File indexPropertiesFile = new File(searchDir, "indexprops.xml");
    // If it doesn't exists we have to create it.
    if (!indexPropertiesFile.exists()) {
        org.dom4j.Document doc = DocumentFactory.getInstance().createDocument(DocumentFactory.getInstance().createElement("search"));
        // Now, write out to the file.
        Writer out = null;
        try {
            // Use JDOM's XMLOutputter to do the writing and formatting.
            out = new FileWriter(indexPropertiesFile);
            XMLWriter outputter = new XMLWriter(out, OutputFormat.createPrettyPrint());
            outputter.write(doc);
            outputter.flush();
        } catch (Exception e) {
            Log.error(e.getMessage(), e);
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (Exception e) {
            // Ignore.
            }
        }
    }
    indexProperties = new XMLProperties(indexPropertiesFile);
}
Also used : FileWriter(java.io.FileWriter) XMLProperties(org.jivesoftware.util.XMLProperties) File(java.io.File) XMLWriter(org.dom4j.io.XMLWriter) XMLWriter(org.dom4j.io.XMLWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer) TimeoutException(java.util.concurrent.TimeoutException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 SQLException (java.sql.SQLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 XMLWriter (org.dom4j.io.XMLWriter)1 XMLProperties (org.jivesoftware.util.XMLProperties)1