added method for retrieving catalogue main email
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@162542 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
047a79b907
commit
8cf12d1593
|
@ -638,4 +638,10 @@ public interface DataCatalogue {
|
|||
* @return a list of matching datasets
|
||||
*/
|
||||
List<CkanDataset> searchForPackageInOrganization(String apiKey, String query, int start, int offset, String organization) throws Exception;
|
||||
|
||||
/**
|
||||
* Retrieve the catalogue email
|
||||
* @return an email address for sending email to this catalogue
|
||||
*/
|
||||
String getCatalogueEmail();
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
private String PORTLET_URL_FOR_SCOPE;
|
||||
private String SOLR_URL;
|
||||
private String CKAN_TOKEN_SYS;
|
||||
private String CKAN_EMAIL;
|
||||
private String URI_RESOLVER_URL;
|
||||
private boolean MANAGE_PRODUCT_BUTTON;
|
||||
private boolean ALERT_USERS_ON_POST_CREATION;
|
||||
|
@ -135,6 +136,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
CKAN_DB_USER = runningInstance.getDataBaseUser().trim();
|
||||
CKAN_DB_PASSWORD = runningInstance.getDataBasePassword().trim();
|
||||
CKAN_TOKEN_SYS = runningInstance.getSysAdminToken().trim();
|
||||
CKAN_EMAIL = runningInstance.getEmailCatalogue().trim();
|
||||
CKAN_DB_PORT = runningInstance.getDatabasePorts().get(0);
|
||||
CKAN_CATALOGUE_URL = runningInstance.getDataCatalogueUrl().get(0).trim();
|
||||
PORTLET_URL_FOR_SCOPE = runningInstance.getPortletUrl().trim();
|
||||
|
@ -2977,4 +2979,11 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
return landingPages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCatalogueEmail() {
|
||||
|
||||
return CKAN_EMAIL;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -59,6 +59,9 @@ public class DataCatalogueRunningCluster {
|
|||
// api key property for SYSADMIN
|
||||
private final static String API_KEY_PROPERTY = "API_KEY";
|
||||
|
||||
// catalogue email
|
||||
private final static String CKAN_EMAIL_PROPERTY = "CATALOGUE_EMAIL";
|
||||
|
||||
// property to retrieve the master service endpoint into the /root scope
|
||||
private final static String IS_MASTER_ROOT_KEY_PROPERTY = "IS_ROOT_MASTER"; // true, false.. missing means false as well
|
||||
private final static String IS_MANAGE_PRODUCT_ENABLED = "IS_MANAGE_PRODUCT_ENABLED"; // true, false.. missing means false as well (for GRSF records)
|
||||
|
@ -90,10 +93,12 @@ public class DataCatalogueRunningCluster {
|
|||
public static final String ROLE_ORGANIZATION_SEPARATOR = "|";
|
||||
public static final String TUPLES_SEPARATOR = ",";
|
||||
|
||||
private static final String DEFAULT_CATALOGUE_EMAIL = "catalogue@d4science.org";
|
||||
|
||||
// this token is needed in order to assign roles to user
|
||||
private String sysAdminToken;
|
||||
|
||||
|
||||
private String catalogueEmail;
|
||||
|
||||
public DataCatalogueRunningCluster(String scope) throws Exception{
|
||||
|
||||
|
@ -182,6 +187,12 @@ public class DataCatalogueRunningCluster {
|
|||
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
|
||||
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
|
||||
|
||||
// retrieve catalogue email
|
||||
if(accessPoint.propertyMap().containsKey(CKAN_EMAIL_PROPERTY)){
|
||||
catalogueEmail = accessPoint.propertyMap().get(CKAN_EMAIL_PROPERTY).value();
|
||||
catalogueEmail = StringEncrypter.getEncrypter().decrypt(catalogueEmail);
|
||||
}
|
||||
|
||||
// retrieve URL_RESOLVER
|
||||
if(accessPoint.propertyMap().containsKey(URL_RESOLVER))
|
||||
urlResolver = accessPoint.propertyMap().get(URL_RESOLVER).value();
|
||||
|
@ -211,6 +222,12 @@ public class DataCatalogueRunningCluster {
|
|||
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
|
||||
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
|
||||
|
||||
// retrieve catalogue email
|
||||
if(accessPoint.propertyMap().containsKey(CKAN_EMAIL_PROPERTY)){
|
||||
catalogueEmail = accessPoint.propertyMap().get(CKAN_EMAIL_PROPERTY).value();
|
||||
catalogueEmail = StringEncrypter.getEncrypter().decrypt(catalogueEmail);
|
||||
}
|
||||
|
||||
// get the is manage product property
|
||||
Property entry = accessPoint.propertyMap().get(IS_MANAGE_PRODUCT_ENABLED);
|
||||
String isManageProduct = entry != null ? entry.value() : null;
|
||||
|
@ -237,7 +254,7 @@ public class DataCatalogueRunningCluster {
|
|||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new ServiceEndPointException("There is no service end point for such information");
|
||||
throw new ServiceEndPointException("There is no service end point for such information" + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,5 +593,13 @@ public class DataCatalogueRunningCluster {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the catalogue email. Default is "catalogue@d4science.org"
|
||||
* @return
|
||||
*/
|
||||
public String getEmailCatalogue() {
|
||||
logger.debug("Read email from resource is " + catalogueEmail);
|
||||
return catalogueEmail == null? DEFAULT_CATALOGUE_EMAIL : catalogueEmail;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,12 @@ public class TestDataCatalogueLib {
|
|||
//@Before
|
||||
public void before() throws Exception{
|
||||
factory = DataCatalogueFactory.getFactory();
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void getSysadminEmail() throws Exception{
|
||||
DataCatalogueImpl utils = factory.getUtilsPerScope(scope);
|
||||
System.out.println(utils.getCatalogueEmail());
|
||||
}
|
||||
|
||||
//@Test
|
||||
|
|
Loading…
Reference in New Issue