Added defaults for missing configuration properties

This commit is contained in:
Luca Frosini 2022-02-15 21:34:50 +01:00
parent 4df3e7cf5c
commit bd22fb48c3
1 changed files with 17 additions and 5 deletions

View File

@ -86,6 +86,14 @@ public class GCoreISConfigurationProxy {
return accessPoint;
}
protected String getDefaultSolrURL(String ckanURL) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(ckanURL);
stringBuffer.append(ckanURL.endsWith("/")?"":"/");
stringBuffer.append("solr/");
return stringBuffer.toString();
}
protected CatalogueConfiguration getCatalogueConfigurationFromIS() {
try {
boolean mustBeUpdated = false;
@ -114,7 +122,7 @@ public class GCoreISConfigurationProxy {
catalogueConfiguration.setSysAdminToken(sysAdminToken);
String defaultOrganization = CatalogueConfiguration.getOrganizationName(context);
String defaultOrganization = null;
if (propertyMap.containsKey(DEFAULT_ORGANIZATION_PROPERTY_KEY)) {
String org = propertyMap.get(DEFAULT_ORGANIZATION_PROPERTY_KEY).value().trim();
if(org!=null && org.compareTo("")==0) {
@ -128,13 +136,13 @@ public class GCoreISConfigurationProxy {
}
catalogueConfiguration.setDefaultOrganization(defaultOrganization);
String solrURL = null;
if (propertyMap.containsKey(SOLR_INDEX_ADDRESS_PROPERTY_KEY)) {
solrURL = propertyMap.get(SOLR_INDEX_ADDRESS_PROPERTY_KEY).value();
catalogueConfiguration.setSolrURL(solrURL);
}else {
solrURL = getDefaultSolrURL(ckanURL);
}
catalogueConfiguration.setSolrURL(solrURL);
// retrieve option to check if the social post has to be made
Boolean socialPostEnabled = true;
@ -178,12 +186,16 @@ public class GCoreISConfigurationProxy {
supportedOrganizations = getSupportedOrganizationsFromGenericResource();
mustBeUpdated = true;
}
if (supportedOrganizations != null) {
catalogueConfiguration.setSupportedOrganizations(supportedOrganizations);
if(defaultOrganization==null) {
defaultOrganization = supportedOrganizations.toArray(new String[supportedOrganizations.size()])[0];
catalogueConfiguration.setDefaultOrganization(defaultOrganization);
}
}
if(mustBeUpdated) {
// updateOnIS(serviceEndpoint);
logger.warn("The ServiceEndpoint with ID {} in context {} should be updated", serviceEndpoint.id(), context);
}