Package fr.gouv.vitam.logbook.common.model

# Class TraceabilityFile

java.lang.Object
fr.gouv.vitam.logbook.common.model.TraceabilityFile

All Implemented Interfaces:
  `AutoCloseable`

public class TraceabilityFile extends Object implements AutoCloseable
Used to handle zip file for traceability

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `currentHash`
  `static final String`
  `previousTimestampToken`
  `static final String`
  `previousTimestampTokenMinusOneMonth`
  `static final String`
  `previousTimestampTokenMinusOneYear`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TraceabilityFile(File file)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  flush the stream and close it.
  `void`
  `closeStoreLog()`
  Close the extracted data file
  `void`
  `initStoreLog()`
  Create a new file for extracted data.
  Should be directly followed by one or multiple storeLog
  Must be close with closeStoreLog
  `void`
  `storeAdditionalInformation(long numberOfLine, String startDate, String endDate)`
  Add an additionalInformation file with the given data in the zipFile
  `void`
  `storeComputedInformation(String currentHash, String previousHash, String currentHashMinusOneMonth, String currentHashMinusOneYear)`
  Add an computedInformation file with the traceability data in the zipFile
  `void`
  `storeLog(byte[] line)`
  Add a line of extracted data in the recently created file.
  Must be directly preceded by a call of initStoreLog or storeLog
  `void`
  `storeMerkleTree(MerkleTree merkleTree)`
  Add a merkleTree file with the computed merkleTree in the zipFile
  `void`
  `storeTimeStampToken(byte[] timestampToken)`
  Add a timestampToken file with the computed token of the traceability operation in the zipFile

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### previousTimestampToken

    public static final String previousTimestampToken
    See Also:
      - Constant Field Values

  - ### previousTimestampTokenMinusOneMonth

    public static final String previousTimestampTokenMinusOneMonth
    See Also:
      - Constant Field Values

  - ### previousTimestampTokenMinusOneYear

    public static final String previousTimestampTokenMinusOneYear
    See Also:
      - Constant Field Values

  - ### currentHash

    public static final String currentHash
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TraceabilityFile

    public TraceabilityFile(File file) throws FileNotFoundException, org.apache.commons.compress.archivers.ArchiveException
    Parameters:
      `file` - the targeted file to store tmp zip file
    Throws:
      `FileNotFoundException` - if the given file is missing
      `org.apache.commons.compress.archivers.ArchiveException` - if any error occurs while creating ZipArchiveOutputStram

- ## Method Details

  - ### storeMerkleTree

    public void storeMerkleTree(MerkleTree merkleTree) throws IOException
    Add a merkleTree file with the computed merkleTree in the zipFile
    Parameters:
      `merkleTree` - the tree that should be store in zip
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### storeTimeStampToken

    public void storeTimeStampToken(byte[] timestampToken) throws IOException
    Add a timestampToken file with the computed token of the traceability operation in the zipFile
    Parameters:
      `timestampToken` - of the traceability operation
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### initStoreLog

    public void initStoreLog() throws IOException
    Create a new file for extracted data.
    Should be directly followed by one or multiple storeLog
    Must be close with closeStoreLog
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### storeLog

    public void storeLog(byte[] line) throws IOException
    Add a line of extracted data in the recently created file.
    Must be directly preceded by a call of initStoreLog or storeLog
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### closeStoreLog

    public void closeStoreLog() throws IOException
    Close the extracted data file
    Throws:
      `IOException` - if error on closing stream

  - ### storeAdditionalInformation

    public void storeAdditionalInformation(long numberOfLine, String startDate, String endDate) throws IOException
    Add an additionalInformation file with the given data in the zipFile
    Parameters:
      `numberOfLine` - of the extracted data secured by the traceability process
      `startDate` - of the traceability process
      `endDate` - of the traceability process
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### storeComputedInformation

    public void storeComputedInformation(String currentHash, String previousHash, String currentHashMinusOneMonth, String currentHashMinusOneYear) throws IOException
    Add an computedInformation file with the traceability data in the zipFile
    Parameters:
      `currentHash` - hash of the new merkleTree root
      `previousHash` - hash of the last traceability operation merkleTree root
      `currentHashMinusOneMonth` - hash of the (Month - 1) traceability operation merkleTree root
      `currentHashMinusOneYear` - hash of the (Year - 1) traceability operation merkleTree root
    Throws:
      `IOException` - if any error occurs while attempting to write in zip

  - ### close

    public void close() throws IOException
    flush the stream and close it.
    Specified by:
      `close` in interface `AutoCloseable`
    Throws:
      `IOException` - if error on closing stream