Class LogbookStorageTraceabilityHelper
- java.lang.Object
-
- fr.gouv.vitam.storage.engine.server.storagetraceability.LogbookStorageTraceabilityHelper
-
- All Implemented Interfaces:
LogbookTraceabilityHelper
public class LogbookStorageTraceabilityHelper extends java.lang.Object implements LogbookTraceabilityHelper
Handle specific steps of the traceability process for Storage
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
STP_STORAGE_SECURISATION
-
Fields inherited from interface fr.gouv.vitam.logbook.common.traceability.LogbookTraceabilityHelper
INITIAL_START_DATE
-
-
Constructor Summary
Constructors Constructor Description LogbookStorageTraceabilityHelper(LogbookOperationsClient logbookOperations, WorkspaceClient workspaceClient, TraceabilityStorageService traceabilityLogbookService, GUID operationID, int overlapDelayInSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createLogbookOperationEvent(java.lang.Integer tenantId, java.lang.String eventType, StatusCode status, TraceabilityEvent event)
Update or finalize the traceability entry in the logbook collectionlong
getDataSize()
Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIteratorboolean
getMaxEntriesReached()
java.lang.String
getPreviousMonthStartDate()
Get the first traceability (in logbook) one month before the given currentDate and return the startDate of the entrybyte[]
getPreviousMonthTimestampToken()
Get the first traceability (in logbook) one month before the given currentDate and return the timestampToken of the entryjava.lang.String
getPreviousStartDate()
Get the last traceability (in logbook) event and return the startDate of the entrybyte[]
getPreviousTimestampToken()
Get the last traceability (in logbook) event and return the timestampToken of the entryjava.lang.String
getPreviousYearStartDate()
Get the first traceability (in logbook) one year before the given currentDate and return the startDate of the entrybyte[]
getPreviousYearTimestampToken()
Get the first traceability (in logbook) one year before the given currentDate and return the timestampToken of the entryjava.lang.String
getStepName()
java.lang.String
getTimestampStepName()
java.lang.String
getTraceabilityEndDate()
java.lang.String
getTraceabilityStartDate()
TraceabilityStatistics
getTraceabilityStatistics()
TraceabilityType
getTraceabilityType()
java.lang.String
getZipName()
void
saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file)
Search for entries to secure with the traceability process and store data in the given Traceability zip file.
Also, Merkle Algorithm should be updated by adding each wanted entry as a leaf of the tree.void
saveEmpty(java.lang.Integer tenantId)
Save the close master event if neededvoid
startTraceability()
Prepare and start the traceability operationvoid
storeAndDeleteZip(java.lang.Integer tenant, java.lang.String strategyId, java.io.File zipFile, java.lang.String fileName, TraceabilityEvent event)
Store the temporary zip.
-
-
-
Field Detail
-
STP_STORAGE_SECURISATION
public static final java.lang.String STP_STORAGE_SECURISATION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LogbookStorageTraceabilityHelper
public LogbookStorageTraceabilityHelper(LogbookOperationsClient logbookOperations, WorkspaceClient workspaceClient, TraceabilityStorageService traceabilityLogbookService, GUID operationID, int overlapDelayInSeconds)
- Parameters:
logbookOperations
- used to search the operation to secureoperationID
- guid of the traceability operationoverlapDelayInSeconds
- the overlap delay in second used to avoid to forgot logbook operation for traceability
-
-
Method Detail
-
saveDataInZip
public void saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file) throws java.io.IOException, TraceabilityException
Description copied from interface:LogbookTraceabilityHelper
Search for entries to secure with the traceability process and store data in the given Traceability zip file.
Also, Merkle Algorithm should be updated by adding each wanted entry as a leaf of the tree.- Specified by:
saveDataInZip
in interfaceLogbookTraceabilityHelper
- Parameters:
algo
- algorithm used to generate MerkleTree with data.file
- output zip to store data (in some TYPE_COLLECTION.json)- Throws:
java.io.IOException
- if any error occurs while writing in traceabilityFileTraceabilityException
- for any other errors specifically in the search / data transformation
-
getPreviousStartDate
public java.lang.String getPreviousStartDate() throws InvalidParseOperationException
Description copied from interface:LogbookTraceabilityHelper
Get the last traceability (in logbook) event and return the startDate of the entry- Specified by:
getPreviousStartDate
in interfaceLogbookTraceabilityHelper
- Returns:
- the start date of the last traceability entry
- Throws:
InvalidParseOperationException
- if any errors occurs while deserializing entry's data.
-
getPreviousTimestampToken
public byte[] getPreviousTimestampToken() throws InvalidParseOperationException
Description copied from interface:LogbookTraceabilityHelper
Get the last traceability (in logbook) event and return the timestampToken of the entry- Specified by:
getPreviousTimestampToken
in interfaceLogbookTraceabilityHelper
- Returns:
- the timestamp token of the last traceability entry or null if no previous traceability OK for that type
- Throws:
InvalidParseOperationException
- if any errors occurs while deserializing entry's data.
-
getPreviousMonthStartDate
public java.lang.String getPreviousMonthStartDate()
Description copied from interface:LogbookTraceabilityHelper
Get the first traceability (in logbook) one month before the given currentDate and return the startDate of the entry- Specified by:
getPreviousMonthStartDate
in interfaceLogbookTraceabilityHelper
- Returns:
- the start date of the matching entry or null if no matching entry
-
getPreviousMonthTimestampToken
public byte[] getPreviousMonthTimestampToken()
Description copied from interface:LogbookTraceabilityHelper
Get the first traceability (in logbook) one month before the given currentDate and return the timestampToken of the entry- Specified by:
getPreviousMonthTimestampToken
in interfaceLogbookTraceabilityHelper
- Returns:
- the timestamp token of the matching entry or null if no matching entry
-
getPreviousYearStartDate
public java.lang.String getPreviousYearStartDate()
Description copied from interface:LogbookTraceabilityHelper
Get the first traceability (in logbook) one year before the given currentDate and return the startDate of the entry- Specified by:
getPreviousYearStartDate
in interfaceLogbookTraceabilityHelper
- Returns:
- the start date of the matching entry or null if no matching entry
-
getPreviousYearTimestampToken
public byte[] getPreviousYearTimestampToken()
Description copied from interface:LogbookTraceabilityHelper
Get the first traceability (in logbook) one year before the given currentDate and return the timestampToken of the entry- Specified by:
getPreviousYearTimestampToken
in interfaceLogbookTraceabilityHelper
- Returns:
- the timestamp token of the matching entry or null if no matching entry
-
startTraceability
public void startTraceability() throws TraceabilityException
Description copied from interface:LogbookTraceabilityHelper
Prepare and start the traceability operation- Specified by:
startTraceability
in interfaceLogbookTraceabilityHelper
- Throws:
TraceabilityException
- if any error occurs
-
createLogbookOperationEvent
public void createLogbookOperationEvent(java.lang.Integer tenantId, java.lang.String eventType, StatusCode status, TraceabilityEvent event) throws TraceabilityException
Description copied from interface:LogbookTraceabilityHelper
Update or finalize the traceability entry in the logbook collection- Specified by:
createLogbookOperationEvent
in interfaceLogbookTraceabilityHelper
- Parameters:
tenantId
- tenant used for the operationeventType
- code of the eventType for the entrystatus
- status of the entryevent
- data of the entry- Throws:
TraceabilityException
- if any error occurs
-
saveEmpty
public void saveEmpty(java.lang.Integer tenantId) throws TraceabilityException
Description copied from interface:LogbookTraceabilityHelper
Save the close master event if needed- Specified by:
saveEmpty
in interfaceLogbookTraceabilityHelper
- Parameters:
tenantId
- the tenant used for log- Throws:
TraceabilityException
-
storeAndDeleteZip
public void storeAndDeleteZip(java.lang.Integer tenant, java.lang.String strategyId, java.io.File zipFile, java.lang.String fileName, TraceabilityEvent event) throws TraceabilityException
Description copied from interface:LogbookTraceabilityHelper
Store the temporary zip.- Specified by:
storeAndDeleteZip
in interfaceLogbookTraceabilityHelper
- Parameters:
tenant
- tenant used for the operationstrategyId
- strategy used for the storagezipFile
- file containing multiple information about the traceability operation (data, merkle, computingData, ...)fileName
- name of the file on the destinationevent
- traceability event that should be updated by this operation- Throws:
TraceabilityException
- if any error occurs
-
getStepName
public java.lang.String getStepName()
- Specified by:
getStepName
in interfaceLogbookTraceabilityHelper
- Returns:
- the main eventType code for the specific implementation class
-
getTimestampStepName
public java.lang.String getTimestampStepName()
- Specified by:
getTimestampStepName
in interfaceLogbookTraceabilityHelper
- Returns:
- the timestamp eventType code for the specific implementation class
-
getZipName
public java.lang.String getZipName()
- Specified by:
getZipName
in interfaceLogbookTraceabilityHelper
- Returns:
- the name of the tmp zip file
-
getTraceabilityType
public TraceabilityType getTraceabilityType()
- Specified by:
getTraceabilityType
in interfaceLogbookTraceabilityHelper
- Returns:
- the traceabilityType of the implementation class
-
getMaxEntriesReached
public boolean getMaxEntriesReached()
- Specified by:
getMaxEntriesReached
in interfaceLogbookTraceabilityHelper
- Returns:
- true if max entries reached (unit & object group lifecycle traceability operation are limited in size)
-
getTraceabilityStatistics
public TraceabilityStatistics getTraceabilityStatistics()
- Specified by:
getTraceabilityStatistics
in interfaceLogbookTraceabilityHelper
-
getDataSize
public long getDataSize()
Description copied from interface:LogbookTraceabilityHelper
Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIterator- Specified by:
getDataSize
in interfaceLogbookTraceabilityHelper
- Returns:
- the number of items secured in traceabilityIterator
-
getTraceabilityStartDate
public java.lang.String getTraceabilityStartDate()
- Specified by:
getTraceabilityStartDate
in interfaceLogbookTraceabilityHelper
- Returns:
- the start date of the traceability (computed from the end date of the last traceability)
-
getTraceabilityEndDate
public java.lang.String getTraceabilityEndDate()
- Specified by:
getTraceabilityEndDate
in interfaceLogbookTraceabilityHelper
- Returns:
- the end date of the traceability (now)
-
-