public static Map < String , Attachment > loadAttachments ( InputStream in ) throws IOException { ObjectMapper mapper = new ObjectMapper ( ) ; TypeReference < TreeMap < String , Attachment > > typeRef = new TypeReference < TreeMap < String , Attachment > > ( ) { } ; TreeMap < String , Attachment > attachments ; try { attachments = mapper . readValue ( in , typeRef ) ; LOG . info ( "Attachments could be loaded" ) ; for ( Map . Entry < String , Attachment > entry : attachments . entrySet ( ) ) { Attachment currentAttachment = entry . getValue ( ) ; if ( ! validateAttachment ( currentAttachment ) ) { throw new IOException ( "Attachment is not valid: " + currentAttachment . getAlternateId ( ) ) ; } } return attachments ; } catch ( IOException e ) { throw new IOException ( "Attachments in the given file can not be loaded." ) ; } }
reads the attachments from the given inputstream and returns the attachment db