Interface EntityVersioningManager

All Known Implementing Classes:
EntityVersioningManagerImpl, EntityVersioningManagerWithStats, NoOpEntityVersioningManager

public interface EntityVersioningManager
Since:
v8.9
  • Field Details

    • NO_OP_ENTITY_VERSION

      static final EntityVersion NO_OP_ENTITY_VERSION
      Used for implementations not using the real source of versioning data to distinguish from a situation where no version was actually found.
  • Method Details

    • incrementIssueVersion

      void incrementIssueVersion(long issueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified issue. If a version number doesn't exist, one is created.
      Parameters:
      issueId - identifier for the issue whose version should be bumped
      Throws:
      IncrementDeletedEntityVersionException - if issueId is related to an issue version which is marked as deleted
    • incrementIssueVersionAndGet

      Optional<Long> incrementIssueVersionAndGet(long issueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified issue and retrieves it in the same transaction. If a version number doesn't exist, one is created.
      Parameters:
      issueId - identifier for the issue whose version should be bumped
      Returns:
      the new version for the entity, or Optional.empty() if one could not be found.
      Throws:
      IncrementDeletedEntityVersionException - if issueId is related to an issue version which is marked as deleted
      Since:
      11.1
    • incrementIssueVersionsAndGet

      Map<Long,Long> incrementIssueVersionsAndGet(List<Long> issueIds)
      Increments the version number for the specified issues and retrieves it in the same transaction. - If a version number doesn't exist, one is created. - If a version number can't be created, the issue id will not be present in the returned map.
      Parameters:
      issueIds - identifiers for the issues whose versions should be bumped
      Returns:
      a map of issue id to new version for all the entities that were successfully updated or initialised with a new version.
      Since:
      11.2
    • incrementCommentVersion

      void incrementCommentVersion(long commentId, long parentIssueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified comment. If a version number doesn't exist, one is created.
      Parameters:
      commentId - identifier for the comment whose version should be bumped
      parentIssueId - identifier for the Issue that the comment belongs to
      Throws:
      IncrementDeletedEntityVersionException - if commentId is related to a deleted comment version which is marked as deleted
    • incrementCommentVersionAndGet

      Optional<Long> incrementCommentVersionAndGet(long commentId, long parentIssueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified comment. If a version number doesn't exist, one is created.
      Parameters:
      commentId - identifier for the comment whose version should be bumped
      parentIssueId - identifier for the Issue that the comment belongs to
      Returns:
      the new comment version
      Throws:
      IncrementDeletedEntityVersionException - if commentId is related to a deleted comment version which is marked as deleted
    • incrementWorklogVersion

      void incrementWorklogVersion(long worklogId, long parentIssueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified worklog. If a version number doesn't exist, one is created.
      Parameters:
      worklogId - identifier for the worklog whose version should be bumped
      parentIssueId - identifier for the Issue that the worklog belongs to
      Throws:
      IncrementDeletedEntityVersionException - if worklogId is related to a deleted worklog version which is marked as deleted
    • incrementWorklogVersionAndGet

      Optional<Long> incrementWorklogVersionAndGet(long worklogId, long parentIssueId) throws IncrementDeletedEntityVersionException
      Increments the version number for the specified worklog. If a version number doesn't exist, one is created.
      Parameters:
      worklogId - identifier for the worklog whose version should be bumped
      parentIssueId - identifier for the Issue that the worklog belongs to
      Returns:
      the new worklog version
      Throws:
      IncrementDeletedEntityVersionException - if worklogId is related to a deleted worklog version which is marked as deleted
    • incrementRelatedCommentVersions

      void incrementRelatedCommentVersions(long parentIssueId)
      Bumps the versions for all comments associated with the specified parentIssueId. If there isn't a version record associated with a given comment, it will be added.
      Parameters:
      parentIssueId - identifier for the Issue whose comments will be bumped.
    • incrementRelatedWorklogVersions

      void incrementRelatedWorklogVersions(long parentIssueId)
      Bumps the versions for all worklogs associated with the specified parentIssueId. If there isn't a version record associated with a given worklog, it will be added.
      Parameters:
      parentIssueId - identifier for the Issue whose worklogs will be bumped.
    • markIssueDeletedAndIncrementVersion

      void markIssueDeletedAndIncrementVersion(long issueId)
      Marks the specified issue and all its related comments and worklogs as deleted bumps their versions by 1.
      Parameters:
      issueId - identifier for issue and all its related comments and worklogs to mark as deleted invalid input: '&' whose version number to bump
    • markIssueDeletedIncrementAndGetIssueVersion

      Optional<Long> markIssueDeletedIncrementAndGetIssueVersion(long issueId)
      Marks the specified issue and all its related comments and worklogs as deleted, bumps their versions by 1 and returns the new issue version.
      Parameters:
      issueId - identifier for issue and all its related comments and worklogs to mark as deleted invalid input: '&' whose version number to bump
      Returns:
      the new version, or Optional.empty() if one could not be found.
      Since:
      11.1
    • markCommentDeletedAndIncrementVersion

      void markCommentDeletedAndIncrementVersion(long commentId)
      Marks the specified comment as deleted and bumps its version by 1.
      Parameters:
      commentId - identifier for comment to mark as deleted invalid input: '&' whose version number to bump
    • markCommentDeletedIncrementVersionAndGet

      Optional<Long> markCommentDeletedIncrementVersionAndGet(long commentId)
      Marks the specified comment as deleted and bumps its version by 1.
      Parameters:
      commentId - identifier for comment to mark as deleted invalid input: '&' whose version number to bump
      Returns:
      the new comment version
    • markWorklogDeletedAndIncrementVersion

      void markWorklogDeletedAndIncrementVersion(long worklogId)
      Marks the specified worklog as deleted and bumps its version by 1.
      Parameters:
      worklogId - identifier for worklog to mark as deleted invalid input: '&' whose version number to bump
    • markWorklogDeletedIncrementVersionAndGet

      Optional<Long> markWorklogDeletedIncrementVersionAndGet(long worklogId)
      Marks the specified worklog as deleted and bumps its version by 1.
      Parameters:
      worklogId - identifier for worklog to mark as deleted invalid input: '&' whose version number to bump
      Returns:
      the new worklog version
    • getIssueVersion

      @Deprecated Optional<Long> getIssueVersion(long issueId)
      Deprecated.
      Return the issue version for the issue identified by issueId or Optional.empty() if there is no version.
      Parameters:
      issueId - identifies the issue whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified issue; an empty optional if no version is found.
    • getIssueEntityVersion

      Optional<EntityVersion> getIssueEntityVersion(long issueId)
      Return the issue version for the issue identified by issueId, Optional.empty() if there is no version or NO_OP_ENTITY_VERSION an implementation not using a real data source is used.
      Parameters:
      issueId - identifies the issue whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified issue; an empty optional if no version is found; NO_OP_ENTITY_VERSION if an implementation not using a real data source is used.
    • getIssueEntityVersions

      Map<Long,EntityVersion> getIssueEntityVersions(List<Long> issueIds)
      Return the issue versions for the issues identified by issueIds. If an issue has no version, it will not be included in the returned map.
      Parameters:
      issueIds - identifiers for the issues whose current versions will be retrieved
      Returns:
      A map from issueId to issue version; an empty map if no version is found (because no version exists/no issue exists/issue doesn't exist).
    • getCommentVersion

      @Deprecated Optional<Long> getCommentVersion(long commentId)
      Deprecated.
      Return the comment version for the comment identified by commentId or Optional.empty() if there is no version.
      Parameters:
      commentId - identifies the comment whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified comment; an empty optional if no version is found.
    • getCommentEntityVersion

      Optional<EntityVersion> getCommentEntityVersion(long commentId)
      Return the comment version for the comment identified by issueId, Optional.empty() if there is no version or NO_OP_ENTITY_VERSION an implementation not using a real data source is used.
      Parameters:
      commentId - identifies the comment whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified comment; an empty optional if no version is found; NO_OP_ENTITY_VERSION if an implementation not using a real data source is used.
    • getWorklogVersion

      @Deprecated Optional<Long> getWorklogVersion(long worklogId)
      Deprecated.
      Return the worklog version for the worklog identified by worklogId or Optional.empty() if there is no version.
      Parameters:
      worklogId - identifies the worklog whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified worklog; an empty optional if no version is found.
    • getWorklogEntityVersion

      Optional<EntityVersion> getWorklogEntityVersion(long worklogId)
      Return the worklog version for the worklog identified by issueId, Optional.empty() if there is no version or NO_OP_ENTITY_VERSION an implementation not using a real data source is used.
      Parameters:
      worklogId - identifies the worklog whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified worklog; an empty optional if no version is found; NO_OP_ENTITY_VERSION if an implementation not using a real data source is used.
    • getRelatedCommentVersions

      Map<Long,Long> getRelatedCommentVersions(long parentIssueId)
      Return the comment versions for for all comments associated with the specified parentIssueId.
      Parameters:
      parentIssueId - identifier for the Issue whose comments will be retrieved
      Returns:
      A map from commentId to comment version; an empty map if no version is found (because no version exists/no comment exists/issue doesn't exist).
    • getRelatedWorklogVersions

      Map<Long,Long> getRelatedWorklogVersions(long parentIssueId)
      Return the worklog versions for for all worklogs associated with the specified parentIssueId.
      Parameters:
      parentIssueId - identifier for the Issue whose worklogs will be retrieved
      Returns:
      A map from worklogId to worklog version; an empty map if no version is found (because no version exists/no worklog exists/issue doesn't exist).
    • getLocalVersions

      Map<Long,Optional<Long>> getLocalVersions(Set<Long> entityIds, IndexDirectoryFactory.Name indexName) throws IOException
      Returns the corresponding entity version from the specified local lucene index for each of the ids passed in with entityIds in the form of a map of ids to versions. Which local index to retrieve the versions from is determined by indexName.
      Parameters:
      entityIds - Set of entity ids whose versions we want to look up in the local index referred to by indexName
      indexName - Specifies which local Lucene index the versions should be retrieved from
      Returns:
      A mapping of entity ids to their corresponding versions. The version-values are wrapped in Optionals, with empty values for versions that were not found.
      Throws:
      IOException - if an I/O problem arises when searching the target lucene index
    • cleanAllDeletedEntityVersionsOlderThan

      long cleanAllDeletedEntityVersionsOlderThan(Duration duration)
      Removes all entity version records (issues, comments, invalid input: '&' worklogs) for entites marked as deleted and older than duration.
      Parameters:
      duration - threshold for deletion; entries marked as deleted and older than this will be removed.
      Returns:
      the number of entity version entries that were removed
    • findEntityVersionsUpdatedInTheLast

      List<EntityVersion> findEntityVersionsUpdatedInTheLast(IndexDirectoryFactory.Name indexName, Duration duration)
      Looks up all the entities whose version changed during the last duration amount of time. A data object containing the entity's id, version, whether or not it was deleted, etc. is returned for every entity-version modified since the duration.
      Parameters:
      indexName - which type of entity to get the updated versions for
      duration - how far back in time to look for entity versions that have been updated
      Returns:
      data objects that bundle id, version, delete status, etc.
    • getLatestEntityUpdate

      Optional<EntityVersion> getLatestEntityUpdate(IndexDirectoryFactory.Name indexName)
      Looks up the Version invalid input: '&' related info for the most recently modified entity version. Deleted entity versions are also considered as part of this calculation.
      Parameters:
      indexName - which type of entity to get the latest update for
      Returns:
      An Optional wrapping the most recent update for any entity version or an empty Optional if no versions are present.