* they are read by the cocoon i18n transformer. We want to add in <location> parameters
* for each
*/
public void configure(Configuration originalConf) throws ConfigurationException
{
MutableConfiguration modifiedConf = new DefaultConfiguration(originalConf,true);
MutableConfiguration cataloguesConf = modifiedConf.getMutableChild("catalogues", true);
// Find the default catalogue and add our new locations to it.
for (MutableConfiguration catalogueConf : cataloguesConf.getMutableChildren())
{
if (!"false".equals(catalogueConf.getAttribute("aspects","false")))
{
// Get the first location element to determine what the base path is.
String baseCatalogueLocationPath = DEFAULT_BASE_LOCATION;
Configuration baseCatalogueLocationConf = catalogueConf.getChild("location");
if (baseCatalogueLocationConf != null)
{
baseCatalogueLocationPath = baseCatalogueLocationConf.getValue();
}
if (!baseCatalogueLocationPath.endsWith("/"))
{
baseCatalogueLocationPath += "/";
} // Add a trailing slash if one doesn't exist
String catalogueId = catalogueConf.getAttribute("id","unknown");
// For each aspect add two new locations one inside the aspect's directory
// and another inside the base location for i18n files.
for (Aspect aspect : XMLUIConfiguration.getAspectChain())
{
// Add a catalogue location inside the default i18n directory in the webapp
// this will be of the form: "context://i18n/<aspectpath>/" thus for the artifact
// browser aspect it will be "context://i18n/aspects/ArtifactBrowser/"
String baseLocationPath = aspect.getPath();
int idx = baseLocationPath.indexOf("://");
if (idx > 0)
{
// remove the module directive from the aspect's path so it's just a normal path
baseLocationPath = baseLocationPath.substring(idx + 3, baseLocationPath.length());
}
// Now that the module directive has been removed from the path, add in the base i18npath
baseLocationPath = baseCatalogueLocationPath + baseLocationPath;
MutableConfiguration baseLocation = new DefaultConfiguration("location");
baseLocation.setValue(baseLocationPath);
catalogueConf.addChild(baseLocation);
// Add a catalogue location inside the aspect's directory
// (most likely in the jar's resources but if it's not that's okay)
// For the artifact browser this would be:
// "resource://aspects/ArtifactBrowser/i18n/"
String aspectLocationPath = aspect.getPath();
if (!aspectLocationPath.endsWith("/"))
{
aspectLocationPath += "/"; // Add a trailing slash if one doesn't exist
}
aspectLocationPath += "i18n/";
MutableConfiguration aspectLocation = new DefaultConfiguration("location");
aspectLocation.setValue(aspectLocationPath);
catalogueConf.addChild(aspectLocation);
log.debug("Adding i18n location path for '"+catalogueId+"' catalogue: "+baseLocationPath);
log.debug("Adding i18n location path for '"+catalogueId+"' catalogue: "+aspectLocationPath);
} // for each aspect