now revoked or assigned roles arrive to the server, still to be managed

This commit is contained in:
Massimiliano Assante 2021-05-12 19:11:24 +02:00
parent 51620bc664
commit 5cb7bbb3a1
3 changed files with 877 additions and 836 deletions

View File

@ -74,6 +74,7 @@ public class UsersManagementPortletHome extends GenericPortlet {
private static final int DELETE_SITE_TEAMS_TABLE = 0; private static final int DELETE_SITE_TEAMS_TABLE = 0;
private static final int MASS_EDIT_USERS = 0; private static final int MASS_EDIT_USERS = 0;
private static final int ASSIGN_ROLES_TO_USERS = 1; private static final int ASSIGN_ROLES_TO_USERS = 1;
private static final int REMOVE_ROLES_TO_USERS = 3;
private static final int ASSIGN_TEAMS_TO_USERS = 2; private static final int ASSIGN_TEAMS_TO_USERS = 2;
public void init() { public void init() {
@ -557,9 +558,17 @@ public class UsersManagementPortletHome extends GenericPortlet {
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request);
_log.debug("Editing users for the group: " + groupName); _log.debug("*** \n\n Editing users for the context: " + groupName);
System.out.println("\n\n****");
if(usersIDs.length == 1){//You can delete previous roles of a single user only. System.out.println("long[] usersIDs="+usersIDs.toString());
System.out.println("String[] theRoles="+theRoles.toString());
System.out.println("deletePreviousRoles?="+deletePreviousRoles);
System.out.println("selfId="+selfId);
System.out.println("int typeOfChangesUpponUserMode is="+typeOfChangesUpponUserMode);
System.out.println("usersIDs.length="+usersIDs.length);
if(usersIDs.length == 1) {//You can delete previous roles of a single user only.
GCubeUser gcu = lum.getUserById(usersIDs[0]); GCubeUser gcu = lum.getUserById(usersIDs[0]);
long[] roleIDs = new long[theRoles.length]; long[] roleIDs = new long[theRoles.length];
GCubeRole[] gCubeRoles = new GCubeRole[theRoles.length]; GCubeRole[] gCubeRoles = new GCubeRole[theRoles.length];
@ -572,20 +581,12 @@ public class UsersManagementPortletHome extends GenericPortlet {
newRoleIDs[i] = gCubeRoles[i].getRoleId(); newRoleIDs[i] = gCubeRoles[i].getRoleId();
} }
if(deletePreviousRoles && typeOfChangesUpponUserMode == MASS_EDIT_USERS){ if(typeOfChangesUpponUserMode == REMOVE_ROLES_TO_USERS){
_log.debug("MASS_EDIT_USERS"); System.out.println("\n\n\n ****** REMOVE_ROLES_TO_USERS");
try{
lrm.removeAllRolesFromUser(gcu.getUserId(), groupId);
}catch(Exception e){
e.printStackTrace();
}
// List<GCubeTeam> teams = lrm.listTeamsByGroup(groupId); }
// if(teams.size() > 0 ){ else if(typeOfChangesUpponUserMode == ASSIGN_ROLES_TO_USERS){
// lrm.deleteUserTeams(gcu.getUserId(), teams); _log.info("\n\n\n ****** ASSIGN_ROLES_TO_USERS");
// }
} else if(deletePreviousRoles && typeOfChangesUpponUserMode == ASSIGN_ROLES_TO_USERS){
_log.debug("ASSIGN_ROLES_TO_USERS");
try{ try{
lrm.removeAllRolesFromUser(gcu.getUserId(), groupId); lrm.removeAllRolesFromUser(gcu.getUserId(), groupId);
}catch(Exception e){ }catch(Exception e){
@ -599,7 +600,7 @@ public class UsersManagementPortletHome extends GenericPortlet {
String[] gCubeTeamNames = new String[usersTeams.length]; String[] gCubeTeamNames = new String[usersTeams.length];
StringBuffer teamNames = new StringBuffer(); StringBuffer teamNames = new StringBuffer();
for(int i=0; i<usersTeams.length; i++){ for (int i=0; i<usersTeams.length; i++) {
GCubeTeam team = null; GCubeTeam team = null;
try { try {
team = lrm.getTeam(groupId, usersTeams[i].trim()); team = lrm.getTeam(groupId, usersTeams[i].trim());
@ -706,7 +707,10 @@ public class UsersManagementPortletHome extends GenericPortlet {
} }
_log.debug("User: " + currentUser.getUsername() + " is editing the roles of user: "+ gcu.getUsername() + " for the site: " + groupName + "and deletes all previous site-roles"); _log.debug("User: " + currentUser.getUsername() + " is editing the roles of user: "+ gcu.getUsername() + " for the site: " + groupName + "and deletes all previous site-roles");
}else{
} //END EDIT ROLES
else {
List<GCubeTeam> existingGCubeTeams = lrm.listTeamsByGroup(groupId); List<GCubeTeam> existingGCubeTeams = lrm.listTeamsByGroup(groupId);

File diff suppressed because it is too large Load Diff

View File

@ -78,6 +78,7 @@
var MASS_EDIT_USERS = 0; var MASS_EDIT_USERS = 0;
var ASSIGN_ROLES_TO_USERS = 1; var ASSIGN_ROLES_TO_USERS = 1;
var ASSIGN_TEAMS_TO_USERS = 2; var ASSIGN_TEAMS_TO_USERS = 2;
var REMOVE_ROLES_TO_USERS = 3;
var handlersAppliedToToolbarForFirstTime = false; var handlersAppliedToToolbarForFirstTime = false;
</script> </script>
@ -500,11 +501,9 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div> </div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button id="openEditModal" class="btn btn-link btn-large">Edit</button>
<button id="closeUSerDetailsModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Close</button> <button id="closeUSerDetailsModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Close</button>
</div> </div>
</div> </div>