protected static Function < Triple , Triple > convertMementoReferences ( final IdentifierConverter < Resource , FedoraResource > translator , final IdentifierConverter < Resource , FedoraResource > internalTranslator ) { return t -> { final String subjectURI = t . getSubject ( ) . getURI ( ) ; // Remove any hash components from the subject while locating the original resource final String subjectPath ; final int hashIndex = subjectURI . indexOf ( "#" ) ; if ( hashIndex != - 1 ) { subjectPath = subjectURI . substring ( 0 , hashIndex ) ; } else { subjectPath = subjectURI ; } final Resource subject = createResource ( subjectPath ) ; final FedoraResource subjResc = translator . convert ( subject ) ; org . apache . jena . graph . Node subjectNode = translator . reverse ( ) . convert ( subjResc . getOriginalResource ( ) ) . asNode ( ) ; // Add the hash component back into the subject uri. Note: we cannot convert the memento hash URI // to the original as a jcr node, as the hash may not exist for the original at this point. if ( hashIndex != - 1 ) { subjectNode = createURI ( subjectNode . getURI ( ) + subjectURI . substring ( hashIndex ) ) ; } org . apache . jena . graph . Node objectNode = t . getObject ( ) ; if ( t . getObject ( ) . isURI ( ) ) { final Resource object = createResource ( t . getObject ( ) . getURI ( ) ) ; if ( internalTranslator . inDomain ( object ) ) { final FedoraResource objResc = internalTranslator . convert ( object ) ; final Resource newObject = translator . reverse ( ) . convert ( objResc ) ; objectNode = newObject . asNode ( ) ; } } return new Triple ( subjectNode , t . getPredicate ( ) , objectNode ) ; } ; }
Returns a function that converts the subject to the original URI and the object of a triple from an undereferenceable internal identifier back to it s original external resource path . If the object is not an internal identifier the object is returned .