@ RequestMapping ( value = "/profile" , method = RequestMethod . POST ) public String post ( @ RequestParam ( required = false ) Collection < String > checkedScopes , @ RequestParam ( required = false ) String update , @ RequestParam ( required = false ) String delete , @ RequestParam ( required = false ) String clientId ) { String userId = getCurrentUserId ( ) ; if ( null != update ) { Map < String , List < DescribedApproval > > approvalsByClientId = getCurrentApprovalsForUser ( userId ) ; List < DescribedApproval > allApprovals = new ArrayList <> ( ) ; for ( List < DescribedApproval > clientApprovals : approvalsByClientId . values ( ) ) { allApprovals . addAll ( clientApprovals ) ; } if ( hasText ( clientId ) ) { allApprovals . removeIf ( da -> ! clientId . equals ( da . getClientId ( ) ) ) ; } for ( Approval approval : allApprovals ) { String namespacedScope = approval . getClientId ( ) + "-" + approval . getScope ( ) ; if ( checkedScopes != null && checkedScopes . contains ( namespacedScope ) ) { approval . setStatus ( Approval . ApprovalStatus . APPROVED ) ; } else { approval . setStatus ( Approval . ApprovalStatus . DENIED ) ; } } updateApprovals ( allApprovals ) ; } else if ( null != delete ) { deleteApprovalsForClient ( userId , clientId ) ; } return "redirect:profile" ; }
Handle form post for revoking chosen approvals