private static String serializedGraphForMessage ( final Message message , final Resource subject ) throws IOException { // serialize triples final ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream ( ) ; final Model model = createDefaultModel ( ) ; // get info from jms message headers @ SuppressWarnings ( "unchecked" ) final List < String > eventType = message . getHeader ( FCREPO_EVENT_TYPE , emptyList ( ) , List . class ) ; final String dateTime = message . getHeader ( FCREPO_DATE_TIME , EMPTY_STRING , String . class ) ; @ SuppressWarnings ( "unchecked" ) final List < String > agents = message . getHeader ( FCREPO_AGENT , emptyList ( ) , List . class ) ; @ SuppressWarnings ( "unchecked" ) final List < String > resourceTypes = message . getHeader ( FCREPO_RESOURCE_TYPE , emptyList ( ) , List . class ) ; final String identifier = message . getHeader ( FCREPO_URI , EMPTY_STRING , String . class ) ; final Optional < String > premisType = getAuditEventType ( eventType , resourceTypes ) ; model . add ( model . createStatement ( subject , type , INTERNAL_EVENT ) ) ; model . add ( model . createStatement ( subject , type , PREMIS_EVENT ) ) ; model . add ( model . createStatement ( subject , type , PROV_EVENT ) ) ; // basic event info model . add ( model . createStatement ( subject , PREMIS_TIME , createTypedLiteral ( dateTime , XSDdateTime ) ) ) ; model . add ( model . createStatement ( subject , PREMIS_OBJ , createResource ( identifier ) ) ) ; agents . forEach ( agent -> { model . add ( model . createStatement ( subject , PREMIS_AGENT , createTypedLiteral ( agent , XSDstring ) ) ) ; } ) ; premisType . ifPresent ( rdfType -> { model . add ( model . createStatement ( subject , PREMIS_TYPE , createResource ( rdfType ) ) ) ; } ) ; write ( serializedGraph , model , NTRIPLES ) ; return serializedGraph . toString ( "UTF-8" ) ; }
Convert a Camel message to audit event description .