public Model findOrCreateTemplate ( String name , InputStream modelJson ) throws IOException { try { Model m = getTemplateByName ( name ) ; return m ; } catch ( IllegalArgumentException ignore ) { } String modelStr = IOUtils . toString ( modelJson , "UTF-8" ) ; return modelService . createModel ( new TypedString ( modelStr ) ) ; }
Tries to lookup the model by name and returns it if it s found . If not it is created from the provided JSON input stream .