private void preIngestIfNeeded ( boolean firstRun , DOManager doManager , RDFName objectName ) throws Exception { PID pid = new PID ( objectName . uri . substring ( "info:fedora/" . length ( ) ) ) ; boolean exists = doManager . objectExists ( pid . toString ( ) ) ; if ( exists && firstRun ) { logger . info ( "Purging old system object: {}" , pid ) ; Context context = ReadOnlyContext . getContext ( null , null , null , false ) ; DOWriter w = doManager . getWriter ( USE_DEFINITIVE_STORE , context , pid . toString ( ) ) ; w . remove ( ) ; try { w . commit ( "Purged by Fedora at startup (to be re-ingested)" ) ; exists = false ; } finally { doManager . releaseWriter ( w ) ; } } if ( ! exists ) { logger . info ( "Ingesting new system object: {}" , pid ) ; InputStream xml = getStream ( "org/fcrepo/server/resources/" + pid . toFilename ( ) + ".xml" ) ; Context context = ReadOnlyContext . getContext ( null , null , null , false ) ; DOWriter w = doManager . getIngestWriter ( USE_DEFINITIVE_STORE , context , xml , Constants . FOXML1_1 . uri , "UTF-8" , null ) ; try { w . commit ( "Pre-ingested by Fedora at startup" ) ; } finally { doManager . releaseWriter ( w ) ; } } }
Ingests the given system object if it doesn t exist OR if it exists but this instance of Fedora has never been started . This ensures that upon upgrade the old system object is replaced with the new one .