public static WebOperation getOperationByName ( final String name ) throws WebOperationNotFoundException { if ( ! cache . containsKey ( name ) ) { WebOperation wo = null ; Map < String , Object > cls = Objects . find ( ( List < Map < String , Object > > ) Options . getStorage ( ) . getSystem ( List . class , "webOperations" , new ArrayList ( ) ) , new Closure < Map < String , Object > , Boolean > ( ) { @ Override public Boolean call ( Map < String , Object > input ) { return name . equals ( Objects . get ( input , "name" ) ) ; } } ) ; if ( ! Objects . isNullOrEmpty ( cls ) ) { try { wo = ( WebOperation ) Class . forName ( Objects . get ( String . class , cls , "class" ) ) . newInstance ( ) ; wo . setConfig ( Objects . get ( cls , "config" , Objects . newHashMap ( String . class , Object . class ) ) ) ; } catch ( Exception e ) { throw new WebOperationNotFoundException ( "Cannot initialize WebOperation (" + cls + "): " + e . getMessage ( ) , e ) ; } } if ( wo == null ) throw new WebOperationNotFoundException ( "WebOperation " + name + " not found" ) ; cache . put ( name , wo ) ; } return cache . get ( name ) ; }
Get WebOperation by name