class VerifyTimeStampActionHandler extends ActionHandler {

    @Override
    public ItemStatus execute(WorkerParameters param, HandlerIO handler)
        throws ProcessingException {
        final ItemStatus itemStatus = new ItemStatus(HANDLER_ID);
        InputStream tokenFile = null;
        // 1- Get TraceabilityEventDetail from Workspace
        try {
            JsonNode traceabilityEvent =
                JsonHandler.getFromFile((File) handler.getInput(TRACEABILITY_EVENT_DETAIL_RANK));

            String operationFilePath = SedaConstants.TRACEABILITY_OPERATION_DIRECTORY + "/" +
                TIMESTAMP_FILENAME;
            tokenFile = handler.getInputStreamFromWorkspace(operationFilePath);
            String encodedTimeStampToken = IOUtils.toString(tokenFile, "UTF-8");

            // 1st part - lets check timestamp within the file is the same as the one saved in the traceabilityEvent
            final ItemStatus subItemStatusTokenComparison = new ItemStatus(HANDLER_SUB_ACTION_COMPARE_TOKEN_TIMESTAMP);
            try {
                compareTimeStamps(encodedTimeStampToken, traceabilityEvent);
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_COMPARE_TOKEN_TIMESTAMP,
                    subItemStatusTokenComparison.increment(StatusCode.OK));
            } catch (ProcessingException e) {
                LOGGER.error("Timestamps are not equal", e);
                // lets stop the process and return an error
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_COMPARE_TOKEN_TIMESTAMP, subItemStatusTokenComparison.increment(StatusCode.KO));
                return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus);
            }

            // 2nd part - using bouncy castle, lets validate the timestamp
            final ItemStatus subItemStatusTokenValidation = new ItemStatus(HANDLER_SUB_ACTION_VALIDATE_TOKEN_TIMESTAMP);
            try {
                validateTimestamp(encodedTimeStampToken);
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_VALIDATE_TOKEN_TIMESTAMP,
                    subItemStatusTokenValidation.increment(StatusCode.OK));
            } catch (ProcessingException e) {
                LOGGER.error("Timestamps is not valid", e);
                // lets stop the process and return an error
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_VALIDATE_TOKEN_TIMESTAMP,
                    subItemStatusTokenValidation.increment(StatusCode.KO));
                return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus);
            }

            final ItemStatus subItemStatusTokenVerification = new ItemStatus(HANDLER_SUB_ACTION_VERIFY_TOKEN_TIMESTAMP);
            try {
                String computingInformationPath = String.format("%s/%s", SedaConstants.TRACEABILITY_OPERATION_DIRECTORY, TRACEABILITY_COMPUTING_INFORMATION);
                String merkleTreePath = String.format("%s/%s", SedaConstants.TRACEABILITY_OPERATION_DIRECTORY, TRACEABILITY_MERKLE_TREE);
                verifyTimestamp(encodedTimeStampToken, computingInformationPath, merkleTreePath, handler);
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_VERIFY_TOKEN_TIMESTAMP,
                    subItemStatusTokenVerification.increment(StatusCode.OK));
            } catch (ProcessingException e) {
                LOGGER.error("Timestamps is not valid", e);
                // lets stop the process and return an error
                itemStatus.setItemsStatus(HANDLER_SUB_ACTION_VERIFY_TOKEN_TIMESTAMP,
                    subItemStatusTokenVerification.increment(StatusCode.KO));
                return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus);
            }

        } catch (InvalidParseOperationException | ContentAddressableStorageNotFoundException | IOException | ContentAddressableStorageServerException e) {
            LOGGER.error(e);
            itemStatus.increment(StatusCode.FATAL);
        } finally {
            IOUtils.closeQuietly(tokenFile);
        }

        return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, itemStatus);
    }

}