there is no need to create groups. Just check the user has enough privileges to associate it to the group
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@132962 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
91f56dca42
commit
a2a00e0d8a
|
@ -19,7 +19,6 @@ public class AssociationToGroupThread extends Thread {
|
||||||
private String datasetId;
|
private String datasetId;
|
||||||
private String username;
|
private String username;
|
||||||
private DataCatalogue catalogue;
|
private DataCatalogue catalogue;
|
||||||
private String organization;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param groupTitle
|
* @param groupTitle
|
||||||
|
@ -28,37 +27,31 @@ public class AssociationToGroupThread extends Thread {
|
||||||
* @param catalogue
|
* @param catalogue
|
||||||
*/
|
*/
|
||||||
public AssociationToGroupThread(List<String> groupsTitles, String datasetId,
|
public AssociationToGroupThread(List<String> groupsTitles, String datasetId,
|
||||||
String username, DataCatalogue catalogue, String organization) {
|
String username, DataCatalogue catalogue) {
|
||||||
this.groupsTitles = groupsTitles;
|
this.groupsTitles = groupsTitles;
|
||||||
this.datasetId = datasetId;
|
this.datasetId = datasetId;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.catalogue = catalogue;
|
this.catalogue = catalogue;
|
||||||
this.organization = organization;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
logger.info("Association thread started to put the dataset with id="+ datasetId + " into group with title " + groupsTitles + " for user " + username);
|
logger.info("Association thread started to put the dataset with id="+ datasetId + " into group with title(s) " + groupsTitles + " for user " + username);
|
||||||
|
|
||||||
// create the group
|
|
||||||
for (String groupTitle : groupsTitles) {
|
for (String groupTitle : groupsTitles) {
|
||||||
|
|
||||||
logger.debug("Group exists, going to add the user " + username + " as its admin...");
|
// check the user has enough privileges to associate it
|
||||||
|
if(catalogue.checkRoleIntoGroup(username, groupTitle, RolesCkanGroupOrOrg.MEMBER)){
|
||||||
// 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());
|
logger.warn("The user " + username + " has no enough priviliges to associate the dataset into group " + groupTitle);
|
||||||
|
continue;
|
||||||
boolean assigned = catalogue.checkRoleIntoGroup(username, groupTitle, role);
|
|
||||||
|
|
||||||
if(assigned){
|
|
||||||
|
|
||||||
logger.debug("Admin/editor role was assigned for this group, going to associate the product to the group");
|
|
||||||
|
|
||||||
boolean putIntoGroup = catalogue.assignDatasetToGroup(groupTitle, datasetId, catalogue.getApiKeyFromUsername(username));
|
|
||||||
logger.info("Was product put into group? " + putIntoGroup);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean putIntoGroup = catalogue.assignDatasetToGroup(groupTitle, datasetId, catalogue.getApiKeyFromUsername(username));
|
||||||
|
logger.info("Was product put into group? " + putIntoGroup);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue