@ Override public void savePolicy ( Model model ) { if ( filePath . equals ( "" ) ) { throw new Error ( "invalid file path, file path cannot be empty" ) ; } StringBuilder tmp = new StringBuilder ( ) ; for ( Map . Entry < String , Assertion > entry : model . model . get ( "p" ) . entrySet ( ) ) { String ptype = entry . getKey ( ) ; Assertion ast = entry . getValue ( ) ; for ( List < String > rule : ast . policy ) { tmp . append ( ptype + ", " ) ; tmp . append ( Util . arrayToString ( rule ) ) ; tmp . append ( "\n" ) ; } } for ( Map . Entry < String , Assertion > entry : model . model . get ( "g" ) . entrySet ( ) ) { String ptype = entry . getKey ( ) ; Assertion ast = entry . getValue ( ) ; for ( List < String > rule : ast . policy ) { tmp . append ( ptype + ", " ) ; tmp . append ( Util . arrayToString ( rule ) ) ; tmp . append ( "\n" ) ; } } savePolicyFile ( tmp . toString ( ) . trim ( ) ) ; }
savePolicy saves all policy rules to the storage .