public String permissionsToYml ( Collection < Permission > permissions ) { try { Map < String , Map < String , Set < Permission > > > map = new TreeMap <> ( ) ; permissions . forEach ( permission -> { map . putIfAbsent ( permission . getMsName ( ) , new TreeMap <> ( ) ) ; map . get ( permission . getMsName ( ) ) . putIfAbsent ( permission . getRoleKey ( ) , new TreeSet <> ( ) ) ; map . get ( permission . getMsName ( ) ) . get ( permission . getRoleKey ( ) ) . add ( permission ) ; } ) ; return mapper . writeValueAsString ( map ) ; } catch ( Exception e ) { log . error ( "Failed to create permissions YML file from collection, error: {}" , e . getMessage ( ) , e ) ; } return null ; }
Convert permissions collection to yml string .