Implemented configuration based on new IS
This commit is contained in:
parent
b80a251896
commit
527e418e16
|
@ -16,6 +16,7 @@ import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.service.FacetBasedISServiceCatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.service.ServiceCKANDB;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.gcube.informationsystem.model.impl.relations.ConsistsOfImpl;
|
||||
|
@ -219,28 +220,40 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
Object supportedOrganizationsObj = configurationSimpleFacet.getAdditionalProperty(CatalogueConfiguration.SUPPORTED_ORGANIZATIONS_KEY);
|
||||
Set<String> supportedOrganizations = new HashSet<>();
|
||||
|
||||
if(supportedOrganizationsObj instanceof Collection) {
|
||||
supportedOrganizations = new HashSet<String>((Collection<String>) supportedOrganizationsObj);
|
||||
}
|
||||
boolean forceUpdate = false;
|
||||
|
||||
supportedOrganizations.add(catalogueConfiguration.getDefaultOrganization());
|
||||
if(supportedOrganizationsObj!=null && supportedOrganizationsObj instanceof Collection) {
|
||||
supportedOrganizations = new HashSet<String>((Collection<String>) supportedOrganizationsObj);
|
||||
}else {
|
||||
supportedOrganizations.add(catalogueConfiguration.getDefaultOrganization());
|
||||
configurationSimpleFacet.setAdditionalProperty(CatalogueConfiguration.SUPPORTED_ORGANIZATIONS_KEY, supportedOrganizations);
|
||||
forceUpdate = true;
|
||||
}
|
||||
catalogueConfiguration.setSupportedOrganizations(supportedOrganizations);
|
||||
|
||||
Map<String,Object> additionalProperties = new HashMap<>(configurationSimpleFacet.getAdditionalProperties());
|
||||
|
||||
for(String key : additionalProperties.keySet()) {
|
||||
if(!CatalogueConfiguration.KNOWN_PROPERTIES.contains(key)) {
|
||||
catalogueConfiguration.setAdditionalProperty(key, additionalProperties.get(key));
|
||||
if(key.startsWith("@")) {
|
||||
continue;
|
||||
}
|
||||
Object value = additionalProperties.get(key);
|
||||
catalogueConfiguration.setAdditionalProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
if(forceUpdate) {
|
||||
updateOnIS(configurationSimpleFacet);
|
||||
}
|
||||
|
||||
return catalogueConfiguration;
|
||||
}
|
||||
|
||||
public ServiceCatalogueConfiguration setCkanServiceInfo(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||
AccessPointFacet ckanServiceAccessPointFacet = queryCkanServiceAccessPointFacet();
|
||||
catalogueConfiguration.setCkanURL(ckanServiceAccessPointFacet.getEndpoint().toString());
|
||||
Encrypted encrypted = (Encrypted) ckanServiceAccessPointFacet.getAuthorization();
|
||||
Encrypted encrypted = (Encrypted) ckanServiceAccessPointFacet.getAdditionalProperty(CatalogueConfiguration.SYS_ADMIN_TOKEN_KEY);
|
||||
String encryptedPassword = encrypted.getEncryptedValue();
|
||||
catalogueConfiguration.setSysAdminToken(encryptedPassword);
|
||||
return catalogueConfiguration;
|
||||
|
@ -251,7 +264,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
ServiceCKANDB ckanDB = new ServiceCKANDB();
|
||||
String ckanDbURL = postgresCkanDBAccessPointFacet.getEndpoint().toString();
|
||||
ckanDB.setUrl(ckanDbURL);
|
||||
Encrypted encrypted = (Encrypted) postgresCkanDBAccessPointFacet.getAuthorization();
|
||||
Encrypted encrypted = (Encrypted) postgresCkanDBAccessPointFacet.getAdditionalProperty(ServiceCKANDB.PASSWORD_KEY);
|
||||
String encryptedPassword = encrypted.getEncryptedValue();
|
||||
ckanDB.setEncryptedPassword(encryptedPassword);
|
||||
String username = (String) postgresCkanDBAccessPointFacet.getAdditionalProperty(ServiceCKANDB.USERNAME_KEY);
|
||||
|
@ -281,7 +294,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
@Override
|
||||
protected ServiceCatalogueConfiguration readFromIS() {
|
||||
try {
|
||||
catalogueConfiguration = new ServiceCatalogueConfiguration(context);
|
||||
catalogueConfiguration = new FacetBasedISServiceCatalogueConfiguration(context, this);
|
||||
virtualService = queryVirtualService();
|
||||
|
||||
configurationSimpleFacet = getISResource();
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
package org.gcube.gcat.configuration;
|
||||
|
||||
public class CatalogueConfigurationFactoryTest {
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CatalogueConfigurationFactoryTest extends ContextTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CatalogueConfigurationFactoryTest.class);
|
||||
|
||||
@Test
|
||||
public void testConf() throws Exception {
|
||||
ServiceCatalogueConfiguration serviceCatalogueConfiguration = CatalogueConfigurationFactory.getInstance();
|
||||
logger.debug("{}", serviceCatalogueConfiguration.toJsonString());
|
||||
logger.debug("{}", serviceCatalogueConfiguration.toJsonString(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue