private String createNewObject ( FedoraClient fedora , String oid ) throws Exception { InputStream in = null ; byte [ ] template = null ; // Start by reading our FOXML template into memory try { if ( foxmlTemplate != null ) { // We have a user provided template in = new FileInputStream ( foxmlTemplate ) ; template = IOUtils . toByteArray ( in ) ; } else { // Use the built in template in = getClass ( ) . getResourceAsStream ( "/foxml_template.xml" ) ; template = IOUtils . toByteArray ( in ) ; } } catch ( IOException ex ) { throw new Exception ( "Error accessing FOXML Template, please check system configuration!" ) ; } finally { if ( in != null ) { in . close ( ) ; } } String vitalPid = fedora . getAPIM ( ) . ingest ( template , Strings . FOXML_VERSION , "ReDBox creating new object: '" + oid + "'" ) ; log . info ( "New VITAL PID: '{}'" , vitalPid ) ; return vitalPid ; }
Create a new VITAL object and return the PID .