minor fix: the role the user will have into a group is the one he/she has into the organization in which the product is going to be published

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@132003 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-28 16:14:39 +00:00
parent c8df6dea6a
commit 6017ee35af
2 changed files with 8 additions and 3 deletions

View File

@ -19,6 +19,7 @@ public class AssociationToGroupThread extends Thread {
private String datasetId;
private String username;
private DataCatalogue catalogue;
private String organization;
/**
* @param groupTitle
@ -27,11 +28,12 @@ public class AssociationToGroupThread extends Thread {
* @param catalogue
*/
public AssociationToGroupThread(String groupTitle, String datasetId,
String username, DataCatalogue catalogue) {
String username, DataCatalogue catalogue, String organization) {
this.groupTitle = groupTitle;
this.datasetId = datasetId;
this.username = username;
this.catalogue = catalogue;
this.organization = organization;
}
@Override
@ -49,8 +51,11 @@ public class AssociationToGroupThread extends Thread {
}else{
logger.debug("Group exists, going to add the user " + username + " as its admin...");
// retrieve the role to be assigned according the one the user has into the organization of the dataset
RolesCkanGroupOrOrg role = RolesCkanGroupOrOrg.valueOf(catalogue.getRoleOfUserInOrganization(username, organization, catalogue.getApiKeyFromUsername(username).toUpperCase()));
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, RolesCkanGroupOrOrg.ADMIN);
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, role);
if(assigned){

View File

@ -497,7 +497,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// start a thread that will associate this dataset with the group
if(toCreate.getChosenProfile() != null){
AssociationToGroupThread thread = new AssociationToGroupThread(toCreate.getChosenProfile(), datasetId, userName, utils);
AssociationToGroupThread thread = new AssociationToGroupThread(toCreate.getChosenProfile(), datasetId, userName, utils, organizationNameOrId);
thread.start();
}