com.atlassian.jira.bc.project.version
Class DefaultVersionService

java.lang.Object
  extended by com.atlassian.jira.bc.project.version.DefaultVersionService
All Implemented Interfaces:
VersionService

public class DefaultVersionService
extends Object
implements 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.VersionBuilder, VersionService.VersionBuilderValidationResult, VersionService.VersionResult, VersionService.VersionsResult
 
Field Summary
 
Fields inherited from interface com.atlassian.jira.bc.project.version.VersionService
REMOVE
 
Constructor Summary
DefaultVersionService(VersionManager versionManager, PermissionManager permissionManager, IssueManager issueManager, IssueIndexManager issueIndexManager, SearchProvider searchProvider, IssueFactory issueFactory, I18nHelper.BeanFactory i18n, DateFieldFormat dateFieldFormat, com.atlassian.event.api.EventPublisher eventPublisher, ProjectManager projectManager)
           
 
Method Summary
 Version archiveVersion(VersionService.ArchiveVersionValidationResult result)
          Takes a validation result and performs the archive operation.
 ServiceOutcome<Version> create(com.atlassian.crowd.embedded.api.User user, VersionService.VersionBuilderValidationResult validationResult)
          Creates a new Version, based on the validation result from calling VersionService.validateCreate(User, VersionBuilder).
 Version createVersion(com.atlassian.crowd.embedded.api.User user, VersionService.CreateVersionValidationResult request)
          Using the validation result from VersionService.validateCreateVersion(User, com.atlassian.jira.project.Project, String, String, String, Long) a new version will be created.
 void decreaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
          Move a version to have a higher sequence number - ie make it later.
 void delete(JiraServiceContext context, VersionService.ValidationResult result)
          Deletes a version from a project.
 long getAffectsIssuesCount(Version version)
          Return the count of Issues that affect this version.
 long getFixIssuesCount(Version version)
          Return the count of Issues Fixed in this version.
 long getUnresolvedIssuesCount(com.atlassian.crowd.embedded.api.User user, Version version)
          Return the count of Issues that are unresolved in this version.
 VersionService.VersionResult getVersionById(ApplicationUser user, Long versionId)
          Used to retrieve a Version object by version id.
 VersionService.VersionResult getVersionById(ApplicationUser user, Project project, Long versionId)
          Used to retrieve a Version object by version id within project specified by Project object.
 VersionService.VersionResult getVersionById(com.atlassian.crowd.embedded.api.User user, Long versionId)
          Used to retrieve a Version object by version id.
 VersionService.VersionResult getVersionById(com.atlassian.crowd.embedded.api.User user, Project project, Long versionId)
          Used to retrieve a Version object by version id within project specified by Project object.
 VersionService.VersionResult getVersionByProjectAndName(com.atlassian.crowd.embedded.api.User user, Project project, String versionName)
          Used to retrieve a Version object by version name within project specified by Project object.
 VersionService.VersionsResult getVersionsByProject(com.atlassian.crowd.embedded.api.User user, Project project)
          Used to retrieve a Version collection within project specified by Project object.
 void increaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
          Move a version to have a lower sequence number - ie make it earlier.
 boolean isOverdue(Version version)
          Is the passed version overdue? This method does no permission checks on the passed version.
 void merge(JiraServiceContext context, VersionService.ValidationResult result)
          Merges a version into another, then removes the original version.
 void moveToEndVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
          Move a version to the end of the version sequence.
 void moveToStartVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
          Move a version to the start of the version list.
 void moveUnreleasedToNewVersion(com.atlassian.crowd.embedded.api.User user, Version currentVersion, Version newVersion)
          Using the validation result from VersionService.validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date) a version will be released.
 void moveVersionAfter(VersionService.MoveVersionValidationResult moveVersionValidationResult)
          Move a version after another version.
 VersionService.VersionBuilder newBuilder()
          Creates a builder to be used when creating a new Version.
 VersionService.VersionBuilder newBuilder(Version version)
          Creates a builder to be used when updating an existing Version.
