Feature #21269: make roles assigned or removed in different operations

Feature/21269
Massimiliano Assante 3 years ago
parent bc5f309fc5
commit 5e8dd211b5

@ -5,10 +5,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v4.0.0-SNAPSHOT] - 2021-05-04
Porting to git, see other changelog.xml for more changelogs.
## [v4.0.0-SNAPSHOT] - 2021-05-13
- Feature #21269: make roles either assigned or removed in different operations, not mixed.
- Ported to git, see other changelog.xml for more changelogs.
## [v1.0.0] - 2016-06-20

@ -23,10 +23,11 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/UsersManagementPortle
* **Panagiota Koltsida** - [National and Kapodistrian University of Athens & Athena' Research Center)
* **Vassilis Floros** - [Communication & Information Technologies Experts S.A - CITE (Greece)]
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR InfraScience Laboratory]
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
## License

@ -551,8 +551,9 @@ public class UsersManagementPortletHome extends GenericPortlet {
}
/**
* this method assign or revoke VE Groups to one user
* manage the assignment to teams
* @param groupId
* @param groupId the LR Site groupID
* @param usersIDs
* @param usersTeams
* @param selfId
@ -641,22 +642,17 @@ public class UsersManagementPortletHome extends GenericPortlet {
}
}
/**
* Called in case of User Assignment or Revokations of roles or assign/remove group, see typeOfChangesUpponUserMode param
*
* @param groupId
* @param usersIDs
* @param groupId the LR Site groupID
* @param usersIDs the LR userIDs that are subject for this operation
* @param theRoles
* @param usersTeams
* @param deletePreviousRoles
* @param deletePreviousRoles should not be used anymore
* @param selfId
* @param typeOfChangesUpponUserMode
* @param typeOfChangesUpponUserMode is the Number of operation (1:assign role, 2: assign/remove group, 3:revoke role)
* @param request
* @return
* @throws SystemException
* @throws PortalException
* @throws UserManagementSystemException
* @throws UserRetrievalFault
* @throws RoleRetrievalFault
* @throws GroupRetrievalFault
*/
protected JSONArray usersForCurrrentUsersTablePlusRoles( Long groupId,
long[] usersIDs, String[] theRoles, String[] usersTeams,
@ -671,10 +667,7 @@ public class UsersManagementPortletHome extends GenericPortlet {
String groupName = lgm.getGroup(groupId).getGroupName();
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request);
_log.debug("Editing users for the context: " + groupName);
_log.info("Editing users roles or group for the context: " + groupName);
_log.debug("String[] theRoles length?="+theRoles.length);
for (int i = 0; i < theRoles.length; i++) {
_log.debug("role: "+theRoles[i]);
@ -683,11 +676,12 @@ public class UsersManagementPortletHome extends GenericPortlet {
for (int i = 0; i < usersTeams.length; i++) {
_log.debug("team: "+usersTeams[i]);
}
_log.debug("Number of operation ((1:assign role, 2: assign/remove group, 3:revoke role) is ="+typeOfChangesUpponUserMode);
_log.info("Number of operation (1:assign role, 2: assign/remove group, 3:revoke role) is ="+typeOfChangesUpponUserMode);
_log.debug("usersIDs.length="+usersIDs.length);
if(usersIDs.length == 1) {// SINGLE USER EDIT, support assignment and removal of roles and groups
GCubeUser gcu = lum.getUserById(usersIDs[0]);
_log.debug("single edit for user: "+gcu.getUsername());
long[] roleIDs = new long[theRoles.length];
GCubeRole[] gCubeRoles = new GCubeRole[theRoles.length];
long[] newRoleIDs = new long[theRoles.length];
@ -753,13 +747,14 @@ public class UsersManagementPortletHome extends GenericPortlet {
} //END EDIT ROLES for single user
else { //MULTIUSER ASSIGNMENT of Roles only and Groups/Sites add and removal
System.out.println("MULTIUSER ASSIGNMENT type?="+typeOfChangesUpponUserMode);
_log.info("MULTIUSER ASSIGNMENT type?="+typeOfChangesUpponUserMode);
List<GCubeTeam> existingGCubeTeams = lrm.listTeamsByGroup(groupId);
for (long uid : usersIDs) { //for each user
GCubeUser user = lum.getUserById(uid);
GCubeUser gcu = lum.getUserByUsername(user.getUsername());
_log.debug("iterating user: "+user.getUsername());
List<GCubeUser> usersInTeam = new ArrayList<GCubeUser>();
@ -816,7 +811,7 @@ public class UsersManagementPortletHome extends GenericPortlet {
String[] gCubeTeamNames = new String[usersTeams.length];
StringBuffer teamNames = new StringBuffer();
for(int i=0; i<usersTeams.length; i++){
for (int i=0; i<usersTeams.length; i++) {
GCubeTeam team = null;
try {
team = lrm.getTeam(groupId, usersTeams[i].trim());
@ -838,14 +833,11 @@ public class UsersManagementPortletHome extends GenericPortlet {
existingGCubeTeamsIDs.addAll(gCubeTeamIDs);
long[] gCubeTeamsIDsToBeAddedToTheUser = new long[existingGCubeTeamsIDs.size()];
int i=0;
for(Long l : existingGCubeTeamsIDs){
for (Long l : existingGCubeTeamsIDs) {
gCubeTeamsIDsToBeAddedToTheUser[i] = l;
i++;
}
try {
List<GCubeTeam> oldUserTeams = lrm.listTeamsByUserAndGroup(gcu.getUserId(), groupId);
List<Long> oldUserTeamsIDs = new ArrayList<Long>();
for(Iterator<GCubeTeam> it = oldUserTeams.iterator(); it.hasNext();) {
@ -897,7 +889,20 @@ public class UsersManagementPortletHome extends GenericPortlet {
return currentGroupUsers( groupId, selfId, httpServletRequest);
}
/**
*
* @param portletRequest
* @param request
* @param groupId
* @param userIDs
* @param membershipRequestsIDs
* @param sendDismissalEmail
* @throws SystemException
* @throws PortalException
* @throws UserManagementSystemException
* @throws UserRetrievalFault
* @throws GroupRetrievalFault
*/
protected void removeUsersFromGroup(PortletRequest portletRequest, ResourceRequest request, long groupId, long[] userIDs,
long[] membershipRequestsIDs, boolean sendDismissalEmail)
throws SystemException, PortalException, UserManagementSystemException,

Loading…
Cancel
Save