log.info( "Reading mappings from file: " + xmlFile );
List errors = new ArrayList();
try {
org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
if ( errors.size() != 0 ) {
throw new InvalidMappingException( "file", xmlFile.toString(), (Throwable) errors.get(0) );
}
try {
log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStream( cachedFile ) );
}
catch ( SerializationException e ) {
log.warn( "Could not write cached file: " + cachedFile, e );
}
catch ( FileNotFoundException e ) {
log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
}
add( doc );
}
catch (DocumentException e) {
throw new InvalidMappingException( "file", xmlFile.toString(), e );
}
return this;
}