Add the possibility to deny social post on catalogue-ws

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@171512 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-09-19 08:10:23 +00:00
parent 9c817c550f
commit 515917ec37
3 changed files with 29 additions and 0 deletions

View File

@ -605,6 +605,12 @@ public interface DataCatalogue {
*/
Map<String, Map<CkanOrganization, RolesCkanGroupOrOrg>>getUserRoleByOrganization(String username, String apiKey);
/**
* Check if in the current context a social post are enabled. Default is true.
* @return a boolean value
*/
boolean isSocialPostEnabled();
/**
* Check if the users of the current context need to be alerted from a post creation or not. Default is false.
* @return a boolean value
@ -649,4 +655,5 @@ public interface DataCatalogue {
* Retrieve a resource by id
*/
CkanResource getResource(String id, String apiKey);
}

View File

@ -95,6 +95,7 @@ public class DataCatalogueImpl implements DataCatalogue{
private String CKAN_EMAIL;
private String URI_RESOLVER_URL;
private boolean MANAGE_PRODUCT_BUTTON;
private boolean SOCIAL_POST;
private boolean ALERT_USERS_ON_POST_CREATION;
private String CONTEXT;
private Map<String, String> extendRoleInOrganization;
@ -143,6 +144,7 @@ public class DataCatalogueImpl implements DataCatalogue{
PORTLET_URL_FOR_SCOPE = runningInstance.getPortletUrl().trim();
MANAGE_PRODUCT_BUTTON = runningInstance.isManageProductEnabled();
URI_RESOLVER_URL = runningInstance.getUrlResolver();
SOCIAL_POST = runningInstance.isSocialPostEnabled();
ALERT_USERS_ON_POST_CREATION = runningInstance.isAlertEnabled();
SOLR_URL = runningInstance.getUrlSolr();
@ -2991,4 +2993,10 @@ public class DataCatalogueImpl implements DataCatalogue{
}
@Override
public boolean isSocialPostEnabled() {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -65,6 +65,8 @@ public class DataCatalogueRunningCluster {
// 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)
private final static String SOCIAL_POST = "SOCIAL_POST";
private final static String ALERT_USERS_ON_POST_CREATION = "ALERT_USERS_ON_POST_CREATION";
private final static String SOLR_INDEX_ADDRESS = "SOLR_INDEX_ADDRESS";
@ -85,6 +87,7 @@ public class DataCatalogueRunningCluster {
private String urlSolr;
private boolean manageProductEnabled;
private String urlResolver;
private boolean socialPost;
private boolean alertUsers;
private Map<String, String> extendRoleInOrganization = new HashMap<String, String>(0);
@ -237,6 +240,13 @@ public class DataCatalogueRunningCluster {
manageProductEnabled = true;
}
// retrieve option to check if the social post has to be made
socialPost = true; // default is true
if(accessPoint.propertyMap().containsKey(SOCIAL_POST))
if(accessPoint.propertyMap().get(ALERT_USERS_ON_POST_CREATION).value().trim().equalsIgnoreCase("false"))
socialPost = false;
// retrieve option for user alert
if(accessPoint.propertyMap().containsKey(ALERT_USERS_ON_POST_CREATION))
if(accessPoint.propertyMap().get(ALERT_USERS_ON_POST_CREATION).value().trim().equalsIgnoreCase("true"))
@ -602,4 +612,8 @@ public class DataCatalogueRunningCluster {
return catalogueEmail == null? DEFAULT_CATALOGUE_EMAIL : catalogueEmail;
}
public boolean isSocialPostEnabled() {
return socialPost;
}
}