protected File getContentSrcAsFile ( IRI contentSrc , File tempDir ) throws ObjectIntegrityException , IOException { if ( contentSrc . isAbsolute ( ) || contentSrc . isPathAbsolute ( ) ) { throw new ObjectIntegrityException ( "contentSrc must not be absolute" ) ; } try { // Normalize the IRI to resolve percent-encoding and // backtracking (e.g. "../") NormalizedURI nUri = new NormalizedURI ( tempDir . toURI ( ) . toString ( ) + contentSrc . toString ( ) ) ; nUri . normalize ( ) ; File f = new File ( nUri . toURI ( ) ) ; if ( f . getParentFile ( ) . equals ( tempDir ) ) { File temp = File . createTempFile ( "binary-datastream" , null ) ; FileUtils . move ( f , temp ) ; temp . deleteOnExit ( ) ; return temp ; //return f; } else { throw new ObjectIntegrityException ( contentSrc . toString ( ) + " is not a valid path." ) ; } } catch ( URISyntaxException e ) { throw new ObjectIntegrityException ( e . getMessage ( ) , e ) ; } }
Returns the an Entry s contentSrc as a File relative to the tempDir param .