vgritsenko    2003/08/08 19:52:18

  Modified:    java/src/org/apache/xindice/server ManagedServer.java
  Log:
  Add logic resolving relative dbroot; same as in XindiceServlet and 
embed.DatabaseImpl
  
  Revision  Changes    Path
  1.5       +23 -2     
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ManagedServer.java        7 Aug 2003 20:13:23 -0000       1.4
  +++ ManagedServer.java        9 Aug 2003 02:52:18 -0000       1.5
  @@ -120,6 +120,7 @@
   
       protected Configuration loadConfiguration() throws 
FileNotFoundException, XindiceException, ReadOnlyException {
           Configuration config;
  +        String configDir = null;
           String configFile = 
System.getProperty(Xindice.PROP_XINDICE_CONFIGURATION);
           if (configFile != null && !configFile.equals("")) {
               if (log.isInfoEnabled()) {
  @@ -128,14 +129,34 @@
               FileInputStream configXMLFile = new FileInputStream(new 
File(configFile));
   
               config = new Configuration(DOMParser.toDocument(configXMLFile), 
false);
  +            configDir = new File(configFile).getAbsoluteFile().getParent();
           } else {
               if (log.isInfoEnabled()) {
                   log.info("No configuration file specified, going with the 
default configuration");
               }
  +
               config = new 
Configuration(DOMParser.toDocument(Xindice.DEFAULT_CONFIGURATION), false);
           }
   
           config = config.getChild("root-collection", false);
  +
  +        String dbRoot = config.getAttribute(Database.DBROOT, 
Database.DBROOT_DEFAULT);
  +        if (!new File(dbRoot).isAbsolute()) {
  +            // 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);
  +            } else if (configDir != null) {
  +                config.setAttribute(Database.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);
  +            }
  +        }
  +
           return config;
       }
   }
  
  
  

Reply via email to