Changeset 2232 for FCKeditor.Java/trunk

Show
Ignore:
Timestamp:
2008-07-19 21:07:51 (5 months ago)
Author:
mosipov
Message:

ASSIGNED - #2357: PropertiesLoader Exception when undeploying a webapp using FCKeditor.Java Integration

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/handlers/PropertiesLoader.java

    r2101 r2232  
    2222 
    2323import java.io.BufferedInputStream; 
    24 import java.io.IOException; 
    2524import java.io.InputStream; 
    2625import java.util.Properties; 
     
    5150 
    5251        static { 
    53                 try { 
    54                         // 1. load library defaults 
    55                         properties.load(new BufferedInputStream(PropertiesLoader.class 
    56                                 .getResourceAsStream("default.properties"))); 
    5752 
    58                         // 2. load user defaults 
    59                         InputStream in = PropertiesLoader.class.getResourceAsStream("/fckeditor.properties"); 
    60                         if (in == null) 
    61                                 logger.warn("Can't find fckeditor.properties!"); 
    62                         else { 
    63                                 try { 
    64                                         properties.load(new BufferedInputStream(in)); 
    65                                         logger.info("fckeditor.properties loaded successfully!"); 
    66                                 } catch (IOException e) { 
    67                                         logger.error("Error while loading fckeditor.properties!", e); 
    68                                         throw new RuntimeException("Can't load fckeditor.properties!", e); 
    69                                 } 
     53                // 1. load library defaults 
     54                InputStream in = PropertiesLoader.class 
     55                                .getResourceAsStream("default.properties"); 
     56 
     57                if (in == null) { 
     58                        logger.error("default.properties not found"); 
     59                        throw new RuntimeException("default.properties not found"); 
     60                } else { 
     61                        if (!(in instanceof BufferedInputStream)) 
     62                                in = new BufferedInputStream(in); 
     63 
     64                        try { 
     65                                properties.load(in); 
     66                                in.close(); 
     67                                logger.debug("default.properties loaded"); 
     68                        } catch (Exception e) { 
     69                                logger.error("Error while processing default.properties"); 
     70                                throw new RuntimeException( 
     71                                                "Error while processing default.properties", e); 
    7072                        } 
    71                 } catch (IOException e) { 
    72                         logger.error("Error while loading default.properties!", e); 
    73                         throw new RuntimeException("Can't load default.properties!", e); 
    7473                } 
     74 
     75                // 2. load user defaults 
     76                InputStream in2 = PropertiesLoader.class 
     77                                .getResourceAsStream("/fckeditor.properties_"); 
     78 
     79                if (in2 == null) { 
     80                        logger.info("fckeditor.properties not found"); 
     81                } else { 
     82 
     83                        if (!(in2 instanceof BufferedInputStream)) 
     84                                in2 = new BufferedInputStream(in2); 
     85 
     86                        try { 
     87                                properties.load(in2); 
     88                                in2.close(); 
     89                                logger.debug("fckeditor.properties loaded"); 
     90                        } catch (Exception e) { 
     91                                logger.error("Error while processing fckeditor.properties"); 
     92                                throw new RuntimeException( 
     93                                                "Error while processing fckeditor.properties", e); 
     94                        } 
     95 
     96                }                
    7597        } 
    7698 
     
    104126                properties.setProperty(key, value); 
    105127        } 
     128         
     129        public static void main(String[] args) { 
     130                new PropertiesLoader(); 
     131        } 
    106132}