Package fr.gouv.vitam.logbook.administration.core

# Class LogbookOperationTraceabilityHelper

java.lang.Object
fr.gouv.vitam.logbook.administration.core.LogbookOperationTraceabilityHelper

All Implemented Interfaces:
  `LogbookTraceabilityHelper`

public class LogbookOperationTraceabilityHelper extends Object implements LogbookTraceabilityHelper

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `STP_OP_SECURISATION`

  ### Fields inherited from interface fr.gouv.vitam.logbook.common.traceability.LogbookTraceabilityHelper

  `INITIAL_START_DATE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LogbookOperationTraceabilityHelper(LogbookOperations logbookOperations, GUID operationID, int temporizationDelayInSeconds, int traceabilityExpirationInSeconds)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `createLogbookOperationEvent(Integer tenantId, String eventType, StatusCode status, TraceabilityEvent event)`
  Update or finalize the traceability entry in the logbook collection
  `long`
  `getDataSize()`
  Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIterator
  `boolean`
  `getMaxEntriesReached()`
  `String`
  `getPreviousMonthStartDate()`
  Get the first traceability (in logbook) one month before the given currentDate and return the startDate of the entry
  `byte[]`
  `getPreviousMonthTimestampToken()`
  Get the first traceability (in logbook) one month before the given currentDate and return the timestampToken of the entry
  `String`
  `getPreviousStartDate()`
  Get the last traceability (in logbook) event and return the startDate of the entry
  `byte[]`
  `getPreviousTimestampToken()`
  Get the last traceability (in logbook) event and return the timestampToken of the entry
  `String`
  `getPreviousYearStartDate()`
  Get the first traceability (in logbook) one year before the given currentDate and return the startDate of the entry
  `byte[]`
  `getPreviousYearTimestampToken()`
  Get the first traceability (in logbook) one year before the given currentDate and return the timestampToken of the entry
  `String`
  `getStepName()`
  `String`
  `getTimestampStepName()`
  `String`
  `getTraceabilityEndDate()`
  `String`
  `getTraceabilityStartDate()`
  `TraceabilityStatistics`
  `getTraceabilityStatistics()`
  `TraceabilityType`
  `getTraceabilityType()`
  `String`
  `getZipName()`
  `void`
  `initialize()`
  `boolean`
  `isTraceabilityOperationRequired()`
  `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(Integer tenantId)`
  Save the close master event if needed
  `void`
  `startTraceability()`
  Prepare and start the traceability operation
  `void`
  `storeAndDeleteZip(Integer tenant, String strategyId, File zipFile, String fileName, TraceabilityEvent event)`
  Store the temporary zip.

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

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

- ## Field Details

  - ### STP_OP_SECURISATION

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

- ## Constructor Details

  - ### LogbookOperationTraceabilityHelper

    public LogbookOperationTraceabilityHelper(LogbookOperations logbookOperations, GUID operationID, int temporizationDelayInSeconds, int traceabilityExpirationInSeconds)
    Parameters:
      `logbookOperations` - used to search the operation to secure
      `operationID` - guid of the traceability operation
      `temporizationDelayInSeconds` - temporization delay (in seconds) for recent logbook operation events.
      `traceabilityExpirationInSeconds` -

- ## Method Details

  - ### initialize

    public void initialize() throws TraceabilityException
    Throws:
      `TraceabilityException`

  - ### isTraceabilityOperationRequired

    public boolean isTraceabilityOperationRequired() throws TraceabilityException
    Throws:
      `TraceabilityException`

  - ### saveDataInZip

    public void saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file) throws 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 interface `LogbookTraceabilityHelper`
    Parameters:
      `algo` - algorithm used to generate MerkleTree with data.
      `file` - output zip to store data (in some TYPE_COLLECTION.json)
    Throws:
      `IOException` - if any error occurs while writing in traceabilityFile
      `TraceabilityException` - for any other errors specifically in the search / data transformation

  - ### getPreviousStartDate

    public 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 interface `LogbookTraceabilityHelper`
    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 interface `LogbookTraceabilityHelper`
    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 String getPreviousMonthStartDate() throws InvalidParseOperationException, TraceabilityException
    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 interface `LogbookTraceabilityHelper`
    Returns:
      the start date of the matching entry or null if no matching entry
    Throws:
      `InvalidParseOperationException` - if any errors occurs while deserializing entry's data.
      `TraceabilityException` - if any other error occurs

  - ### getPreviousMonthTimestampToken

    public byte[] getPreviousMonthTimestampToken() throws InvalidParseOperationException, TraceabilityException
    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 interface `LogbookTraceabilityHelper`
    Returns:
      the timestamp token of the matching entry or null if no matching entry
    Throws:
      `InvalidParseOperationException` - if any errors occurs while deserializing entry's data.
      `TraceabilityException` - if any other error occurs

  - ### getPreviousYearStartDate

    public String getPreviousYearStartDate() throws InvalidParseOperationException, TraceabilityException
    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 interface `LogbookTraceabilityHelper`
    Returns:
      the start date of the matching entry or null if no matching entry
    Throws:
      `InvalidParseOperationException` - if any errors occurs while deserializing entry's data.
      `TraceabilityException` - if any other error occurs

  - ### getPreviousYearTimestampToken

    public byte[] getPreviousYearTimestampToken() throws InvalidParseOperationException, TraceabilityException
    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 interface `LogbookTraceabilityHelper`
    Returns:
      the timestamp token of the matching entry or null if no matching entry
    Throws:
      `InvalidParseOperationException` - if any errors occurs while deserializing entry's data.
      `TraceabilityException` - if any other error occurs

  - ### startTraceability

    public void startTraceability() throws TraceabilityException
    Description copied from interface: `LogbookTraceabilityHelper`
    Prepare and start the traceability operation
    Specified by:
      `startTraceability` in interface `LogbookTraceabilityHelper`
    Throws:
      `TraceabilityException` - if any error occurs

  - ### createLogbookOperationEvent

    public void createLogbookOperationEvent(Integer tenantId, 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 interface `LogbookTraceabilityHelper`
    Parameters:
      `tenantId` - tenant used for the operation
      `eventType` - code of the eventType for the entry
      `status` - status of the entry
      `event` - data of the entry
    Throws:
      `TraceabilityException` - if any error occurs

  - ### saveEmpty

    public void saveEmpty(Integer tenantId) throws TraceabilityException
    Description copied from interface: `LogbookTraceabilityHelper`
    Save the close master event if needed
    Specified by:
      `saveEmpty` in interface `LogbookTraceabilityHelper`
    Parameters:
      `tenantId` - the tenant used for log
    Throws:
      `TraceabilityException`

  - ### storeAndDeleteZip

    public void storeAndDeleteZip(Integer tenant, String strategyId, File zipFile, String fileName, TraceabilityEvent event) throws TraceabilityException
    Description copied from interface: `LogbookTraceabilityHelper`
    Store the temporary zip.
    Specified by:
      `storeAndDeleteZip` in interface `LogbookTraceabilityHelper`
    Parameters:
      `tenant` - tenant used for the operation
      `strategyId` - strategy used for the storage
      `zipFile` - file containing multiple information about the traceability operation (data, merkle, computingData, ...)
      `fileName` - name of the file on the destination
      `event` - traceability event that should be updated by this operation
    Throws:
      `TraceabilityException` - if any error occurs

  - ### getStepName

    public String getStepName()
    Specified by:
      `getStepName` in interface `LogbookTraceabilityHelper`
    Returns:
      the main eventType code for the specific implementation class

  - ### getTimestampStepName

    public String getTimestampStepName()
    Specified by:
      `getTimestampStepName` in interface `LogbookTraceabilityHelper`
    Returns:
      the timestamp eventType code for the specific implementation class

  - ### getZipName

    public String getZipName()
    Specified by:
      `getZipName` in interface `LogbookTraceabilityHelper`
    Returns:
      the name of the tmp zip file

  - ### getTraceabilityType

    public TraceabilityType getTraceabilityType()
    Specified by:
      `getTraceabilityType` in interface `LogbookTraceabilityHelper`
    Returns:
      the traceabilityType of the implementation class

  - ### getMaxEntriesReached

    public boolean getMaxEntriesReached()
    Specified by:
      `getMaxEntriesReached` in interface `LogbookTraceabilityHelper`
    Returns:
      true if max entries reached (unit & object group lifecycle traceability operation are limited in size)

  - ### getTraceabilityStatistics

    public TraceabilityStatistics getTraceabilityStatistics()
    Specified by:
      `getTraceabilityStatistics` in interface `LogbookTraceabilityHelper`

  - ### getDataSize

    public long getDataSize() throws TraceabilityException
    Description copied from interface: `LogbookTraceabilityHelper`
    Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIterator
    Specified by:
      `getDataSize` in interface `LogbookTraceabilityHelper`
    Returns:
      the number of items secured in traceabilityIterator
    Throws:
      `TraceabilityException` - if the traceabilityIterator isn't yet initialized

  - ### getTraceabilityStartDate

    public String getTraceabilityStartDate()
    Specified by:
      `getTraceabilityStartDate` in interface `LogbookTraceabilityHelper`
    Returns:
      the start date of the traceability (computed from the end date of the last traceability)

  - ### getTraceabilityEndDate

    public String getTraceabilityEndDate()
    Specified by:
      `getTraceabilityEndDate` in interface `LogbookTraceabilityHelper`
    Returns:
      the end date of the traceability (now)