Class DefaultVersionService
- All Implemented Interfaces:
VersionService
- Since:
- v3.13
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.project.version.VersionService
VersionService.AbstractVersionResult, VersionService.ArchiveVersionValidationResult, VersionService.CreateVersionValidationResult, VersionService.MoveVersionValidationResult, VersionService.ReasonsServiceResult<R,T>, VersionService.ReleaseVersionValidationResult, VersionService.ValidationResult, VersionService.VersionAction, VersionService.VersionBuilderValidationResult, VersionService.VersionExtractableField, VersionService.VersionResult, VersionService.VersionsResult -
Field Summary
Fields inherited from interface com.atlassian.jira.bc.project.version.VersionService
REMOVE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultVersionService(VersionManager versionManager, PermissionManager permissionManager, IssueManager issueManager, SearchService searchService, I18nHelper.BeanFactory i18n, DateFieldFormat dateFieldFormat, ProjectManager projectManager) -
Method Summary
Modifier and TypeMethodDescriptionTakes a validation result and performs the archive operation.create(ApplicationUser user, VersionService.VersionBuilderValidationResult validationResult) Creates a newVersion, based on the validation result from calling#validateCreate(User, VersionBuilder).Using the validation result from#validateCreateVersion(User, com.atlassian.jira.project.Project, String, String, String, Long)a new version will be created.createVersionDeletaAndReplaceParameters(Version versionToDelete) Create builder that for paramaters to remove version with swap (including custom fields)voiddecreaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Move a version to have a higher sequence number - ie make it later.deleteVersionAndSwap(JiraServiceContext serviceContext, DeleteVersionWithCustomFieldParameters parameters) Remove specified version.findVersions(ApplicationUser user, String substring) Returns all versions visible by the given user filtered by given query.findVersionsByProjects(ApplicationUser user, String substring, @NotEmpty Set<Long> projectIds) Returns all versions visible by the given user filtered by given query and available in given projects.longgetAffectsIssuesCount(Version version) Return the count of Issues that have the "Affects Version" field set to version.longgetCustomFieldIssuesCount(Version version) This method returns the total number of issues where this version is used in custom fieldsgetCustomFieldsUsing(Version version) This method returns usage information in custom fields for a given version.longgetFixIssuesCount(Version version) Return the count of Issues Fixed in this version.longgetUnresolvedIssuesCount(ApplicationUser user, Version version) Return the count of Issues that are unresolved in this version.getVersionById(ApplicationUser user, Project project, Long versionId) getVersionById(ApplicationUser user, Long versionId) Used to retrieve aVersionobject by version id.getVersionByProjectAndName(ApplicationUser user, Project project, String versionName) getVersionsByProject(ApplicationUser user, Project project) getVersionsByProject(ApplicationUser user, Project project, PageRequest pageRequest) This method returns all versions for a given project.getVersionsByProject(ApplicationUser user, Project project, PageRequest pageRequest, OrderByRequest<VersionService.VersionExtractableField> orderBy) This method returns all versions for a given project.getVersionsByProject(ApplicationUser user, Project project, PageRequest pageRequest, io.atlassian.fugue.Option<OrderByRequest<VersionService.VersionExtractableField>> orderBy) voidincreaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Move a version to have a lower sequence number - ie make it earlier.booleanIs the passed version overdue? This method does no permission checks on the passed version.voidmerge(JiraServiceContext context, VersionService.ValidationResult result) Merges a version into another, then removes the original version.voidmoveToEndVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Move a version to the end of the version sequence.voidmoveToStartVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Move a version to the start of the version list.voidmoveUnreleasedToNewVersion(ApplicationUser directoryUser, Version currentVersion, Version newVersion) Using the validation result from#validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be released.voidmoveVersionAfter(VersionService.MoveVersionValidationResult moveVersionValidationResult) Move a version after another version.Creates a builder to be used when creating a newVersion.newVersionBuilder(Version version) Creates a builder to be used when updating an existingVersion.protected DateparseDate(ApplicationUser user, com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field, String date) Parses a string release date into a Date object, throwing an exception if there is a problem parsing the string.Using the validation result from#validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be released.setReleaseDate(ApplicationUser user, Version version, String releaseDate) Modify the release date of a version without performing a release/unrelease.setReleaseDate(ApplicationUser user, Version version, Date releaseDate) Modify the release date of a version without performing a release/unrelease.setVersionDetails(ApplicationUser user, Version version, String name, String description) Set the name and description of a version, if you have edit permission.Takes a validation result and performs the unarchive operation.Using the validation result from#validateUnreleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be unreleased.update(ApplicationUser user, VersionService.VersionBuilderValidationResult validationResult) Updates the existingVersion, based on the validation result from calling#validateUpdate(User, VersionBuilder).validateArchiveVersion(ApplicationUser user, Version version) This method should be called before archiving a version.validateCreate(ApplicationUser user, VersionBuilder versionBuilder) Validates the creation of a newVersionobject, specified with aVersionBuilder.validateCreateVersion(ApplicationUser user, Project project, String versionName, String releaseDateStr, String description, Long scheduleAfterVersion) This method needs to be called before creating a version to ensure all parameters are correct.validateCreateVersion(ApplicationUser user, Project project, String versionName, Date releaseDate, String description, Long scheduleAfterVersion) This method needs to be called before creating a version to ensure all parameters are correct.validateDecreaseVersionSequence(ApplicationUser user, long versionId) Validate Move a version to have a higher sequence number - ie make it later.validateDelete(JiraServiceContext context, Long versionId, VersionService.VersionAction affectsAction, VersionService.VersionAction fixAction) Validates an attempt to delete a version from a project.validateIncreaseVersionSequence(ApplicationUser user, long versionId) Validate Move a version to have a lower sequence number - ie make it earlier.validateMerge(JiraServiceContext context, Long versionId, Long swapVersionId) Implementation is the same as deleting, with the actions set to SWAP and the swapVersionId being passed as both Affects Version swap and Fix Version swapvalidateMoveToEndVersionSequence(ApplicationUser user, long versionId) Validate Move a version to the end of the version sequence.validateMoveToStartVersionSequence(ApplicationUser user, long versionId) Validate Move a version to the start of the version list.validateMoveVersionAfter(ApplicationUser user, long versionId, Long scheduleAfterVersionId) Validate Move a version after another version.validateReleaseVersion(ApplicationUser user, Version version, String releaseDate) This method needs to be called before releasing a version to ensure all parameters are correct.validateReleaseVersion(ApplicationUser user, Version version, Date releaseDate) This method needs to be called before releasing a version to ensure all parameters are correct.protected ServiceOutcome<Void>validateStartReleaseDates(ApplicationUser user, com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field, Date startDate, Date releaseDate) validateUnarchiveVersion(ApplicationUser user, Version version) This method should be called before unarchiving a version.validateUnreleaseVersion(ApplicationUser user, Version version, String releaseDate) This method needs to be called before unreleasing a version to ensure all parameters are correct.validateUnreleaseVersion(ApplicationUser user, Version version, Date releaseDate) This method needs to be called before unreleasing a version to ensure all parameters are correct.validateUpdate(ApplicationUser user, VersionBuilder versionBuilder) Validates the update of an existingVersionobject, specified with aVersionBuilder.
-
Constructor Details
-
DefaultVersionService
public DefaultVersionService(VersionManager versionManager, PermissionManager permissionManager, IssueManager issueManager, SearchService searchService, I18nHelper.BeanFactory i18n, DateFieldFormat dateFieldFormat, ProjectManager projectManager)
-
-
Method Details
-
getVersionById
public VersionService.VersionResult getVersionById(@Nullable ApplicationUser user, Project project, Long versionId) Description copied from interface:VersionServiceUsed to retrieve aVersionobject by version id within project specified byProjectobject. This method returns aVersionService.VersionResult. The version will be null if no version for the id specified can be found, or if the user making the request does not have the ADMIN, PROJECT_ADMIN or BROWSE project permission for the project. In both of these cases, the errorCollection in the result object will contain an appropriate error message.- Specified by:
getVersionByIdin interfaceVersionService- Parameters:
user- The user trying to get a versionproject- The project object containing requested versionversionId- The id of requested version- Returns:
- VersionResult object
-
getVersionById
Description copied from interface:VersionServiceUsed to retrieve aVersionobject by version id. This method returns aVersionService.VersionResult. The version will be null if no version for the id specified can be found, or if the user making the request does not have the ADMIN, PROJECT_ADMIN or BROWSE project permission for the project. In both of these cases, the errorCollection in the result object will contain an appropriate error message.- Specified by:
getVersionByIdin interfaceVersionService- Parameters:
user- The user trying to get a versionversionId- The id of requested version- Returns:
- VersionResult object
-
getVersionByProjectAndName
@Nonnull public VersionService.VersionResult getVersionByProjectAndName(@Nullable ApplicationUser user, @Nonnull Project project, @Nonnull String versionName) Description copied from interface:VersionServiceUsed to retrieve aVersionobject by version name within project specified byProjectobject. This method returns aVersionService.VersionResult. The version will be null if no version for the versionName specified can be found, or if the user making the request does not have the ADMIN, PROJECT_ADMIN or BROWSE project permission for the project. In both of these cases, the errorCollection in the result object will contain an appropriate error message.- Specified by:
getVersionByProjectAndNamein interfaceVersionService- Parameters:
user- The user trying to get a versionproject- The project object containing requested versionversionName- The name of requested version- Returns:
- VersionResult containing errors and the Version if it could be found
-
getVersionsByProject
@Nonnull public VersionService.VersionsResult getVersionsByProject(@Nullable ApplicationUser user, @Nonnull Project project) Description copied from interface:VersionServiceUsed to retrieve aVersioncollection within project specified byProjectobject. This method returns aVersionService.VersionsResult. The versions collection will be empty if the user making the request does not have the ADMIN, PROJECT_ADMIN or BROWSE project permission for the project. In this case, the errorCollection in the result object will contain an appropriate error message.- Specified by:
getVersionsByProjectin interfaceVersionService- Parameters:
user- The user trying to get a versionproject- The project object containing requested version- Returns:
- VerionsResult object
-
getVersionsByProject
@Nonnull public ServiceOutcome<Page<Version>> getVersionsByProject(@Nullable ApplicationUser user, @Nonnull Project project, @Nonnull PageRequest pageRequest) Description copied from interface:VersionServiceThis method returns all versions for a given project. It's similar to theVersionService.getVersionsByProject(ApplicationUser, Project)but the results it returns are paged.The user making the request must have the ADMIN, PROJECT_ADMIN or BROWSE project permissions for the project. Otherwise, the errorCollection in the result object will contain an appropriate error message.
- Specified by:
getVersionsByProjectin interfaceVersionService- Parameters:
user- The user trying to get a versionproject- The project object containing requested versionpageRequest- details of a page to return (offset, max number of results)- Returns:
- A single page of versions or an appropriate error message if the user does not have permissions to read versions for the project
- See Also:
-
getVersionsByProject
@Nonnull public ServiceOutcome<Page<Version>> getVersionsByProject(@Nullable ApplicationUser user, @Nonnull Project project, @Nonnull PageRequest pageRequest, @Nullable OrderByRequest<VersionService.VersionExtractableField> orderBy) Description copied from interface:VersionServiceThis method returns all versions for a given project. It's similar to the VersionService#getVersionsByProject(ApplicationUser, Project) but the results it returns are paged.It also provides the possibility to sort the results by the fields specified in the
VersionService.VersionExtractableFieldclass.The user making the request must have the ADMIN, PROJECT_ADMIN or BROWSE project permissions for the project. Otherwise, the errorCollection in the result object will contain an appropriate error message.
- Specified by:
getVersionsByProjectin interfaceVersionService- Parameters:
user- The user trying to get a versionproject- The project object containing requested versionpageRequest- details of a page to return (offset, max number of results)orderBy- details on how to order the results- Returns:
- A single page of versions or an appropriate error message if the user does not have permissions to read versions for the project
- See Also:
-
findVersions
@Nonnull public Stream<Version> findVersions(@Nullable ApplicationUser user, @Nonnull String substring) Description copied from interface:VersionServiceReturns all versions visible by the given user filtered by given query.- Specified by:
findVersionsin interfaceVersionService- Parameters:
user- user trying to find the versionssubstring- optional query used to filter returned versions
-
findVersionsByProjects
@Nonnull public Stream<Version> findVersionsByProjects(@Nullable ApplicationUser user, @Nonnull String substring, @NotEmpty @NotEmpty Set<Long> projectIds) Description copied from interface:VersionServiceReturns all versions visible by the given user filtered by given query and available in given projects.- Specified by:
findVersionsByProjectsin interfaceVersionService- Parameters:
user- user trying to find the versionssubstring- optional query used to filter returned versionsprojectIds- set of project IDs to filter versions with
-
setVersionDetails
public ServiceOutcome<Version> setVersionDetails(ApplicationUser user, Version version, String name, String description) Description copied from interface:VersionServiceSet the name and description of a version, if you have edit permission.- Specified by:
setVersionDetailsin interfaceVersionService- Parameters:
user- the user who is performing the edit operationversion- the version that they want to editname- the new name for the version (must not be null or already in use)description- the new description for the version- Returns:
- a ServiceOutcome that contains the success or failure of the update
-
setReleaseDate
public ServiceOutcome<Version> setReleaseDate(ApplicationUser user, Version version, Date releaseDate) Description copied from interface:VersionServiceModify the release date of a version without performing a release/unrelease.- Specified by:
setReleaseDatein interfaceVersionService- Parameters:
user- the user who is changing the release dateversion- the version they want to modifyreleaseDate- the new release date to use- Returns:
- a ServiceOutcome describing the success/failure of the edit, along with the new Version if successful
-
setReleaseDate
public ServiceOutcome<Version> setReleaseDate(ApplicationUser user, Version version, String releaseDate) Description copied from interface:VersionServiceModify the release date of a version without performing a release/unrelease.- Specified by:
setReleaseDatein interfaceVersionService- Parameters:
user- the user who is changing the release dateversion- the version they want to modifyreleaseDate- the new release date to use- Returns:
- a ServiceOutcome describing the success/failure of the edit, along with the new Version if successful
-
validateDelete
public VersionService.ValidationResult validateDelete(JiraServiceContext context, Long versionId, VersionService.VersionAction affectsAction, VersionService.VersionAction fixAction) Description copied from interface:VersionServiceValidates an attempt to delete a version from a project. When deleting a version, we need to decide what to do with issues that reference the version in their Affects of Fix Version fields. The action taken is specified as a flag for each field.- Specified by:
validateDeletein interfaceVersionService- Parameters:
context- The context for this service call.versionId- The id of the version to be deleted.affectsAction- Used to decide whether to move all the issues to a different 'affects' version or just remove them. SeeVersionKeys.REMOVE_ACTION,VersionKeys.SWAP_ACTIONfixAction- Used to decide wether to move all the issues to a different 'fix' version or just remove them. SeeVersionKeys.REMOVE_ACTION,VersionKeys.SWAP_ACTION- Returns:
- a
VersionService.ValidationResultobject which contains the version to delete, and the versions to swap to for Affects and Fix versions, or null if the action to be taken isVersionKeys.REMOVE_ACTION
-
createVersionDeletaAndReplaceParameters
public DeleteVersionWithReplacementsParameterBuilder createVersionDeletaAndReplaceParameters(@Nonnull Version versionToDelete) Description copied from interface:VersionServiceCreate builder that for paramaters to remove version with swap (including custom fields)- Specified by:
createVersionDeletaAndReplaceParametersin interfaceVersionService- Parameters:
versionToDelete- version that will be deleted - mandatory- See Also:
-
deleteVersionAndSwap
public ServiceResult deleteVersionAndSwap(@Nonnull JiraServiceContext serviceContext, @Nonnull DeleteVersionWithCustomFieldParameters parameters) Description copied from interface:VersionServiceRemove specified version. According to information inDeleteVersionWithCustomFieldParametersversion will be completly removed from specific fields are replaced.- Specified by:
deleteVersionAndSwapin interfaceVersionService- Parameters:
serviceContext- The context for this service call.parameters- parameters build with builder obtained byVersionService.createVersionDeletaAndReplaceParameters(Version)- Returns:
- result than holds eventual errors in removal
- See Also:
-
validateMerge
public VersionService.ValidationResult validateMerge(JiraServiceContext context, Long versionId, Long swapVersionId) Implementation is the same as deleting, with the actions set to SWAP and the swapVersionId being passed as both Affects Version swap and Fix Version swap- Specified by:
validateMergein interfaceVersionService- Parameters:
context- The context for this service call.versionId- The original version to be merged and removed.swapVersionId- The target version of the merge operation. Must be from the same project.- Returns:
- a
VersionService.ValidationResultobject which contains the version to delete, and the versions to swap to for Affects and Fix versions, or null if the action to be taken isVersionKeys.REMOVE_ACTION
-
merge
Description copied from interface:VersionServiceMerges a version into another, then removes the original version.- Specified by:
mergein interfaceVersionService- Parameters:
context- The context for this service call.result- The result of validation, which contains the version to be deleted, and the swap versions for Affects and Fix fields
-
validateCreateVersion
public VersionService.CreateVersionValidationResult validateCreateVersion(ApplicationUser user, Project project, String versionName, String releaseDateStr, String description, Long scheduleAfterVersion) Description copied from interface:VersionServiceThis method needs to be called before creating a version to ensure all parameters are correct. There are a number of required parameters, such as a project object and versionName. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version with the name provided already exists and throw an appropriate error.Optional validation will be done for the release date, if provided. An error will be returned, if date format is valid.
The method will return a
VersionService.CreateVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateCreateVersionin interfaceVersionService- Parameters:
user- The user trying to create a versionproject- The project object containing requested versionversionName- The name of created versionreleaseDateStr- The release date for a version (optional)description- The description for a version (optional)scheduleAfterVersion- The version after which created version should be scheduled (optional)- Returns:
- CreateVersionValidationResult object
-
validateCreateVersion
public VersionService.CreateVersionValidationResult validateCreateVersion(ApplicationUser user, Project project, String versionName, Date releaseDate, String description, Long scheduleAfterVersion) Description copied from interface:VersionServiceThis method needs to be called before creating a version to ensure all parameters are correct. There are a number of required parameters, such as a project object and versionName. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version with the name provided already exists and throw an appropriate error.Optional validation will be done for the release date, if provided. An error will be returned, if date format is valid.
The method will return a
VersionService.CreateVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateCreateVersionin interfaceVersionService- Parameters:
user- The user trying to create a versionproject- The project object containing requested versionversionName- The name of created versionreleaseDate- The release date for a version (optional)description- The description for a version (optional)scheduleAfterVersion- The version after which created version should be scheduled (optional)- Returns:
- CreateVersionValidationResult object
-
createVersion
public Version createVersion(ApplicationUser user, VersionService.CreateVersionValidationResult request) Description copied from interface:VersionServiceUsing the validation result from#validateCreateVersion(User, com.atlassian.jira.project.Project, String, String, String, Long)a new version will be created. This method will throw an RuntimeException if the version could not be created.- Specified by:
createVersionin interfaceVersionService- Parameters:
user- The user trying to get a versionrequest- TheVersionService.CreateVersionValidationResultobject containing all required data- Returns:
- created Version object
-
validateReleaseVersion
@Nonnull public VersionService.ReleaseVersionValidationResult validateReleaseVersion(@Nullable ApplicationUser user, @Nonnull Version version, @Nullable Date releaseDate) Description copied from interface:VersionServiceThis method needs to be called before releasing a version to ensure all parameters are correct. There is required parameter, version object. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version provided has a valid name and if is not released already.The method will return a
VersionService.ReleaseVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateReleaseVersionin interfaceVersionService- Parameters:
user- The user trying to release a versionversion- The version to releasereleaseDate- The version release date (optional)- Returns:
- ReleaseVersionValidationResult object
-
validateReleaseVersion
@Nonnull public VersionService.ReleaseVersionValidationResult validateReleaseVersion(@Nullable ApplicationUser user, @Nonnull Version version, @Nullable String releaseDate) Description copied from interface:VersionServiceThis method needs to be called before releasing a version to ensure all parameters are correct. There is required parameter, version object. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version provided has a valid name and if is not released already.The method will return a
VersionService.ReleaseVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateReleaseVersionin interfaceVersionService- Parameters:
user- The user trying to release a versionversion- The version to releasereleaseDate- The version release date (optional)- Returns:
- ReleaseVersionValidationResult object
-
validateUnreleaseVersion
@Nonnull public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(@Nullable ApplicationUser user, @Nonnull Version version, @Nullable Date releaseDate) Description copied from interface:VersionServiceThis method needs to be called before unreleasing a version to ensure all parameters are correct. There is required parameter, version object. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version provided has a valid name and if is released already.The method will return a
VersionService.ReleaseVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateUnreleaseVersionin interfaceVersionService- Parameters:
user- The user trying to unrelease a versionversion- The version to releasereleaseDate- The version release date (optional)- Returns:
- ReleaseVersionValidationResult object
-
validateUnreleaseVersion
@Nonnull public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(@Nullable ApplicationUser user, @Nonnull Version version, @Nonnull String releaseDate) Description copied from interface:VersionServiceThis method needs to be called before unreleasing a version to ensure all parameters are correct. There is required parameter, version object. An error will be returned if the user making the request does not have the ADMIN or PROJECT_ADMIN permission for the project. The validation will also check if a version provided has a valid name and if is released already.The method will return a
VersionService.ReleaseVersionValidationResultwhich contains an ErrorCollection with any potential errors and all the version's details.- Specified by:
validateUnreleaseVersionin interfaceVersionService- Parameters:
user- The user trying to unrelease a versionversion- The version to releasereleaseDate- The version release date (optional)- Returns:
- ReleaseVersionValidationResult object
-
validateArchiveVersion
@Nonnull public VersionService.ArchiveVersionValidationResult validateArchiveVersion(@Nullable ApplicationUser user, @Nonnull Version version) Description copied from interface:VersionServiceThis method should be called before archiving a version. It performs some basic validation of the version that was passed in. This includes a null check, checking that the version name isn't empty, and checking that the version is linked against a valid project.The method also validates that the user passed in is either a global admin, or has project admin rights for the project that the version is linked to.
Finally, this method checks that the version that was passed in hasn't already been archived. If there's any errors, the validationResult will contain appropriate errors and wont be valid.
- Specified by:
validateArchiveVersionin interfaceVersionService- Parameters:
user- The user performing this operationversion- The version to be archived- Returns:
- a validation result, containing any errors or the version details on success
-
validateUnarchiveVersion
@Nonnull public VersionService.ArchiveVersionValidationResult validateUnarchiveVersion(@Nullable ApplicationUser user, @Nonnull Version version) Description copied from interface:VersionServiceThis method should be called before unarchiving a version. It performs some basic validation of the version that was passed in. This includes a null check, checking that the version name isn't empty, and checking that the version is linked against a valid project.The method also validates that the user passed in is either a global admin, or has project admin rights for the project that the version is linked to.
Finally, this method checks that the version that was passed is currently archived. If there's any errors, the validationResult will contain appropriate errors and wont be valid.
- Specified by:
validateUnarchiveVersionin interfaceVersionService- Parameters:
user- The user performing this operationversion- The version to be archived- Returns:
- a validation result, containing any errors or the version details on success
-
releaseVersion
Description copied from interface:VersionServiceUsing the validation result from#validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be released. This method will throw an IllegalArgumentException if the provied data are invalid and version could not be released.- Specified by:
releaseVersionin interfaceVersionService- Parameters:
result- a ReleaseVersionValidationResult containg required data- Returns:
- a released version object
-
moveUnreleasedToNewVersion
public void moveUnreleasedToNewVersion(@Nullable ApplicationUser directoryUser, @Nonnull Version currentVersion, @Nonnull Version newVersion) Description copied from interface:VersionServiceUsing the validation result from#validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be released. This method will throw an IllegalArgumentException if the provided data are invalid and version could not be released.- Specified by:
moveUnreleasedToNewVersionin interfaceVersionService- Parameters:
directoryUser- The user trying to release a versioncurrentVersion- The current version being released.newVersion- The version to move issues to.
-
unreleaseVersion
Description copied from interface:VersionServiceUsing the validation result from#validateUnreleaseVersion(User, com.atlassian.jira.project.version.Version, Date)a version will be unreleased. This method will throw an IllegalArgumentException if the provied data are invalid and version could not be unreleased.- Specified by:
unreleaseVersionin interfaceVersionService- Parameters:
result- a ReleaseVersionValidationResult containg required data- Returns:
- a unreleased version object
-
archiveVersion
Description copied from interface:VersionServiceTakes a validation result and performs the archive operation.- Specified by:
archiveVersionin interfaceVersionService- Parameters:
result- The result from the validation- Returns:
- The version that was archived. Ideally this version should have been retrieved from the store for consistency
-
unarchiveVersion
Description copied from interface:VersionServiceTakes a validation result and performs the unarchive operation.- Specified by:
unarchiveVersionin interfaceVersionService- Parameters:
result- The result from the validation- Returns:
- The version that was unarchived. Ideally this version should have been retrieved from the store for consistency
-
validateMoveToStartVersionSequence
@Nonnull public VersionService.MoveVersionValidationResult validateMoveToStartVersionSequence(@Nullable ApplicationUser user, long versionId) Description copied from interface:VersionServiceValidate Move a version to the start of the version list.- Specified by:
validateMoveToStartVersionSequencein interfaceVersionService- Parameters:
user- The user trying to move a version- Returns:
- a validation result, containing any errors or the version details on success
-
validateIncreaseVersionSequence
@Nonnull public VersionService.MoveVersionValidationResult validateIncreaseVersionSequence(@Nullable ApplicationUser user, long versionId) Description copied from interface:VersionServiceValidate Move a version to have a lower sequence number - ie make it earlier.- Specified by:
validateIncreaseVersionSequencein interfaceVersionService- Parameters:
user- The user trying to move a version- Returns:
- a validation result, containing any errors or the version details on success
-
validateDecreaseVersionSequence
@Nonnull public VersionService.MoveVersionValidationResult validateDecreaseVersionSequence(@Nullable ApplicationUser user, long versionId) Description copied from interface:VersionServiceValidate Move a version to have a higher sequence number - ie make it later.- Specified by:
validateDecreaseVersionSequencein interfaceVersionService- Parameters:
user- The user trying to move a version- Returns:
- a validation result, containing any errors or the version details on success
-
validateMoveToEndVersionSequence
@Nonnull public VersionService.MoveVersionValidationResult validateMoveToEndVersionSequence(@Nullable ApplicationUser user, long versionId) Description copied from interface:VersionServiceValidate Move a version to the end of the version sequence.- Specified by:
validateMoveToEndVersionSequencein interfaceVersionService- Parameters:
user- The user trying to move a version- Returns:
- a validation result, containing any errors or the version details on success
-
validateMoveVersionAfter
@Nonnull public VersionService.MoveVersionValidationResult validateMoveVersionAfter(@Nullable ApplicationUser user, long versionId, @Nonnull Long scheduleAfterVersionId) Description copied from interface:VersionServiceValidate Move a version after another version.- Specified by:
validateMoveVersionAfterin interfaceVersionService- Parameters:
user- The user trying to move a versionversionId- version to reschedulescheduleAfterVersionId- id of the version to schedule after the given version object- Returns:
- a validation result, containing any errors or the version details and schedule after target on success
-
moveToStartVersionSequence
public void moveToStartVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Description copied from interface:VersionServiceMove a version to the start of the version list.- Specified by:
moveToStartVersionSequencein interfaceVersionService- Parameters:
moveVersionValidationResult- Move Version Validation Result
-
increaseVersionSequence
public void increaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Description copied from interface:VersionServiceMove a version to have a lower sequence number - ie make it earlier.- Specified by:
increaseVersionSequencein interfaceVersionService- Parameters:
moveVersionValidationResult- Move Version Validation Result
-
decreaseVersionSequence
public void decreaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Description copied from interface:VersionServiceMove a version to have a higher sequence number - ie make it later.- Specified by:
decreaseVersionSequencein interfaceVersionService- Parameters:
moveVersionValidationResult- Move Version Validation Result
-
moveToEndVersionSequence
public void moveToEndVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult) Description copied from interface:VersionServiceMove a version to the end of the version sequence.- Specified by:
moveToEndVersionSequencein interfaceVersionService- Parameters:
moveVersionValidationResult- Move Version Validation Result
-
moveVersionAfter
public void moveVersionAfter(VersionService.MoveVersionValidationResult moveVersionValidationResult) Description copied from interface:VersionServiceMove a version after another version.- Specified by:
moveVersionAfterin interfaceVersionService- Parameters:
moveVersionValidationResult- Move Version Validation Result
-
isOverdue
Description copied from interface:VersionServiceIs the passed version overdue? This method does no permission checks on the passed version.- Specified by:
isOverduein interfaceVersionService- Parameters:
version- the version to check.- Returns:
- true if the passed version is overdue.
-
getFixIssuesCount
Description copied from interface:VersionServiceReturn the count of Issues Fixed in this version.- Specified by:
getFixIssuesCountin interfaceVersionService- Returns:
- A count of issues
-
getAffectsIssuesCount
Description copied from interface:VersionServiceReturn the count of Issues that have the "Affects Version" field set to version.- Specified by:
getAffectsIssuesCountin interfaceVersionService- Returns:
- A count of issues
-
getCustomFieldsUsing
@Nonnull public Collection<CustomFieldWithVersionUsage> getCustomFieldsUsing(@Nonnull Version version) Description copied from interface:VersionServiceThis method returns usage information in custom fields for a given version.- Specified by:
getCustomFieldsUsingin interfaceVersionService- Parameters:
version- The version that we want to get information about.- Returns:
- collection of version usage for each custom fields.
-
getCustomFieldIssuesCount
Description copied from interface:VersionServiceThis method returns the total number of issues where this version is used in custom fields- Specified by:
getCustomFieldIssuesCountin interfaceVersionService- Parameters:
version- The version that we want to get information about.- Returns:
- collection of version usage for each custom fields.
-
getUnresolvedIssuesCount
Description copied from interface:VersionServiceReturn the count of Issues that are unresolved in this version. Used when releasing a version to get user confirmation about what to do with the unresolved issues.- Specified by:
getUnresolvedIssuesCountin interfaceVersionService- Parameters:
user- the user trying to get the countversion- which version to check for unresolved issues- Returns:
- A count of issues
-
validateCreate
@Nonnull public VersionService.VersionBuilderValidationResult validateCreate(@Nullable ApplicationUser user, @Nonnull VersionBuilder versionBuilder) Description copied from interface:VersionServiceValidates the creation of a newVersionobject, specified with aVersionBuilder.This replaces the deprecated methods:
#validateCreateVersion(User, Project, String, Date, String, Long)and#validateCreateVersion(User, Project, String, String, String, Long).- Specified by:
validateCreatein interfaceVersionService- Parameters:
user- the user who is performing the createversionBuilder- the builder which specified the new Version to be created- Returns:
- the result
- See Also:
-
create
@Nonnull public ServiceOutcome<Version> create(@Nullable ApplicationUser user, @Nonnull VersionService.VersionBuilderValidationResult validationResult) Description copied from interface:VersionServiceCreates a newVersion, based on the validation result from calling#validateCreate(User, VersionBuilder).- Specified by:
createin interfaceVersionService- Parameters:
user- the uservalidationResult- the result of validation- Returns:
- the new Version object; errors if not successful.
- See Also:
-
#validateCreate(com.atlassian.crowd.embedded.api.User, VersionBuilder)#validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder)
-
newVersionBuilder
Description copied from interface:VersionServiceCreates a builder to be used when updating an existingVersion. The builder encapsulates all the fields which need to be specified on update.- Specified by:
newVersionBuilderin interfaceVersionService- Parameters:
version- the Version object to update- Returns:
- the builder instance
- See Also:
-
for creating a new versionfor creating a new version
-
newVersionBuilder
Description copied from interface:VersionServiceCreates a builder to be used when creating a newVersion. The builder encapsulates all the fields which need to be specified on create.- Specified by:
newVersionBuilderin interfaceVersionService- Returns:
- the builder instance
- See Also:
-
for updating an existing versionfor updating an existing version
-
validateUpdate
@Nonnull public VersionService.VersionBuilderValidationResult validateUpdate(@Nullable ApplicationUser user, @Nonnull VersionBuilder versionBuilder) Description copied from interface:VersionServiceValidates the update of an existingVersionobject, specified with aVersionBuilder.- Specified by:
validateUpdatein interfaceVersionService- Parameters:
user- the user who is performing the updateversionBuilder- the builder which specified the update to the existing Version- Returns:
- the result
- See Also:
-
VersionService.newVersionBuilder(com.atlassian.jira.project.version.Version)#newBuilder(com.atlassian.jira.project.version.Version)
-
update
public ServiceOutcome<Version> update(ApplicationUser user, VersionService.VersionBuilderValidationResult validationResult) Description copied from interface:VersionServiceUpdates the existingVersion, based on the validation result from calling#validateUpdate(User, VersionBuilder).- Specified by:
updatein interfaceVersionService- Parameters:
user- the uservalidationResult- the result of validation- Returns:
- the updated Version object; errors if not successful.
- See Also:
-
#validateUpdate(com.atlassian.crowd.embedded.api.User, VersionBuilder)#validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder)
-
getVersionsByProject
public ServiceOutcome<Page<Version>> getVersionsByProject(@Nullable ApplicationUser user, @Nonnull Project project, @Nonnull PageRequest pageRequest, io.atlassian.fugue.Option<OrderByRequest<VersionService.VersionExtractableField>> orderBy) -
parseDate
@Nullable protected Date parseDate(@Nullable ApplicationUser user, com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field, String date) throws com.atlassian.jira.bc.project.version.DefaultVersionService.DateParseException Parses a string release date into a Date object, throwing an exception if there is a problem parsing the string. If the release date is an empty string, this method returns null.- Parameters:
user- the user who has provided the datefield- a DateField instance containing information what kind of date we are parsingdate- a string containing a date- Returns:
- a Date object, or null
- Throws:
com.atlassian.jira.bc.project.version.DefaultVersionService.DateParseException- if there is a problem parsing the date string
-
validateStartReleaseDates
protected ServiceOutcome<Void> validateStartReleaseDates(ApplicationUser user, com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field, Date startDate, Date releaseDate)
-