* @throws IOException
* - when createDefaultIsMissing is true and default config
* cannot be created
*/
public WGAConfiguration retrieveWGAConfig(boolean createDefaultIfMissing) throws IncompatibleWGAConfigVersion, IOException {
IFile wgaXML = getWGAConfigFile();
if (wgaXML == null) {
// this nature is not configured yet
return null;
}
if (!wgaXML.exists()) {
if (!createDefaultIfMissing) {
return null;
} else {
// create default config
WGAConfiguration config = WGAConfiguration.createDefaultConfig();
// int segmentCount =
// _wgaBase.getLocation().matchingFirstSegments(_luceneRoot.getLocation());
// IPath relativeLucenePath =
// _luceneRoot.getLocation().removeFirstSegments(segmentCount);
// config.getLuceneManagerConfiguration().setPath(relativeLucenePath.toString());
// config.getDesignConfiguration().getDesignSource(Constants.DESIGNCOL_FILESYSTEM).getOptions().put("path",
// "../designs");
Domain defaultDomain = config.getDefaultDomain();
defaultDomain.setDefaultManager("managers");
defaultDomain.createFileBasedAuthentication("auth.xml");
config.getServerOptions().put(WGAConfiguration.SERVEROPTION_SERVER_NAME, getName());
if (getRootURL() != null) {
config.getServerOptions().put(WGAConfiguration.SERVEROPTION_ROOT_URL, getRootURL().toString());
}
// disable install wizard
config.setRunWizard(false);
saveWGAConfig(config);
return config;
}
} else {
synchronized (_wgaConfigLock) {
FileInputStream wgaXMLStream = null;
try {
wgaXMLStream = new FileInputStream(wgaXML.getLocation().toFile());
WGAConfiguration conf = WGAConfiguration.read(wgaXMLStream);
return conf;
} catch (Exception e) {
IncompatibleWGAConfigVersion notConfigurable = new IncompatibleWGAConfigVersion("Unable to read wga configuration.", e);
throw notConfigurable;