Changeset 416

Show
Ignore:
Timestamp:
11/10/08 12:18:23 (2 months ago)
Author:
arneke
Message:

Minor reorganization of XML configuration search, also allows geoserver plugin to have a configuration file

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/util/XMLConfiguration.java

    r399 r416  
    232232 
    233233        File xmlFile = null; 
    234         if (configH != null) { 
     234        if (configH == null) { 
     235            log.error("deleteLayer() - Missing XML configuration file?"); 
     236            return false; 
     237        } else { 
    235238            // Find the configuration file 
    236239            xmlFile = new File(configH.getAbsolutePath() + File.separator + "geowebcache.xml"); 
     
    315318        String baseDir = context.getServletContext().getRealPath(""); 
    316319         
     320        /* 
     321         * Try  
     322         * 1) absolute path  
     323         * 2) relative path  
     324         * 3) standard paths 
     325         */ 
    317326        if (absPath != null) { 
    318327            configH = new File(absPath); 
    319             return; 
    320         } 
    321  
    322         /* Only keep going for relative directory */ 
    323         if (relPath == null) { 
    324              
    325             for(int i=0; i<CONFIGURATION_REL_PATHS.length; i++) { 
     328        } else if (relPath != null) { 
     329            configH = new File(baseDir + relPath); 
     330            log.info("Configuration directory set to: " 
     331                    + configH.getAbsolutePath()); 
     332        } else if (relPath == null) { 
     333            for (int i = 0; i < CONFIGURATION_REL_PATHS.length; i++) { 
    326334                relPath = CONFIGURATION_REL_PATHS[i]; 
    327                 if(File.separator.equals("\\")) { 
    328                     relPath = relPath.replace("/","\\"); 
     335                if (File.separator.equals("\\")) { 
     336                    relPath = relPath.replace("/", "\\"); 
    329337                } 
    330                  
    331                 File tmpPath = new File(baseDir + relPath + File.separator + CONFIGURATION_FILE_NAME); 
    332                  
    333                 if(tmpPath.exists()) { 
    334                     log.info("No configuration directory was specified, using "+tmpPath.getAbsolutePath()); 
     338 
     339                File tmpPath = new File(baseDir + relPath + File.separator 
     340                        + CONFIGURATION_FILE_NAME); 
     341 
     342                if (tmpPath.exists()) { 
     343                    log.info("No configuration directory was specified, using " 
     344                            + tmpPath.getAbsolutePath()); 
    335345                    configH = new File(baseDir + relPath); 
    336                     return; 
    337346                } 
    338347            } 
    339              
    340             log.error("Failed to find geowebcache.xml, please specify an absolute path in geowebcache-servlet.xml!"); 
    341         } 
    342         configH = new File(baseDir + relPath); 
    343  
    344         log.info("Configuration directory set to: "+ configH.getAbsolutePath()); 
    345  
    346         if (!configH.exists() || !configH.canRead()) { 
    347             log.error(configH.getAbsoluteFile()+ " cannot be read or does not exist!"); 
     348        } 
     349        
     350        if(configH == null) { 
     351            log.error("Failed to find geowebcache.xml, please specify an absolute path " 
     352                    +"in geowebcache-servlet.xml!"); 
     353        } else { 
     354            log.info("Configuration directory set to: "+ configH.getAbsolutePath()); 
     355         
     356            if (!configH.exists() || !configH.canRead()) { 
     357                log.error(configH.getAbsoluteFile()+ " cannot be read or does not exist!"); 
     358            } 
    348359        } 
    349360    }