@@ -80,6 +80,7 @@ public RoleController(RoleRepository roleRepository,
8080 }
8181
8282 @ GetMapping ("" )
83+ @ Transactional (readOnly = true )
8384 public ResponseEntity <Page <Role >> rolesByApplication (@ Parameter (hidden = true ) User user ,
8485 @ RequestParam (value = "force" , required = false , defaultValue = "true" ) boolean force ,
8586 @ RequestParam (value = "query" , required = false , defaultValue = "" ) String query ,
@@ -89,7 +90,7 @@ public ResponseEntity<Page<Role>> rolesByApplication(@Parameter(hidden = true) U
8990 @ RequestParam (value = "sortDirection" , required = false , defaultValue = "ASC" ) String sortDirection ) {
9091 LOG .debug (String .format ("/roles for user %s" , user .getEduPersonPrincipalName ()));
9192
92- Page <Map < String , Object > > rolesPage ;
93+ Page <Role > rolesPage ;
9394 if (user .isSuperUser ()) {
9495 if (force ) {
9596 Pageable pageable = PageRequest .of (0 , Integer .MAX_VALUE );
@@ -106,13 +107,14 @@ public ResponseEntity<Page<Role>> rolesByApplication(@Parameter(hidden = true) U
106107 rolesPage = roleRepository .searchByPageAndOrganizationGUID (user .getOrganizationGUID (), pageable );
107108
108109 }
109- List <Long > roleIdentifiers = rolesPage .getContent ().stream ().map (m -> ( Long ) m . get ( "id" )).toList ();
110+ List <Long > roleIdentifiers = rolesPage .getContent ().stream ().map (role -> role . getId ( )).toList ();
110111 List <Map <String , Object >> applications = roleRepository .findApplications (roleIdentifiers );
111112 List <Role > roles = manage .addManageMetaData (this .roleFromQuery (rolesPage , applications ));
112113 return Pagination .of (rolesPage , roles );
113114 }
114115
115116 @ GetMapping ("{id}" )
117+ @ Transactional (readOnly = true )
116118 public ResponseEntity <Role > role (@ PathVariable ("id" ) Long id , @ Parameter (hidden = true ) User user ) {
117119 LOG .debug (String .format ("/role/%s for user %s" , id , user .getEduPersonPrincipalName ()));
118120
@@ -123,6 +125,7 @@ public ResponseEntity<Role> role(@PathVariable("id") Long id, @Parameter(hidden
123125 }
124126
125127 @ GetMapping ("/application/{manageId}" )
128+ @ Transactional (readOnly = true )
126129 public ResponseEntity <List <Role >> rolesPerApplicationId (@ PathVariable ("manageId" ) String manageId , @ Parameter (hidden = true ) User user ) {
127130 LOG .debug (String .format ("/rolesPerApplicationId for user %s" , user .getEduPersonPrincipalName ()));
128131
@@ -248,17 +251,8 @@ private ResponseEntity<Role> saveOrUpdate(Role role, User user) {
248251 }
249252
250253 //See RoleRepository#searchByPage
251- private List <Role > roleFromQuery (Page <Map <String , Object >> rolesPage , List <Map <String , Object >> applications ) {
252- List <Role > roles = rolesPage .getContent ().stream ().map (m -> new Role (
253- (Long ) m .get ("id" ),
254- (String ) m .get ("name" ),
255- (String ) m .get ("description" ),
256- (Long ) m .get ("userRoleCount" ),
257- (Integer ) m .get ("defaultExpiryDays" ),
258- (boolean ) m .get ("enforceEmailEquality" ),
259- (boolean ) m .get ("eduIDOnly" ),
260- (boolean ) m .get ("overrideSettingsAllowed" )
261- )).toList ();
254+ private List <Role > roleFromQuery (Page <Role > rolesPage , List <Map <String , Object >> applications ) {
255+ List <Role > roles = rolesPage .getContent ();
262256
263257 //Now add all applications, note that we need to preserve ordering of the roles
264258 Map <Long , List <Map <String , Object >>> applicationGroupedByRoleId =
0 commit comments