private void addAuditDatastream ( Feed feed , DigitalObject obj , ZipOutputStream zout , String encoding ) throws ObjectIntegrityException , StreamIOException { if ( obj . getAuditRecords ( ) . size ( ) == 0 ) { return ; } String dsId = PID . toURI ( obj . getPid ( ) ) + "/AUDIT" ; String dsvId = dsId + "/" + DateUtility . convertDateToString ( obj . getCreateDate ( ) ) ; Entry dsEntry = feed . addEntry ( ) ; dsEntry . setId ( dsId ) ; dsEntry . setTitle ( "AUDIT" ) ; dsEntry . setUpdated ( obj . getCreateDate ( ) ) ; // create date? dsEntry . addCategory ( MODEL . STATE . uri , "A" , null ) ; dsEntry . addCategory ( MODEL . CONTROL_GROUP . uri , "X" , null ) ; dsEntry . addCategory ( MODEL . VERSIONABLE . uri , "false" , null ) ; dsEntry . addLink ( dsvId , Link . REL_ALTERNATE ) ; Entry dsvEntry = feed . addEntry ( ) ; dsvEntry . setId ( dsvId ) ; dsvEntry . setTitle ( "AUDIT.0" ) ; dsvEntry . setUpdated ( obj . getCreateDate ( ) ) ; ThreadHelper . addInReplyTo ( dsvEntry , PID . toURI ( obj . getPid ( ) ) + "/AUDIT" ) ; dsvEntry . addCategory ( MODEL . FORMAT_URI . uri , AUDIT1_0 . uri , null ) ; dsvEntry . addCategory ( MODEL . LABEL . uri , "Audit Trail for this object" , null ) ; if ( m_format . equals ( ATOM_ZIP1_1 ) ) { String name = "AUDIT.0.xml" ; try { zout . putNextEntry ( new ZipEntry ( name ) ) ; ReadableCharArrayWriter buf = new ReadableCharArrayWriter ( 512 ) ; PrintWriter pw = new PrintWriter ( buf ) ; DOTranslationUtility . appendAuditTrail ( obj , pw ) ; pw . close ( ) ; IOUtils . copy ( buf . toReader ( ) , zout , encoding ) ; zout . closeEntry ( ) ; } catch ( IOException e ) { throw new StreamIOException ( e . getMessage ( ) , e ) ; } IRI iri = new IRI ( name ) ; dsvEntry . setSummary ( "AUDIT.0" ) ; dsvEntry . setContent ( iri , "text/xml" ) ; } else { dsvEntry . setContent ( DOTranslationUtility . getAuditTrail ( obj ) , "text/xml" ) ; } }
AUDIT datastream is rebuilt from the latest in - memory audit trail which is a separate array list in the DigitalObject class . Audit trail datastream re - created from audit records . There is only ONE version of the audit trail datastream