mapFile = TurbineServlet.getRealPath(mapFile);
directory = TurbineServlet.getRealPath(directory);
}
catch (Throwable t)
{
throw new InitializationException("Unable to initialize LateInitCastorRegistryService, missing config keys");
}
// build the map of default fragments, eahc registry must be associated
// with at least one fragment
try
{
Iterator i = getConfiguration().getKeys("default");
while (i.hasNext())
{
String key = (String) i.next();
String name = key.substring(key.indexOf(".") + 1);
String fragmentFileName = getConfiguration().getString(key);
String absFileName = new File(directory, fragmentFileName + extension).getCanonicalPath();
// add this name in the list of available registries
names.add(name);
// store the default file mapping
this.defaults.put(name, absFileName);
}
}
catch (Exception e)
{
logger.error("RegistryService: Registry init error", e);
throw new InitializationException("Unable to initialize LateInitCastorRegistryService, invalid registries definition");
}
// create the serializer output format
this.format = new OutputFormat();
format.setIndenting(true);
format.setIndent(4);
format.setLineWidth(0);
// test the mapping file and create the mapping object
if (mapFile != null)
{
File map = new File(mapFile);
if (map.exists() && map.isFile() && map.canRead())
{
try
{
mapping = new SynchronizedMapping();
InputSource is = new InputSource(new FileReader(map));
is.setSystemId(mapFile);
mapping.loadMapping(is);
}
catch (Exception e)
{
logger.error("RegistryService: Error in mapping creation", e);
throw new InitializationException("Error in mapping", e);
}
}
else
{
throw new InitializationException("Mapping not found or not a file or unreadable: " + mapFile);
}
}
// Set directory watcher if directory exists
File base = new File(directory);