public void process ( final Exchange exchange ) throws Exception { final Message in = exchange . getIn ( ) ; final String contentType = in . getHeader ( CONTENT_TYPE , "" , String . class ) ; final String body = in . getBody ( String . class ) ; final Set < String > endpoints = new HashSet <> ( ) ; for ( final String s : in . getHeader ( REINDEXING_RECIPIENTS , "" , String . class ) . split ( "," ) ) { endpoints . add ( s . trim ( ) ) ; } if ( contentType . equals ( "application/json" ) && body != null && ! body . trim ( ) . isEmpty ( ) ) { try { final JsonNode root = MAPPER . readTree ( body ) ; final Iterator < JsonNode > ite = root . elements ( ) ; while ( ite . hasNext ( ) ) { final JsonNode n = ite . next ( ) ; endpoints . add ( n . asText ( ) ) ; } } catch ( JsonProcessingException e ) { LOGGER . debug ( "Invalid JSON" , e ) ; in . setHeader ( HTTP_RESPONSE_CODE , BAD_REQUEST ) ; in . setBody ( "Invalid JSON" ) ; } } in . setHeader ( REINDEXING_RECIPIENTS , join ( "," , endpoints ) ) ; }
Convert the incoming REST request into the correct Fcrepo header fields .