public static FedoraEvent from ( final Event event ) { requireNonNull ( event ) ; try { @ SuppressWarnings ( "unchecked" ) final Map < String , String > info = new HashMap <> ( event . getInfo ( ) ) ; final String userdata = event . getUserData ( ) ; try { if ( userdata != null && ! userdata . isEmpty ( ) ) { final JsonNode json = MAPPER . readTree ( userdata ) ; if ( json . has ( BASE_URL ) ) { String url = json . get ( BASE_URL ) . asText ( ) ; while ( url . endsWith ( "/" ) ) { url = url . substring ( 0 , url . length ( ) - 1 ) ; } info . put ( BASE_URL , url ) ; } if ( json . has ( USER_AGENT ) ) { info . put ( USER_AGENT , json . get ( USER_AGENT ) . asText ( ) ) ; } } else { LOGGER . debug ( "Event UserData is empty!" ) ; } } catch ( final IOException ex ) { LOGGER . warn ( "Error extracting user data: " + userdata , ex . getMessage ( ) ) ; } final Set < String > resourceTypes = getResourceTypes ( event ) . collect ( toSet ( ) ) ; return new FedoraEventImpl ( valueOf ( event . getType ( ) ) , cleanPath ( event ) , resourceTypes , event . getUserID ( ) , FedoraSessionUserUtil . getUserURI ( event . getUserID ( ) ) , ofEpochMilli ( event . getDate ( ) ) , info ) ; } catch ( final RepositoryException ex ) { throw new RepositoryRuntimeException ( "Error converting JCR Event to FedoraEvent" , ex ) ; } }
Convert a JCR Event to a FedoraEvent