protected  Date parseDate(com.atlassian.crowd.embedded.api.User 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.
 Version releaseVersion(VersionService.ReleaseVersionValidationResult result)
          Using the validation result from VersionService.validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date) a version will be released.
 ServiceOutcome<Version> setReleaseDate(com.atlassian.crowd.embedded.api.User user, Version version, Date releaseDate)
          Modify the release date of a version without performing a release/unrelease.
 ServiceOutcome<Version> setReleaseDate(com.atlassian.crowd.embedded.api.User user, Version version, String releaseDate)
          Modify the release date of a version without performing a release/unrelease.
 ServiceOutcome<Version> setVersionDetails(com.atlassian.crowd.embedded.api.User user, Version version, String name, String description)
          Set the name and description of a version, if you have edit permission.
 Version unarchiveVersion(VersionService.ArchiveVersionValidationResult result)
          Takes a validation result and performs the unarchive operation.
 Version unreleaseVersion(VersionService.ReleaseVersionValidationResult result)
          Using the validation result from VersionService.validateUnreleaseVersion(User, com.atlassian.jira.project.version.Version, Date) a version will be unreleased.
 ServiceOutcome<Version> update(com.atlassian.crowd.embedded.api.User user, VersionService.VersionBuilderValidationResult validationResult)
          Updates the existing Version, based on the validation result from calling VersionService.validateUpdate(User, VersionBuilder).
 VersionService.ArchiveVersionValidationResult validateArchiveVersion(com.atlassian.crowd.embedded.api.User user, Version version)
          This method should be called before archiving a version.
 VersionService.VersionBuilderValidationResult validateCreate(com.atlassian.crowd.embedded.api.User user, VersionService.VersionBuilder versionBuilder)
          Validates the creation of a new Version object, specified with a VersionService.VersionBuilder.
 VersionService.CreateVersionValidationResult validateCreateVersion(com.atlassian.crowd.embedded.api.User 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.
 VersionService.CreateVersionValidationResult validateCreateVersion(com.atlassian.crowd.embedded.api.User 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.
 VersionService.MoveVersionValidationResult validateDecreaseVersionSequence(com.atlassian.crowd.embedded.api.User user, long versionId)
          Validate Move a version to have a higher sequence number - ie make it later.
 VersionService.ValidationResult validateDelete(JiraServiceContext context, Long versionId, VersionService.VersionAction affectsAction, VersionService.VersionAction fixAction)
          Validates an attempt to delete a version from a project.
 VersionService.MoveVersionValidationResult validateIncreaseVersionSequence(com.atlassian.crowd.embedded.api.User user, long versionId)
          Validate Move a version to have a lower sequence number - ie make it earlier.
 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
 VersionService.MoveVersionValidationResult validateMoveToEndVersionSequence(com.atlassian.crowd.embedded.api.User user, long versionId)
          Validate Move a version to the end of the version sequence.
 VersionService.MoveVersionValidationResult validateMoveToStartVersionSequence(com.atlassian.crowd.embedded.api.User user, long versionId)
          Validate Move a version to the start of the version list.
 VersionService.MoveVersionValidationResult validateMoveVersionAfter(com.atlassian.crowd.embedded.api.User user, long versionId, Long scheduleAfterVersionId)
          Validate Move a version after another version.
 ServiceOutcome<Version> validateReleaseDate(com.atlassian.crowd.embedded.api.User user, Version version, String releaseDate)
          Validate the release date of a version without performing a release/unrelease.
 VersionService.ReleaseVersionValidationResult validateReleaseVersion(com.atlassian.crowd.embedded.api.User user, Version version, Date releaseDate)
          This method needs to be called before releasing a version to ensure all parameters are correct.
 VersionService.ReleaseVersionValidationResult validateReleaseVersion(com.atlassian.crowd.embedded.api.User user, Version version, String releaseDate)
          This method needs to be called before releasing a version to ensure all parameters are correct.
protected  ServiceOutcome<Void> validateStartReleaseDates(com.atlassian.crowd.embedded.api.User user, com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field, Date startDate, Date releaseDate)
           
 VersionService.ArchiveVersionValidationResult validateUnarchiveVersion(com.atlassian.crowd.embedded.api.User user, Version version)
          This method should be called before unarchiving a version.
 VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(com.atlassian.crowd.embedded.api.User user, Version version, Date releaseDate)
          This method needs to be called before unreleasing a version to ensure all parameters are correct.
 VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(com.atlassian.crowd.embedded.api.User user, Version version, String releaseDate)
          This method needs to be called before unreleasing a version to ensure all parameters are correct.
 VersionService.VersionBuilderValidationResult validateUpdate(com.atlassian.crowd.embedded.api.User user, VersionService.VersionBuilder versionBuilder)
          Validates the update of an existing Version object, specified with a VersionService.VersionBuilder.
 ErrorCollection validateVersionDetails(com.atlassian.crowd.embedded.api.User user, Version version, String name, String description)
          Validate the name and description of a version, if you have edit permission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVersionService

public DefaultVersionService(VersionManager versionManager,
                             PermissionManager permissionManager,
                             IssueManager issueManager,
                             IssueIndexManager issueIndexManager,
                             SearchProvider searchProvider,
                             IssueFactory issueFactory,
                             I18nHelper.BeanFactory i18n,
                             DateFieldFormat dateFieldFormat,
                             com.atlassian.event.api.EventPublisher eventPublisher,
                             ProjectManager projectManager)
Method Detail

getVersionById

public VersionService.VersionResult getVersionById(ApplicationUser user,
                                                   Project project,
                                                   Long versionId)
Description copied from interface: VersionService
Used to retrieve a Version object by version id within project specified by Project object. This method returns a VersionService.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:
getVersionById in interface VersionService
Parameters:
user - The user trying to get a version
project - The project object containing requested version
versionId - The id of requested version
Returns:
VersionResult object

getVersionById

public VersionService.VersionResult getVersionById(com.atlassian.crowd.embedded.api.User user,
                                                   Project project,
                                                   Long versionId)
Description copied from interface: VersionService
Used to retrieve a Version object by version id within project specified by Project object. This method returns a VersionService.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:
getVersionById in interface VersionService
Parameters:
user - The user trying to get a version
project - The project object containing requested version
versionId - The id of requested version
Returns:
VersionResult object

getVersionById

public VersionService.VersionResult getVersionById(ApplicationUser user,
                                                   Long versionId)
Description copied from interface: VersionService
Used to retrieve a Version object by version id. This method returns a VersionService.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:
getVersionById in interface VersionService
Parameters:
user - The user trying to get a version
versionId - The id of requested version
Returns:
VersionResult object

getVersionById

public VersionService.VersionResult getVersionById(com.atlassian.crowd.embedded.api.User user,
                                                   Long versionId)
Description copied from interface: VersionService
Used to retrieve a Version object by version id. This method returns a VersionService.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:
getVersionById in interface VersionService
Parameters:
user - The user trying to get a version
versionId - The id of requested version
Returns:
VersionResult object

getVersionByProjectAndName

public VersionService.VersionResult getVersionByProjectAndName(com.atlassian.crowd.embedded.api.User user,
                                                               Project project,
                                                               String versionName)
Description copied from interface: VersionService
Used to retrieve a Version object by version name within project specified by Project object. This method returns a VersionService.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:
getVersionByProjectAndName in interface VersionService
Parameters:
user - The user trying to get a version
project - The project object containing requested version
versionName - The name of requested version
Returns:
VerionResult object

getVersionsByProject

public VersionService.VersionsResult getVersionsByProject(com.atlassian.crowd.embedded.api.User user,
                                                          Project project)
Description copied from interface: VersionService
Used to retrieve a Version collection within project specified by Project object. This method returns a VersionService.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:
getVersionsByProject in interface VersionService
Parameters:
user - The user trying to get a version
project - The project object containing requested version
Returns:
VerionsResult object

setVersionDetails

public ServiceOutcome<Version> setVersionDetails(com.atlassian.crowd.embedded.api.User user,
                                                 Version version,
                                                 String name,
                                                 String description)
Description copied from interface: VersionService
Set the name and description of a version, if you have edit permission.

Specified by:
setVersionDetails in interface VersionService
Parameters:
user - the user who is performing the edit operation
version - the version that they want to edit
name - 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

validateVersionDetails

public ErrorCollection validateVersionDetails(com.atlassian.crowd.embedded.api.User user,
                                              Version version,
                                              String name,
                                              String description)
Description copied from interface: VersionService
Validate the name and description of a version, if you have edit permission.

Specified by:
validateVersionDetails in interface VersionService
Parameters:
user - the user who is performing the edit operation
version - the version that they want to edit
name - the new name for the version (must not be null or already in use)
description - the new description for the version
Returns:
an ErrorCollection that contains the success or failure of the update

setReleaseDate

public ServiceOutcome<Version> setReleaseDate(com.atlassian.crowd.embedded.api.User user,
                                              Version version,
                                              Date releaseDate)
Description copied from interface: VersionService
Modify the release date of a version without performing a release/unrelease.

Specified by:
setReleaseDate in interface VersionService
Parameters:
user - the user who is changing the release date
version - the version they want to modify
releaseDate - the new release date to use
Returns:
a ServiceOutcome describing the success/failure of the edit, along with the new Version if successful

validateReleaseDate

public ServiceOutcome<Version> validateReleaseDate(com.atlassian.crowd.embedded.api.User user,
                                                   Version version,
                                                   String releaseDate)
Description copied from interface: VersionService
Validate the release date of a version without performing a release/unrelease.

Specified by:
validateReleaseDate in interface VersionService
Parameters:
user - the user who is changing the release date
version - the version they want to modify
releaseDate - 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(com.atlassian.crowd.embedded.api.User user,
                                              Version version,
                                              String releaseDate)
Description copied from interface: VersionService
Modify the release date of a version without performing a release/unrelease.

Specified by:
setReleaseDate in interface VersionService
Parameters:
user - the user who is changing the release date
version - the version they want to modify
releaseDate - 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: VersionService
Validates 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:
validateDelete in interface VersionService
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. See VersionKeys.REMOVE_ACTION, VersionKeys.SWAP_ACTION
fixAction - Used to decide wether to move all the issues to a different 'fix' version or just remove them. See VersionKeys.REMOVE_ACTION, VersionKeys.SWAP_ACTION
Returns:
a VersionService.ValidationResult object 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 is VersionKeys.REMOVE_ACTION

delete

public void delete(JiraServiceContext context,
                   VersionService.ValidationResult result)
Description copied from interface: VersionService
Deletes 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:
delete in interface VersionService
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

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:
validateMerge in interface VersionService
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.ValidationResult object 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 is VersionKeys.REMOVE_ACTION

merge

public void merge(JiraServiceContext context,
                  VersionService.ValidationResult result)
Description copied from interface: VersionService
Merges a version into another, then removes the original version.

Specified by:
merge in interface VersionService
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(com.atlassian.crowd.embedded.api.User user,
                                                                          Project project,
                                                                          String versionName,
                                                                          String releaseDateStr,
                                                                          String description,
                                                                          Long scheduleAfterVersion)
Description copied from interface: VersionService
This 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.CreateVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateCreateVersion in interface VersionService
Parameters:
user - The user trying to create a version
project - The project object containing requested version
versionName - The name of created version
releaseDateStr - 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(com.atlassian.crowd.embedded.api.User user,
                                                                          Project project,
                                                                          String versionName,
                                                                          Date releaseDate,
                                                                          String description,
                                                                          Long scheduleAfterVersion)
Description copied from interface: VersionService
This 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.CreateVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateCreateVersion in interface VersionService
Parameters:
user - The user trying to create a version
project - The project object containing requested version
versionName - The name of created version
releaseDate - 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(com.atlassian.crowd.embedded.api.User user,
                             VersionService.CreateVersionValidationResult request)
Description copied from interface: VersionService
Using the validation result from VersionService.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:
createVersion in interface VersionService
Parameters:
user - The user trying to get a version
request - The VersionService.CreateVersionValidationResult object containg all required data
Returns:
created Version object

validateReleaseVersion

public VersionService.ReleaseVersionValidationResult validateReleaseVersion(com.atlassian.crowd.embedded.api.User user,
                                                                            Version version,
                                                                            Date releaseDate)
Description copied from interface: VersionService
This 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.ReleaseVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateReleaseVersion in interface VersionService
Parameters:
user - The user trying to release a version
version - The version to release
releaseDate - The version release date (optional)
Returns:
ReleaseVersionValidationResult object

validateReleaseVersion

public VersionService.ReleaseVersionValidationResult validateReleaseVersion(com.atlassian.crowd.embedded.api.User user,
                                                                            Version version,
                                                                            String releaseDate)
Description copied from interface: VersionService
This 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.ReleaseVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateReleaseVersion in interface VersionService
Parameters:
user - The user trying to release a version
version - The version to release
releaseDate - The version release date (optional)
Returns:
ReleaseVersionValidationResult object

validateUnreleaseVersion

public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(com.atlassian.crowd.embedded.api.User user,
                                                                              Version version,
                                                                              Date releaseDate)
Description copied from interface: VersionService
This 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.ReleaseVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateUnreleaseVersion in interface VersionService
Parameters:
user - The user trying to unrelease a version
version - The version to release
releaseDate - The version release date (optional)
Returns:
ReleaseVersionValidationResult object

validateUnreleaseVersion

public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(com.atlassian.crowd.embedded.api.User user,
                                                                              Version version,
                                                                              String releaseDate)
Description copied from interface: VersionService
This 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.ReleaseVersionValidationResult which contains an ErrorCollection with any potential errors and all the version's details.

Specified by:
validateUnreleaseVersion in interface VersionService
Parameters:
user - The user trying to unrelease a version
version - The version to release
releaseDate - The version release date (optional)
Returns:
ReleaseVersionValidationResult object

validateArchiveVersion

public VersionService.ArchiveVersionValidationResult validateArchiveVersion(com.atlassian.crowd.embedded.api.User user,
                                                                            Version version)
Description copied from interface: VersionService
This 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:
validateArchiveVersion in interface VersionService
Parameters:
user - The user performing this operation
version - The version to be archived
Returns:
a validation result, containing any errors or the version details on success

validateUnarchiveVersion

public VersionService.ArchiveVersionValidationResult validateUnarchiveVersion(com.atlassian.crowd.embedded.api.User user,
                                                                              Version version)
Description copied from interface: VersionService
This 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:
validateUnarchiveVersion in interface VersionService
Parameters:
user - The user performing this operation
version - The version to be archived
Returns:
a validation result, containing any errors or the version details on success

releaseVersion

public Version releaseVersion(VersionService.ReleaseVersionValidationResult result)
Description copied from interface: VersionService
Using the validation result from VersionService.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:
releaseVersion in interface VersionService
Parameters:
result - a ReleaseVersionValidationResult containg required data
Returns:
a released version object

moveUnreleasedToNewVersion

public void moveUnreleasedToNewVersion(com.atlassian.crowd.embedded.api.User user,
                                       Version currentVersion,
                                       Version newVersion)
Description copied from interface: VersionService
Using the validation result from VersionService.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:
moveUnreleasedToNewVersion in interface VersionService
Parameters:
user - The user trying to release a version
currentVersion - The current version being released.
newVersion - The version to move issues to.

unreleaseVersion

public Version unreleaseVersion(VersionService.ReleaseVersionValidationResult result)
Description copied from interface: VersionService
Using the validation result from VersionService.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:
unreleaseVersion in interface VersionService
Parameters:
result - a ReleaseVersionValidationResult containg required data
Returns:
a unreleased version object

archiveVersion

public Version archiveVersion(VersionService.ArchiveVersionValidationResult result)
Description copied from interface: VersionService
Takes a validation result and performs the archive operation.

Specified by:
archiveVersion in interface VersionService
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

public Version unarchiveVersion(VersionService.ArchiveVersionValidationResult result)
Description copied from interface: VersionService
Takes a validation result and performs the unarchive operation.

Specified by:
unarchiveVersion in interface VersionService
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

public VersionService.MoveVersionValidationResult validateMoveToStartVersionSequence(com.atlassian.crowd.embedded.api.User user,
                                                                                     long versionId)
Description copied from interface: VersionService
Validate Move a version to the start of the version list.

Specified by:
validateMoveToStartVersionSequence in interface VersionService
Parameters:
user - The user trying to move a version
Returns:
a validation result, containing any errors or the version details on success

validateIncreaseVersionSequence

public VersionService.MoveVersionValidationResult validateIncreaseVersionSequence(com.atlassian.crowd.embedded.api.User user,
                                                                                  long versionId)
Description copied from interface: VersionService
Validate Move a version to have a lower sequence number - ie make it earlier.

Specified by:
validateIncreaseVersionSequence in interface VersionService
Parameters:
user - The user trying to move a version
Returns:
a validation result, containing any errors or the version details on success

validateDecreaseVersionSequence

public VersionService.MoveVersionValidationResult validateDecreaseVersionSequence(com.atlassian.crowd.embedded.api.User user,
                                                                                  long versionId)
Description copied from interface: VersionService
Validate Move a version to have a higher sequence number - ie make it later.

Specified by:
validateDecreaseVersionSequence in interface VersionService
Parameters:
user - The user trying to move a version
Returns:
a validation result, containing any errors or the version details on success

validateMoveToEndVersionSequence

public VersionService.MoveVersionValidationResult validateMoveToEndVersionSequence(com.atlassian.crowd.embedded.api.User user,
                                                                                   long versionId)
Description copied from interface: VersionService
Validate Move a version to the end of the version sequence.

Specified by:
validateMoveToEndVersionSequence in interface VersionService
Parameters:
user - The user trying to move a version
Returns:
a validation result, containing any errors or the version details on success

validateMoveVersionAfter

public VersionService.MoveVersionValidationResult validateMoveVersionAfter(com.atlassian.crowd.embedded.api.User user,
                                                                           long versionId,
                                                                           Long scheduleAfterVersionId)
Description copied from interface: VersionService
Validate Move a version after another version.

Specified by:
validateMoveVersionAfter in interface VersionService
Parameters:
user - The user trying to move a version
versionId - version to reschedule
scheduleAfterVersionId - 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: VersionService
Move a version to the start of the version list.

Specified by:
moveToStartVersionSequence in interface VersionService
Parameters:
moveVersionValidationResult - Move Version Validation Result

increaseVersionSequence

public void increaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
Description copied from interface: VersionService
Move a version to have a lower sequence number - ie make it earlier.

Specified by:
increaseVersionSequence in interface VersionService
Parameters:
moveVersionValidationResult - Move Version Validation Result

decreaseVersionSequence

public void decreaseVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
Description copied from interface: VersionService
Move a version to have a higher sequence number - ie make it later.

Specified by:
decreaseVersionSequence in interface VersionService
Parameters:
moveVersionValidationResult - Move Version Validation Result

moveToEndVersionSequence

public void moveToEndVersionSequence(VersionService.MoveVersionValidationResult moveVersionValidationResult)
Description copied from interface: VersionService
Move a version to the end of the version sequence.

Specified by:
moveToEndVersionSequence in interface VersionService
Parameters:
moveVersionValidationResult - Move Version Validation Result

moveVersionAfter

public void moveVersionAfter(VersionService.MoveVersionValidationResult moveVersionValidationResult)
Description copied from interface: VersionService
Move a version after another version.

Specified by:
moveVersionAfter in interface VersionService
Parameters:
moveVersionValidationResult - Move Version Validation Result

isOverdue

public boolean isOverdue(Version version)
Description copied from interface: VersionService
Is the passed version overdue? This method does no permission checks on the passed version.

Specified by:
isOverdue in interface VersionService
Parameters:
version - the version to check.
Returns:
true if the passed version is overdue.

getFixIssuesCount

public long getFixIssuesCount(Version version)
Description copied from interface: VersionService
Return the count of Issues Fixed in this version.

Specified by:
getFixIssuesCount in interface VersionService
Returns:
A count of issues

getAffectsIssuesCount

public long getAffectsIssuesCount(Version version)
Description copied from interface: VersionService
Return the count of Issues that affect this version.

Specified by:
getAffectsIssuesCount in interface VersionService
Returns:
A count of issues

getUnresolvedIssuesCount

public long getUnresolvedIssuesCount(com.atlassian.crowd.embedded.api.User user,
                                     Version version)
Description copied from interface: VersionService
Return 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:
getUnresolvedIssuesCount in interface VersionService
Parameters:
user - the user trying to release the version
version - which version to check for unresolved issues
Returns:
A count of issues

parseDate

@Nullable
protected Date parseDate(com.atlassian.crowd.embedded.api.User 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 date
field - a DateField instance containing information what kind of date we are parsing
date - 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(com.atlassian.crowd.embedded.api.User user,
                                                         com.atlassian.jira.bc.project.version.DefaultVersionService.DateField field,
                                                         Date startDate,
                                                         Date releaseDate)

newBuilder

public VersionService.VersionBuilder newBuilder()
Description copied from interface: VersionService
Creates a builder to be used when creating a new Version. The builder encapsulates all the fields which need to be specified on create.

Specified by:
newBuilder in interface VersionService
Returns:
the builder instance
See Also:
for updating an existing version

validateCreate

public VersionService.VersionBuilderValidationResult validateCreate(com.atlassian.crowd.embedded.api.User user,
                                                                    VersionService.VersionBuilder versionBuilder)
Description copied from interface: VersionService
Validates the creation of a new Version object, specified with a VersionService.VersionBuilder.

This replaces the deprecated methods: VersionService.validateCreateVersion(User, Project, String, Date, String, Long) and VersionService.validateCreateVersion(User, Project, String, String, String, Long).

Specified by:
validateCreate in interface VersionService
Parameters:
user - the user who is performing the create
versionBuilder - the builder which specified the new Version to be created
Returns:
the result
See Also:
VersionService.newBuilder()

create

public ServiceOutcome<Version> create(com.atlassian.crowd.embedded.api.User user,
                                      VersionService.VersionBuilderValidationResult validationResult)
Description copied from interface: VersionService
Creates a new Version, based on the validation result from calling VersionService.validateCreate(User, VersionBuilder).

Specified by:
create in interface VersionService
Parameters:
user - the user
validationResult - the result of validation
Returns:
the new Version object; errors if not successful.
See Also:
VersionService.validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder)

newBuilder

public VersionService.VersionBuilder newBuilder(Version version)
Description copied from interface: VersionService
Creates a builder to be used when updating an existing Version. The builder encapsulates all the fields which need to be specified on update.

Specified by:
newBuilder in interface VersionService
Parameters:
version - the Version object to update
Returns:
the builder instance
See Also:
for creating a new version

validateUpdate

public VersionService.VersionBuilderValidationResult validateUpdate(com.atlassian.crowd.embedded.api.User user,
                                                                    VersionService.VersionBuilder versionBuilder)
Description copied from interface: VersionService
Validates the update of an existing Version object, specified with a VersionService.VersionBuilder.

This replaces the deprecated methods: VersionService.validateReleaseDate(User, Version, String) and VersionService.validateVersionDetails(User, Version, String, String).

Specified by:
validateUpdate in interface VersionService
Parameters:
user - the user who is performing the update
versionBuilder - the builder which specified the update to the existing Version
Returns:
the result
See Also:
VersionService.newBuilder(com.atlassian.jira.project.version.Version)

update

public ServiceOutcome<Version> update(com.atlassian.crowd.embedded.api.User user,
                                      VersionService.VersionBuilderValidationResult validationResult)
Description copied from interface: VersionService
Updates the existing Version, based on the validation result from calling VersionService.validateUpdate(User, VersionBuilder).

Specified by:
update in interface VersionService
Parameters:
user - the user
validationResult - the result of validation
Returns:
the updated Version object; errors if not successful.
See Also:
VersionService.validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder)


Copyright © 2002-2014 Atlassian. All Rights Reserved.