added manage product option

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@135023 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-11-29 09:28:50 +00:00
parent 32a50abe9a
commit 8d6b1771ec
3 changed files with 42 additions and 0 deletions

View File

@ -77,6 +77,7 @@ public class DataCatalogueImpl implements DataCatalogue{
private Integer CKAN_DB_PORT;
private String PORTLET_URL_FOR_SCOPE;
private String CKAN_TOKEN_SYS;
private boolean MANAGE_PRODUCT_BUTTON;
// ckan client
private CkanClient client;
@ -115,6 +116,7 @@ public class DataCatalogueImpl implements DataCatalogue{
CKAN_DB_PORT = runningInstance.getDatabasePorts().get(0);
CKAN_CATALOGUE_URL = runningInstance.getDataCatalogueUrl().get(0).trim();
PORTLET_URL_FOR_SCOPE = runningInstance.getPortletUrl().trim();
MANAGE_PRODUCT_BUTTON = runningInstance.isManageProductEnabled();
logger.debug("Plain sys admin token first 3 chars are " + CKAN_TOKEN_SYS.substring(0, 3));
logger.debug("Plain db password first 3 chars are " + CKAN_DB_PASSWORD.substring(0, 3));
@ -143,6 +145,14 @@ public class DataCatalogueImpl implements DataCatalogue{
return connection;
}
/**
* Check if the manage product is enabled
* @return
*/
public boolean isManageProductEnabled() {
return MANAGE_PRODUCT_BUTTON;
}
/**
* Tries to close a connection
@ -1780,4 +1790,5 @@ public class DataCatalogueImpl implements DataCatalogue{
return false;
}
}

View File

@ -54,6 +54,7 @@ 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)
// retrieved data
private List<String> datacatalogueUrls = new ArrayList<String>();
@ -63,6 +64,7 @@ public class DataCatalogueRunningCluster {
private String userDB;
private String passwordDB;
private String portletUrl;
private boolean manageProductEnabled;
// this token is needed in order to assign roles to user
private String sysAdminToken;
@ -157,6 +159,7 @@ public class DataCatalogueRunningCluster {
// save user and password
passwordDB = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
userDB = accessPoint.username();
}
}
}
@ -229,6 +232,15 @@ public class DataCatalogueRunningCluster {
// retrieve sys admin token
sysAdminToken = accessPoint.propertyMap().get(API_KEY_PROPERTY).value();
sysAdminToken = StringEncrypter.getEncrypter().decrypt(sysAdminToken);
// get the is manage product property
Property entry = accessPoint.propertyMap().get(IS_MANAGE_PRODUCT_ENABLED);
String isManageProduct = entry != null ? entry.value() : null;
if(isManageProduct != null && isManageProduct.equals("true")){
logger.info("Manage product is enabled in this scope");
manageProductEnabled = true;
}
}
}
}
@ -384,4 +396,13 @@ public class DataCatalogueRunningCluster {
public String getSysAdminToken() {
return sysAdminToken;
}
/**
* Is manager product enabled (e.g., for GRSF records)
* @return
*/
public boolean isManageProductEnabled() {
return manageProductEnabled;
}
}

View File

@ -14,6 +14,8 @@ import org.gcube.datacatalogue.ckanutillibrary.models.CkanDatasetRelationship;
import org.gcube.datacatalogue.ckanutillibrary.models.DatasetRelationships;
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import eu.trentorise.opendata.jackan.CheckedCkanClient;
@ -40,6 +42,14 @@ public class TestDataCatalogueLib {
public void before(){
factory = DataCatalogueFactory.getFactory();
}
//@Test
public void testManageProduct() throws Exception{
DataCatalogueImpl catalogue = factory.getUtilsPerScope(scope);
logger.debug("Manage product is " + catalogue.isManageProductEnabled());
}
//@Test
public void getRole() throws Exception{