minor fix
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@129166 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1425113df5
commit
6b8c310d30
|
@ -662,7 +662,7 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
|
|||
String ckanUsername = UtilMethods.fromUsernameToCKanUsername(username);
|
||||
|
||||
// check if this role is already present in ckan for this user within the organization
|
||||
boolean alreadyPresent = isRoleAlreadySet(ckanUsername, organizationName, correspondentRoleToCheck);
|
||||
boolean alreadyPresent = isRoleAlreadySet(ckanUsername, organizationName.toLowerCase(), correspondentRoleToCheck);
|
||||
|
||||
if(alreadyPresent)
|
||||
return true; // just return
|
||||
|
@ -711,7 +711,7 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
|
|||
* @param correspondentRoleToCheck
|
||||
* @return true if he has the role, false otherwise
|
||||
*/
|
||||
private boolean isRoleAlreadySet(String ckanUsername,
|
||||
protected boolean isRoleAlreadySet(String ckanUsername,
|
||||
String organizationName,
|
||||
RolesIntoOrganization correspondentRoleToCheck) {
|
||||
|
||||
|
@ -719,9 +719,14 @@ public class CKanUtilsImpl implements CKanUtilsInterface{
|
|||
|
||||
// user id
|
||||
String userId = getUserIdByUsername(ckanUsername);
|
||||
|
||||
// we need a checked client
|
||||
CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, CKAN_TOKEN_SYS);
|
||||
|
||||
// get the CkanClient to retrieve the organization id from the name
|
||||
String orgId = client.getOrganization(organizationName).getId();
|
||||
|
||||
logger.debug("Organization with name " + organizationName + " has id " + orgId);
|
||||
|
||||
String query =
|
||||
"SELECT * FROM \"member\" WHERE \"table_id\"=? and \"group_id\"=? and \"table_name\"=? and \"state\"=? and \"capacity\"=?;";
|
||||
|
|
|
@ -78,4 +78,13 @@ public class TestCKanLib {
|
|||
|
||||
System.out.println("organizations for user " + username + " are " + map);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void isRoleAlreadySet() throws Exception{
|
||||
|
||||
instance = new CKanUtilsImpl("/gcube");
|
||||
boolean res = instance.isRoleAlreadySet("andrea_rossi", "devVRE".toLowerCase(), RolesIntoOrganization.EDITOR);
|
||||
logger.debug("Res is " + res);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue