Class TraceabilityFile
- java.lang.Object
-
- fr.gouv.vitam.logbook.common.model.TraceabilityFile
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class TraceabilityFile extends java.lang.Object implements java.lang.AutoCloseableUsed to handle zip file for traceability
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringcurrentHashstatic java.lang.StringpreviousTimestampTokenstatic java.lang.StringpreviousTimestampTokenMinusOneMonthstatic java.lang.StringpreviousTimestampTokenMinusOneYear
-
Constructor Summary
Constructors Constructor Description TraceabilityFile(java.io.File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()flush the stream and close it.voidcloseStoreLog()Close the extracted data filevoidinitStoreLog()Create a new file for extracted data.
Should be directly followed by one or multiple storeLog
Must be close with closeStoreLogvoidstoreAdditionalInformation(long numberOfLine, java.lang.String startDate, java.lang.String endDate)Add an additionalInformation file with the given data in the zipFilevoidstoreComputedInformation(java.lang.String currentHash, java.lang.String previousHash, java.lang.String currentHashMinusOneMonth, java.lang.String currentHashMinusOneYear)Add an computedInformation file with the traceability data in the zipFilevoidstoreLog(byte[] line)Add a line of extracted data in the recently created file.
Must be directly preceded by a call of initStoreLog or storeLogvoidstoreMerkleTree(MerkleTree merkleTree)Add a merkleTree file with the computed merkleTree in the zipFilevoidstoreTimeStampToken(byte[] timestampToken)Add a timestampToken file with the computed token of the traceability operation in the zipFile
-
-
-
Field Detail
-
previousTimestampToken
public static final java.lang.String previousTimestampToken
- See Also:
- Constant Field Values
-
previousTimestampTokenMinusOneMonth
public static final java.lang.String previousTimestampTokenMinusOneMonth
- See Also:
- Constant Field Values
-
previousTimestampTokenMinusOneYear
public static final java.lang.String previousTimestampTokenMinusOneYear
- See Also:
- Constant Field Values
-
currentHash
public static final java.lang.String currentHash
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TraceabilityFile
public TraceabilityFile(java.io.File file) throws java.io.FileNotFoundException, org.apache.commons.compress.archivers.ArchiveException- Parameters:
file- the targeted file to store tmp zip file- Throws:
java.io.FileNotFoundException- if the given file is missingorg.apache.commons.compress.archivers.ArchiveException- if any error occurs while creating ZipArchiveOutputStram
-
-
Method Detail
-
storeMerkleTree
public void storeMerkleTree(MerkleTree merkleTree) throws java.io.IOException
Add a merkleTree file with the computed merkleTree in the zipFile- Parameters:
merkleTree- the tree that should be store in zip- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
storeTimeStampToken
public void storeTimeStampToken(byte[] timestampToken) throws java.io.IOExceptionAdd a timestampToken file with the computed token of the traceability operation in the zipFile- Parameters:
timestampToken- of the traceability operation- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
initStoreLog
public void initStoreLog() throws java.io.IOExceptionCreate a new file for extracted data.
Should be directly followed by one or multiple storeLog
Must be close with closeStoreLog- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
storeLog
public void storeLog(byte[] line) throws java.io.IOExceptionAdd a line of extracted data in the recently created file.
Must be directly preceded by a call of initStoreLog or storeLog- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
closeStoreLog
public void closeStoreLog() throws java.io.IOExceptionClose the extracted data file- Throws:
java.io.IOException- if error on closing stream
-
storeAdditionalInformation
public void storeAdditionalInformation(long numberOfLine, java.lang.String startDate, java.lang.String endDate) throws java.io.IOExceptionAdd an additionalInformation file with the given data in the zipFile- Parameters:
numberOfLine- of the extracted data secured by the traceability processstartDate- of the traceability processendDate- of the traceability process- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
storeComputedInformation
public void storeComputedInformation(java.lang.String currentHash, java.lang.String previousHash, java.lang.String currentHashMinusOneMonth, java.lang.String currentHashMinusOneYear) throws java.io.IOExceptionAdd an computedInformation file with the traceability data in the zipFile- Parameters:
currentHash- hash of the new merkleTree rootpreviousHash- hash of the last traceability operation merkleTree rootcurrentHashMinusOneMonth- hash of the (Month - 1) traceability operation merkleTree rootcurrentHashMinusOneYear- hash of the (Year - 1) traceability operation merkleTree root- Throws:
java.io.IOException- if any error occurs while attempting to write in zip
-
close
public void close() throws java.io.IOExceptionflush the stream and close it.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.io.IOException- if error on closing stream
-
-