vgritsenko    2003/08/19 14:13:33

  Modified:    java/src/org/apache/xindice/core Database.java
  Log:
  If PROP_XINDICE_DB_HOME is missing use the current directory.
  Print warnings.
  
  Revision  Changes    Path
  1.30      +21 -3     
xml-xindice/java/src/org/apache/xindice/core/Database.java
  
  Index: Database.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/Database.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Database.java     12 Aug 2003 02:57:30 -0000      1.29
  +++ Database.java     19 Aug 2003 21:13:33 -0000      1.30
  @@ -75,6 +75,7 @@
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   import java.io.File;
  +import java.io.IOException;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -301,7 +302,24 @@
           File dbrootDir = new File(dbroot);
           if (!dbrootDir.isAbsolute()) {
               // Here, DB root already should be absolute. XMLRPC, Embed, and 
Managed drivers take care of it.
  -            dbrootDir = new 
File(System.getProperty(Xindice.PROP_XINDICE_DB_HOME), dbroot);
  +            log.warn("The specified database root directory '" + dbroot + "' 
is relative. " +
  +                     "Using property " + Xindice.PROP_XINDICE_DB_HOME + " to 
resolve.");
  +
  +            String home = System.getProperty(Xindice.PROP_XINDICE_DB_HOME);
  +            if (home == null) {
  +                log.warn("The specified database root directory '" + dbroot 
+ "' is relative " +
  +                         "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.");
  +
  +                home = ".";
  +            }
  +            try {
  +                // In case home has been specified as relative path convert 
it to absolute path
  +                dbrootDir = new File(home, dbroot).getCanonicalFile();
  +            } catch (IOException e) {
  +                throw new XindiceException("Can't get canonical path", e);
  +            }
           }
   
           setCollectionRoot(dbrootDir);
  
  
  

Reply via email to