fix in checkrole method
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@131418 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5fa2475614
commit
6295a91bae
|
@ -784,6 +784,7 @@ public class CKanUtilsImpl implements CKanUtils{
|
|||
// else
|
||||
organizationNameToCheck = organizationName.toLowerCase();
|
||||
|
||||
try{
|
||||
boolean alreadyPresent = isRoleAlreadySet(ckanUsername, organizationNameToCheck, correspondentRoleToCheck);
|
||||
|
||||
if(alreadyPresent)
|
||||
|
@ -821,6 +822,10 @@ public class CKanUtilsImpl implements CKanUtils{
|
|||
logger.error("Error while trying to change the role for this user ", ex);
|
||||
}
|
||||
}
|
||||
}catch (Exception ex) {
|
||||
logger.error("Unable to check if this role was already set, please check your parameters! ", ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -833,9 +838,7 @@ public class CKanUtilsImpl implements CKanUtils{
|
|||
*/
|
||||
protected boolean isRoleAlreadySet(String ckanUsername,
|
||||
String organizationName,
|
||||
RolesIntoOrganization correspondentRoleToCheck) {
|
||||
|
||||
try{
|
||||
RolesIntoOrganization correspondentRoleToCheck) throws Exception{
|
||||
|
||||
// get the users (if you try ckanOrganization.getUsers() it returns null.. maybe a bug TODO)
|
||||
List<CkanUser> users = client.getOrganization(organizationName).getUsers();
|
||||
|
@ -845,10 +848,6 @@ public class CKanUtilsImpl implements CKanUtils{
|
|||
return true;
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to check if this role was already set", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class TestCKanLib {
|
|||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TestCKanLib.class);
|
||||
|
||||
private CkanUtilsFactory factory;
|
||||
private String scope = "/gcube/devNext/NextNext";
|
||||
private String scope = "/gcube";
|
||||
private String testUser = "costantino_perciante";
|
||||
String subjectId = "aa_father4";
|
||||
String objectId = "bb_son4";
|
||||
|
@ -178,12 +178,12 @@ public class TestCKanLib {
|
|||
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
String url = "https://dev4.d4science.org/group/devvre/ckan";
|
||||
String scopeToUse = new ApplicationProfileScopePerUrlReader().getScopePerUrl(url);
|
||||
String scopeToUse = ApplicationProfileScopePerUrlReader.getScopePerUrl(url);
|
||||
logger.debug("Retrieved scope is " + scopeToUse);
|
||||
|
||||
ScopeProvider.instance.reset(); // the following sysout should print null
|
||||
String url2 = "https://dev4.d4science.org/group/devvre/ckan";
|
||||
String scopeToUse2 = new ApplicationProfileScopePerUrlReader().getScopePerUrl(url2);
|
||||
String scopeToUse2 = ApplicationProfileScopePerUrlReader.getScopePerUrl(url2);
|
||||
logger.debug("Retrieved scope is " + scopeToUse2);
|
||||
}
|
||||
|
||||
|
@ -246,4 +246,13 @@ public class TestCKanLib {
|
|||
//
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testInvalidOrgRole() throws Exception{
|
||||
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope(scope);
|
||||
boolean res = instance.checkRole("costantino_perciante", "gcube", RolesIntoOrganization.EDITOR);
|
||||
logger.debug(""+res);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue