private NotificationResponse readFromFile ( String filename ) { NotificationResponse rslt ; logger . debug ( "Preparing to read from file: {}" , filename ) ; URL location = getClass ( ) . getClassLoader ( ) . getResource ( filename ) ; if ( location != null ) { try { File f = new File ( location . toURI ( ) ) ; rslt = mapper . readValue ( f , NotificationResponse . class ) ; } catch ( Exception e ) { String msg = "Failed to read the data file: " + location ; logger . error ( msg , e ) ; rslt = prepareErrorResponse ( getName ( ) , msg ) ; } } else { String msg = "Data file not found: " + filename ; rslt = prepareErrorResponse ( getName ( ) , msg ) ; } return rslt ; }
Deserialize the given JSON formatted file back into a object .