Changeset 426 for trunk

Show
Ignore:
Timestamp:
11/17/08 16:26:53 (7 weeks ago)
Author:
arneke
Message:

Increasing robustness to absence of geowebcache.xml, got a bit confused on Tomcat for some reason

Location:
trunk/geowebcache/src/main/java/org/geowebcache
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FileCache.java

    r424 r426  
    4949    public final static String GS_DATA_DIR = "GEOSERVER_DATA_DIR"; 
    5050 
    51     private static Log log = LogFactory 
    52             .getLog(org.geowebcache.cache.file.FileCache.class); 
     51    private static Log log = LogFactory.getLog(org.geowebcache.cache.file.FileCache.class); 
    5352 
    5453    private String defaultKeyBeanId = null; 
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/TileLayerDispatcher.java

    r399 r426  
    110110            Configuration config = configIter.next(); 
    111111 
    112             try { 
    113                 configLayers = config.getTileLayers(); 
    114             } catch (GeoWebCacheException gwce) { 
    115                 log.error(gwce.getMessage()); 
    116                 log.error("Failed to add layers from " 
    117                                 + config.getIdentifier()); 
    118             } 
     112            String configIdent = config.getIdentifier(); 
    119113 
    120             log.info("Adding layers from " + config.getIdentifier()); 
    121             if (configLayers != null && configLayers.size() > 0) { 
    122                 Iterator<Entry<String,TileLayer>> iter = configLayers.entrySet().iterator(); 
    123                 while (iter.hasNext()) { 
    124                     Entry<String,TileLayer> one = iter.next(); 
    125                     layers.put(one.getKey(), one.getValue()); 
     114            if (configIdent != null) { 
     115                try { 
     116                    configLayers = config.getTileLayers(); 
     117                } catch (GeoWebCacheException gwce) { 
     118                    log.error(gwce.getMessage()); 
     119                    log.error("Failed to add layers from " + configIdent); 
    126120                } 
    127             } else { 
    128                 log.error("Configuration " + config.getIdentifier() 
    129                         + " contained no layers."); 
     121 
     122                log.info("Adding layers from " + configIdent); 
     123                if (configLayers != null && configLayers.size() > 0) { 
     124                    Iterator<Entry<String, TileLayer>> iter = configLayers 
     125                            .entrySet().iterator(); 
     126                    while (iter.hasNext()) { 
     127                        Entry<String, TileLayer> one = iter.next(); 
     128                        layers.put(one.getKey(), one.getValue()); 
     129                    } 
     130                } else { 
     131                    log.error("Configuration " + configIdent 
     132                            + " contained no layers."); 
     133                } 
    130134            } 
    131135        } 
  • trunk/geowebcache/src/main/java/org/geowebcache/util/XMLConfiguration.java

    r417 r426  
    9797        File xmlFile = null; 
    9898        if (configH != null) { 
    99             // Find the property file 
    10099            xmlFile = new File(configH.getAbsolutePath() + File.separator + CONFIGURATION_FILE_NAME); 
    101100        } else { 
     
    120119         
    121120        HashMap<String, TileLayer> layers = new HashMap<String, TileLayer>(); 
    122  
     121         
    123122        // load configurations into Document 
    124123        Document docc = loadIntoDocument(xmlFile); 
    125         Element root = docc.getDocumentElement(); 
    126         NodeList allLayerNodes = root.getChildNodes(); 
    127  
    128         XStream xs = getConfiguredXStream(new XStream()); 
    129  
    130         TileLayer result = null; 
    131         for (int i = 0; i < allLayerNodes.getLength(); i++) { 
    132             if (allLayerNodes.item(i) instanceof Element) { 
    133                 Element e = (Element) allLayerNodes.item(i); 
    134                 if (e.getTagName().equalsIgnoreCase("wmslayer")) 
    135                     result = (WMSLayer) xs.unmarshal(new DomReader( 
    136                             (Element) allLayerNodes.item(i))); 
    137                 result.setCacheFactory(this.cacheFactory); 
    138                 layers.put(result.getName(), result); 
    139             } 
     124        if(docc != null) { 
     125            Element root = docc.getDocumentElement(); 
     126            NodeList allLayerNodes = root.getChildNodes(); 
     127 
     128            XStream xs = getConfiguredXStream(new XStream()); 
     129 
     130            TileLayer result = null; 
     131            for (int i = 0; i < allLayerNodes.getLength(); i++) { 
     132                if (allLayerNodes.item(i) instanceof Element) { 
     133                    Element e = (Element) allLayerNodes.item(i); 
     134                    if (e.getTagName().equalsIgnoreCase("wmslayer")) 
     135                        result = (WMSLayer) xs.unmarshal(new DomReader( 
     136                                (Element) allLayerNodes.item(i))); 
     137                    result.setCacheFactory(this.cacheFactory); 
     138                    layers.put(result.getName(), result); 
     139                } 
     140            } 
     141        } else { 
     142             
    140143        } 
    141144 
     
    382385         
    383386            if (!configH.exists() || !configH.canRead()) { 
    384                 log.error(configH.getAbsoluteFile()+ " cannot be read or does not exist!"); 
     387                log.error("Configuration file cannot be read or does not exist!"); 
    385388            } 
    386389        } 
     
    388391 
    389392    public String getIdentifier() { 
    390         return configH.getAbsolutePath(); 
     393        if(configH != null) { 
     394          return configH.getAbsolutePath(); 
     395        } else { 
     396            return null; 
     397        } 
    391398    } 
    392399