vgritsenko 2003/08/19 14:08:27
Modified: java/src/org/apache/xindice/client/xmldb/embed
DatabaseImpl.java
java/src/org/apache/xindice/server XindiceServlet.java
ManagedServer.java
Log:
Convert dbRoot to canonical path
Revision Changes Path
1.20 +9 -9
xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DatabaseImpl.java 15 Aug 2003 04:34:54 -0000 1.19
+++ DatabaseImpl.java 19 Aug 2003 21:08:27 -0000 1.20
@@ -65,7 +65,6 @@
import org.apache.xindice.core.Database;
import org.apache.xindice.server.Xindice;
import org.apache.xindice.util.Configuration;
-import org.apache.xindice.util.ReadOnlyException;
import org.apache.xindice.util.XindiceException;
import org.apache.xindice.xml.dom.DOMParser;
@@ -75,7 +74,7 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
/**
* implements XML:DB's <code>Database</code> interface providing
@@ -115,7 +114,7 @@
* use the Configurable interface and only create the database when the
* getCollection method is called.
*/
- public DatabaseImpl() throws FileNotFoundException, XindiceException {
+ public DatabaseImpl() throws IOException, XindiceException {
Configuration config = loadConfiguration();
this.database = Database.getDatabase(config);
@@ -129,7 +128,7 @@
}
}
- protected Configuration loadConfiguration() throws
FileNotFoundException, XindiceException, ReadOnlyException {
+ protected Configuration loadConfiguration() throws IOException,
XindiceException {
Configuration config;
String configDir = null;
String configFile =
System.getProperty(Xindice.PROP_XINDICE_CONFIGURATION);
@@ -156,16 +155,17 @@
// Let's see if the property was specified.
String home = System.getProperty(Xindice.PROP_XINDICE_DB_HOME);
if (home != null) {
- config.setAttribute(Database.DBROOT, home + File.separator +
dbRoot);
+ dbRoot = new File(home + File.separator +
dbRoot).getCanonicalPath();
} else if (configDir != null) {
- config.setAttribute(Database.DBROOT, configDir +
File.separator + dbRoot);
+ dbRoot = configDir + File.separator + dbRoot;
} else {
log.warn("The database configuration file is not specified
and there was no "
+ Xindice.PROP_XINDICE_DB_HOME + " property set, "
+ "so Xindice was unable to determine a database
location. "
+ "Database will be created relative to the current
directory.");
- config.setAttribute(Database.DBROOT, new
File(".").getAbsolutePath() + File.separator + dbRoot);
+ dbRoot = new File("." + File.separator +
dbRoot).getCanonicalPath();
}
+ config.setAttribute(Database.DBROOT, dbRoot);
}
return config;
1.23 +6 -7
xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java
Index: XindiceServlet.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XindiceServlet.java 12 Aug 2003 02:57:30 -0000 1.22
+++ XindiceServlet.java 19 Aug 2003 21:08:27 -0000 1.23
@@ -170,20 +170,18 @@
// Stupid hack but spec compliant.
// If getRealPath() returns null the war archive
has not been unpacked.
- //
String realPath =
servletConfig.getServletContext().getRealPath("/WEB-INF");
// Let's see if the property was specified.
String home =
System.getProperty(Xindice.PROP_XINDICE_DB_HOME);
if (home != null) {
-
rootCollectionConfiguration.setAttribute(Database.DBROOT, home + File.separator
+ dbRoot);
+ dbRoot = new File(home + File.separator +
dbRoot).getCanonicalPath();
} else if (realPath != null) {
- String root = realPath + File.separator + dbRoot;
+ dbRoot = new File(realPath + File.separator +
dbRoot).getCanonicalPath();
log.warn(
"The database root directory has been set to
"
- + root
+ + dbRoot
+ ". Keep in mind that if a war upgrade will
take place the database will be lost.");
-
rootCollectionConfiguration.setAttribute(Database.DBROOT, root);
} else {
throw new ConfigurationException(
"The database configuration points to a
relative path, "
@@ -194,6 +192,7 @@
+ "as the \"dbroot\" attribute of
\"root-collection\" "
+ "or specify a suitable " +
Xindice.PROP_XINDICE_DB_HOME + " system property.");
}
+
rootCollectionConfiguration.setAttribute(Database.DBROOT, dbRoot);
}
//
1.6 +9 -9
xml-xindice/java/src/org/apache/xindice/server/ManagedServer.java
Index: ManagedServer.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/ManagedServer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ManagedServer.java 9 Aug 2003 02:52:18 -0000 1.5
+++ ManagedServer.java 19 Aug 2003 21:08:27 -0000 1.6
@@ -63,13 +63,12 @@
import org.apache.commons.logging.LogFactory;
import org.apache.xindice.core.Database;
import org.apache.xindice.util.Configuration;
-import org.apache.xindice.util.ReadOnlyException;
import org.apache.xindice.util.XindiceException;
import org.apache.xindice.xml.dom.DOMParser;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
/**
* Creates an registers a database instance for use of the managed driver.
This class
@@ -107,7 +106,7 @@
}
}
- public void configure() throws FileNotFoundException, XindiceException {
+ public void configure() throws IOException, XindiceException {
db = Database.getDatabase(loadConfiguration());
if (null == db) {
@@ -118,7 +117,7 @@
}
}
- protected Configuration loadConfiguration() throws
FileNotFoundException, XindiceException, ReadOnlyException {
+ protected Configuration loadConfiguration() throws IOException,
XindiceException {
Configuration config;
String configDir = null;
String configFile =
System.getProperty(Xindice.PROP_XINDICE_CONFIGURATION);
@@ -145,16 +144,17 @@
// Let's see if the property was specified.
String home = System.getProperty(Xindice.PROP_XINDICE_DB_HOME);
if (home != null) {
- config.setAttribute(Database.DBROOT, home + File.separator +
dbRoot);
+ dbRoot = new File(home + File.separator +
dbRoot).getCanonicalPath();
} else if (configDir != null) {
- config.setAttribute(Database.DBROOT, configDir +
File.separator + dbRoot);
+ dbRoot = configDir + File.separator + dbRoot;
} else {
+ dbRoot = new File("." + File.separator +
dbRoot).getCanonicalPath();
log.warn("The database configuration file is not specified
and there was no "
+ Xindice.PROP_XINDICE_DB_HOME + " property set, "
+ "so Xindice was unable to determine a database
location. "
+ "Database will be created relative to the current
directory.");
- config.setAttribute(Database.DBROOT, new
File(".").getAbsolutePath() + File.separator + dbRoot);
}
+ config.setAttribute(Database.DBROOT, dbRoot);
}
return config;