@SuppressWarnings("unchecked")
List<Element> serviceConfigElems = config.getChildren();
ServiceConfig handlerConfig = new ServiceConfig(serviceConfigElems);
// Init configuration directory
final GeonetworkDataDirectory dataDirectory = _applicationContext.getBean(GeonetworkDataDirectory.class);
dataDirectory.init(webappName, appPath, handlerConfig, context.getServlet());
// Get config handler properties
String systemDataDir = handlerConfig.getMandatoryValue(Geonet.Config.SYSTEM_DATA_DIR);
String thesauriDir = handlerConfig.getMandatoryValue(Geonet.Config.CODELIST_DIR);
String luceneDir = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_DIR);
String luceneConfigXmlFile = handlerConfig.getMandatoryValue(Geonet.Config.LUCENE_CONFIG);
logger.info("Data directory: " + systemDataDir);
setProps(appPath, handlerConfig);
importDatabaseData(context);
// Status actions class - load it
String statusActionsClassName = handlerConfig.getMandatoryValue(Geonet.Config.STATUS_ACTIONS_CLASS);
@SuppressWarnings("unchecked")
Class<StatusActions> statusActionsClass = (Class<StatusActions>) Class.forName(statusActionsClassName);
JeevesJCS.setConfigFilename(appPath + "WEB-INF/classes/cache.ccf");
// force caches to be config'd so shutdown hook works correctly
JeevesJCS.getInstance(Processor.XLINK_JCS);
JeevesJCS.getInstance(XmlResolver.XMLRESOLVER_JCS);
//------------------------------------------------------------------------
//--- initialize thread pool
logger.info(" - Thread Pool...");
threadPool = new ThreadPool();
//------------------------------------------------------------------------
//--- initialize settings subsystem
logger.info(" - Setting manager...");
SettingManager settingMan = this._applicationContext.getBean(SettingManager.class);
//--- initialize ThreadUtils with setting manager and rm props
final DataSource dataSource = context.getBean(DataSource.class);
Connection conn = null;
try {
conn = dataSource.getConnection();
ThreadUtils.init(conn.getMetaData().getURL(), settingMan);
} finally {
if (conn != null) {
conn.close();
}
}
//------------------------------------------------------------------------
//--- initialize Z39.50
logger.info(" - Z39.50...");
boolean z3950Enable = settingMan.getValueAsBool("system/z3950/enable", false);
String z3950port = settingMan.getValue("system/z3950/port");
logger.info(" - Z39.50 is enabled: " + z3950Enable);
if (z3950Enable) {
// build Z3950 repositories file first from template
URL url = getClass().getClassLoader().getResource(Geonet.File.JZKITCONFIG_TEMPLATE);
if (Repositories.build(url, context)) {
logger.info(" Repositories file built from template.");
try {
ConfigurableApplicationContext appContext = context.getApplicationContext();
// to have access to the GN context in spring-managed objects
ContextContainer cc = (ContextContainer) appContext.getBean("ContextGateway");
cc.setSrvctx(context);
if (!z3950Enable) {
logger.info(" Server is Disabled.");
} else {
logger.info(" Server is Enabled.");
Server.init(z3950port, appContext);
}
} catch (Exception e) {
logger.error(" Repositories file init FAILED - Z3950 server disabled and Z3950 client services (remote search, " +
"harvesting) may not work. Error is:" + e.getMessage());
e.printStackTrace();
}
} else {
logger.error(" Repositories file builder FAILED - Z3950 server disabled and Z3950 client services (remote search, " +
"harvesting) may not work.");
}
}
//------------------------------------------------------------------------
//--- initialize SchemaManager
logger.info(" - Schema manager...");
String schemaPluginsDir = dataDirectory.getSchemaPluginsDir().getAbsolutePath();
String schemaCatalogueFile = dataDirectory.getConfigDir()+File.separator+Geonet.File.SCHEMA_PLUGINS_CATALOG;
boolean createOrUpdateSchemaCatalog = handlerConfig.getMandatoryValue(Geonet.Config.SCHEMA_PLUGINS_CATALOG_UPDATE).equals("true");
logger.info(" - Schema plugins directory: " + schemaPluginsDir);
logger.info(" - Schema Catalog File : " + schemaCatalogueFile);
SchemaManager schemaMan = _applicationContext.getBean(SchemaManager.class);
schemaMan.configure(_applicationContext, appPath, Resources.locateResourcesDir(context), schemaCatalogueFile,
schemaPluginsDir, context.getLanguage(), handlerConfig.getMandatoryValue(Geonet.Config.PREFERRED_SCHEMA),
createOrUpdateSchemaCatalog);
//------------------------------------------------------------------------
//--- initialize search and editing
logger.info(" - Search...");
boolean logSpatialObject = "true".equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_SPATIAL_OBJECTS));
boolean logAsynch = "true".equalsIgnoreCase(handlerConfig.getMandatoryValue(Geonet.Config.STAT_LOG_ASYNCH));
logger.info(" - Log spatial object: " + logSpatialObject);
logger.info(" - Log in asynch mode: " + logAsynch);
String luceneTermsToExclude = "";
luceneTermsToExclude = handlerConfig.getMandatoryValue(Geonet.Config.STAT_LUCENE_TERMS_EXCLUDE);
LuceneConfig lc = _applicationContext.getBean(LuceneConfig.class);
lc.configure(luceneConfigXmlFile);
logger.info(" - Lucene configuration is:");
logger.info(lc.toString());
try {
_applicationContext.getBean(DataStore.class);
} catch (NoSuchBeanDefinitionException e) {
DataStore dataStore = createShapefileDatastore(luceneDir);
_applicationContext.getBeanFactory().registerSingleton("dataStore", dataStore);
//--- no datastore for spatial indexing means that we can't continue
if (dataStore == null) {
throw new IllegalArgumentException("GeoTools datastore creation failed - check logs for more info/exceptions");
}
}
String maxWritesInTransactionStr = handlerConfig.getMandatoryValue(Geonet.Config.MAX_WRITES_IN_TRANSACTION);
int maxWritesInTransaction = SpatialIndexWriter.MAX_WRITES_IN_TRANSACTION;
try {
maxWritesInTransaction = Integer.parseInt(maxWritesInTransactionStr);
} catch (NumberFormatException nfe) {
logger.error("Invalid config parameter: maximum number of writes to spatial index in a transaction (maxWritesInTransaction)"
+ ", Using " + maxWritesInTransaction + " instead.");
nfe.printStackTrace();
}
SettingInfo settingInfo = context.getBean(SettingInfo.class);
searchMan = _applicationContext.getBean(SearchManager.class);
searchMan.init(logAsynch,
logSpatialObject, luceneTermsToExclude,
maxWritesInTransaction);
// if the validator exists the proxyCallbackURL needs to have the external host and
// servlet name added so that the cas knows where to send the validation notice
ServerBeanPropertyUpdater.updateURL(settingInfo.getSiteUrl(true) + baseURL, _applicationContext);
//------------------------------------------------------------------------
//--- extract intranet ip/mask and initialize AccessManager
logger.info(" - Access manager...");
//------------------------------------------------------------------------
//--- get edit params and initialize DataManager
logger.info(" - Xml serializer and Data manager...");
SvnManager svnManager = _applicationContext.getBean(SvnManager.class);
XmlSerializer xmlSerializer = _applicationContext.getBean(XmlSerializer.class);
if (xmlSerializer instanceof XmlSerializerSvn && svnManager != null) {
svnManager.setContext(context);
String subversionPath = dataDirectory.getMetadataRevisionDir().getCanonicalPath();
svnManager.setSubversionPath(subversionPath);
svnManager.init();
}
/**