@ Override public void renameRole ( String oldrole , String newrole ) throws RolesException { if ( role_list . containsKey ( oldrole ) ) { List < String > users_with_role = role_list . get ( oldrole ) ; for ( String user : users_with_role ) { // Remove the role from this user List < String > roles_of_user = user_list . get ( user ) ; roles_of_user . remove ( oldrole ) ; roles_of_user . add ( newrole ) ; user_list . put ( user , roles_of_user ) ; // Update our file_store String roles = StringUtils . join ( roles_of_user . toArray ( new String [ 0 ] ) , "," ) ; file_store . setProperty ( user , roles ) ; } // Replace the role entry role_list . remove ( oldrole ) ; role_list . put ( newrole , users_with_role ) ; // And commit the file_store to disk try { saveRoles ( ) ; } catch ( IOException e ) { throw new RolesException ( e ) ; } } else { throw new RolesException ( "Cannot find role '" + oldrole + "'!" ) ; } }
Rename a role .