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.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
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.ServiceCKANDB;
|
||||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||||
import org.gcube.informationsystem.model.impl.relations.ConsistsOfImpl;
|
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);
|
Object supportedOrganizationsObj = configurationSimpleFacet.getAdditionalProperty(CatalogueConfiguration.SUPPORTED_ORGANIZATIONS_KEY);
|
||||||
Set<String> supportedOrganizations = new HashSet<>();
|
Set<String> supportedOrganizations = new HashSet<>();
|
||||||
|
|
||||||
if(supportedOrganizationsObj instanceof Collection) {
|
boolean forceUpdate = false;
|
||||||
supportedOrganizations = new HashSet<String>((Collection<String>) supportedOrganizationsObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
catalogueConfiguration.setSupportedOrganizations(supportedOrganizations);
|
||||||
|
|
||||||
Map<String,Object> additionalProperties = new HashMap<>(configurationSimpleFacet.getAdditionalProperties());
|
Map<String,Object> additionalProperties = new HashMap<>(configurationSimpleFacet.getAdditionalProperties());
|
||||||
|
|
||||||
for(String key : additionalProperties.keySet()) {
|
for(String key : additionalProperties.keySet()) {
|
||||||
if(!CatalogueConfiguration.KNOWN_PROPERTIES.contains(key)) {
|
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;
|
return catalogueConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceCatalogueConfiguration setCkanServiceInfo(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
public ServiceCatalogueConfiguration setCkanServiceInfo(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
|
||||||
AccessPointFacet ckanServiceAccessPointFacet = queryCkanServiceAccessPointFacet();
|
AccessPointFacet ckanServiceAccessPointFacet = queryCkanServiceAccessPointFacet();
|
||||||
catalogueConfiguration.setCkanURL(ckanServiceAccessPointFacet.getEndpoint().toString());
|
catalogueConfiguration.setCkanURL(ckanServiceAccessPointFacet.getEndpoint().toString());
|
||||||
Encrypted encrypted = (Encrypted) ckanServiceAccessPointFacet.getAuthorization();
|
Encrypted encrypted = (Encrypted) ckanServiceAccessPointFacet.getAdditionalProperty(CatalogueConfiguration.SYS_ADMIN_TOKEN_KEY);
|
||||||
String encryptedPassword = encrypted.getEncryptedValue();
|
String encryptedPassword = encrypted.getEncryptedValue();
|
||||||
catalogueConfiguration.setSysAdminToken(encryptedPassword);
|
catalogueConfiguration.setSysAdminToken(encryptedPassword);
|
||||||
return catalogueConfiguration;
|
return catalogueConfiguration;
|
||||||
|
@ -251,7 +264,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
ServiceCKANDB ckanDB = new ServiceCKANDB();
|
ServiceCKANDB ckanDB = new ServiceCKANDB();
|
||||||
String ckanDbURL = postgresCkanDBAccessPointFacet.getEndpoint().toString();
|
String ckanDbURL = postgresCkanDBAccessPointFacet.getEndpoint().toString();
|
||||||
ckanDB.setUrl(ckanDbURL);
|
ckanDB.setUrl(ckanDbURL);
|
||||||
Encrypted encrypted = (Encrypted) postgresCkanDBAccessPointFacet.getAuthorization();
|
Encrypted encrypted = (Encrypted) postgresCkanDBAccessPointFacet.getAdditionalProperty(ServiceCKANDB.PASSWORD_KEY);
|
||||||
String encryptedPassword = encrypted.getEncryptedValue();
|
String encryptedPassword = encrypted.getEncryptedValue();
|
||||||
ckanDB.setEncryptedPassword(encryptedPassword);
|
ckanDB.setEncryptedPassword(encryptedPassword);
|
||||||
String username = (String) postgresCkanDBAccessPointFacet.getAdditionalProperty(ServiceCKANDB.USERNAME_KEY);
|
String username = (String) postgresCkanDBAccessPointFacet.getAdditionalProperty(ServiceCKANDB.USERNAME_KEY);
|
||||||
|
@ -281,7 +294,7 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
||||||
@Override
|
@Override
|
||||||
protected ServiceCatalogueConfiguration readFromIS() {
|
protected ServiceCatalogueConfiguration readFromIS() {
|
||||||
try {
|
try {
|
||||||
catalogueConfiguration = new ServiceCatalogueConfiguration(context);
|
catalogueConfiguration = new FacetBasedISServiceCatalogueConfiguration(context, this);
|
||||||
virtualService = queryVirtualService();
|
virtualService = queryVirtualService();
|
||||||
|
|
||||||
configurationSimpleFacet = getISResource();
|
configurationSimpleFacet = getISResource();
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
package org.gcube.gcat.configuration;
|
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