@PublicApi public interface

VersionService

com.atlassian.jira.bc.project.version.VersionService
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Service for VersionService

Summary

Nested Classes
class VersionService.AbstractVersionResult  
class VersionService.ArchiveVersionValidationResult  
class VersionService.CreateVersionValidationResult  
class VersionService.MoveVersionValidationResult  
class VersionService.ReasonsServiceResult<R, T> A generified ServiceResultImpl that allows Service-specified Reasons to be set as part of the result (in addition to Reasons specified inside the ErrorCollection
class VersionService.ReleaseVersionValidationResult  
interface VersionService.ValidationResult Represents the results of performing a validation call for a single merge or delete operation. 
interface VersionService.VersionAction  
class VersionService.VersionBuilder A builder class to specify a new Version to create or an existing Version to update. 
class VersionService.VersionBuilderValidationResult Result object that relates to new VersionService methods that take a VersionService.VersionBuilder as a parameter. 
class VersionService.VersionResult  
class VersionService.VersionsResult  
Fields
public static final VersionService.VersionAction REMOVE Indicates that the Version should be removed from affected issues.
Public Methods
Version archiveVersion(VersionService.ArchiveVersionValidationResult result)
Takes a validation result and performs the archive operation.
ServiceOutcome<Version> create(User user, VersionService.VersionBuilderValidationResult validationResult)
Creates a new Version, based on the validation result from calling validateCreate(User, VersionBuilder).
Version createVersion(User user, VersionService.CreateVersionValidationResult request)
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(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(User user, Long versionId)
This method is deprecated. Use getVersionById(ApplicationUser, Long) instead. Since v6.1.1.
VersionService.VersionResult getVersionById(User user, Project project, Long versionId)
This method is deprecated. Use getVersionById(ApplicationUser, Project, Long) instead. Since v6.1.1.
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 getVersionByProjectAndName(User user, Project project, String versionName)
Used to retrieve a Version object by version name within project specified by Project object.
VersionService.VersionsResult getVersionsByProject(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(User user, Version currentVersion, Version newVersion)
Using the validation result from 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(Version version)
Creates a builder to be used when updating an existing Version.
VersionService.VersionBuilder newBuilder()
Creates a builder to be used when creating a new Version.
Version releaseVersion(VersionService.ReleaseVersionValidationResult result)
Using the validation result from validateReleaseVersion(User, com.atlassian.jira.project.version.Version, Date) a version will be released.
ServiceOutcome<Version> setReleaseDate(User user, Version version, String releaseDate)
ServiceOutcome<Version> setReleaseDate(User user, Version version, Date releaseDate)
ServiceOutcome<Version> setVersionDetails(User user, Version version, String name, String description)
Version unarchiveVersion(VersionService.ArchiveVersionValidationResult result)
Takes a validation result and performs the unarchive operation.
Version unreleaseVersion(VersionService.ReleaseVersionValidationResult result)
Using the validation result from validateUnreleaseVersion(User, com.atlassian.jira.project.version.Version, Date) a version will be unreleased.
ServiceOutcome<Version> update(User user, VersionService.VersionBuilderValidationResult validationResult)
Updates the existing Version, based on the validation result from calling validateUpdate(User, VersionBuilder).
VersionService.ArchiveVersionValidationResult validateArchiveVersion(User user, Version version)
This method should be called before archiving a version.
VersionService.VersionBuilderValidationResult validateCreate(User user, VersionService.VersionBuilder versionBuilder)
Validates the creation of a new Version object, specified with a VersionService.VersionBuilder.
VersionService.CreateVersionValidationResult validateCreateVersion(User user, Project project, String versionName, String releaseDate, String description, Long scheduleAfterVersion)
VersionService.CreateVersionValidationResult validateCreateVersion(User user, Project project, String versionName, Date releaseDate, String description, Long scheduleAfterVersion)
VersionService.MoveVersionValidationResult validateDecreaseVersionSequence(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(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)
Validates an attempt to merge a version into another.
VersionService.MoveVersionValidationResult validateMoveToEndVersionSequence(User user, long versionId)
Validate Move a version to the end of the version sequence.
VersionService.MoveVersionValidationResult validateMoveToStartVersionSequence(User user, long versionId)
Validate Move a version to the start of the version list.
VersionService.MoveVersionValidationResult validateMoveVersionAfter(User user, long versionId, Long scheduleAfterVersion)
Validate Move a version after another version.
ServiceOutcome<Version> validateReleaseDate(User user, Version version, String releaseDate)
VersionService.ReleaseVersionValidationResult validateReleaseVersion(User user, Version version, String releaseDate)
This method needs to be called before releasing a version to ensure all parameters are correct.
VersionService.ReleaseVersionValidationResult validateReleaseVersion(User user, Version version, Date releaseDate)
This method needs to be called before releasing a version to ensure all parameters are correct.
VersionService.ArchiveVersionValidationResult validateUnarchiveVersion(User user, Version version)
This method should be called before unarchiving a version.
VersionService.ReleaseVersionValidationResult validateUnreleaseVersion(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(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(User user, VersionService.VersionBuilder versionBuilder)
Validates the update of an existing Version object, specified with a VersionService.VersionBuilder.
ErrorCollection validateVersionDetails(User user, Version version, String name, String description)

Fields

public static final VersionService.VersionAction REMOVE

Indicates that the Version should be removed from affected issues.

Public Methods

public Version archiveVersion (VersionService.ArchiveVersionValidationResult result)

Takes a validation result and performs the archive operation.

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
Throws
IllegalStateException if the result passed in is not valid.

public ServiceOutcome<Version> create (User user, VersionService.VersionBuilderValidationResult validationResult)

Creates a new Version, based on the validation result from calling validateCreate(User, VersionBuilder).

Parameters
user the user
validationResult the result of validation
Returns
  • the new Version object; errors if not successful.

public Version createVersion (User user, VersionService.CreateVersionValidationResult request)

This method is deprecated.
Use validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and create(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult)

Using 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.

Parameters
user The user trying to get a version
request The VersionService.CreateVersionValidationResult object containg all required data
Returns
  • created Version object

public void decreaseVersionSequence (VersionService.MoveVersionValidationResult moveVersionValidationResult)

Move a version to have a higher sequence number - ie make it later.

Parameters
moveVersionValidationResult Move Version Validation Result

public void delete (JiraServiceContext context, VersionService.ValidationResult result)

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.

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

public long getAffectsIssuesCount (Version version)

Return the count of Issues that affect this version.

Returns
  • A count of issues

public long getFixIssuesCount (Version version)

Return the count of Issues Fixed in this version.

Returns
  • A count of issues

public long getUnresolvedIssuesCount (User user, Version version)

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.

Parameters
user the user trying to release the version
version which version to check for unresolved issues
Returns
  • A count of issues

public VersionService.VersionResult getVersionById (ApplicationUser user, Long versionId)

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.

Parameters
user The user trying to get a version
versionId The id of requested version
Returns
  • VersionResult object

public VersionService.VersionResult getVersionById (User user, Long versionId)

This method is deprecated.
Use getVersionById(ApplicationUser, Long) instead. Since v6.1.1.

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.

Parameters
user The user trying to get a version
versionId The id of requested version
Returns
  • VersionResult object

public VersionService.VersionResult getVersionById (User user, Project project, Long versionId)

This method is deprecated.
Use getVersionById(ApplicationUser, Project, Long) instead. Since v6.1.1.

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.

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

public VersionService.VersionResult getVersionById (ApplicationUser user, Project project, Long versionId)

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.

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

public VersionService.VersionResult getVersionByProjectAndName (User user, Project project, String versionName)

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.

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

public VersionService.VersionsResult getVersionsByProject (User user, Project project)

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.

Parameters
user The user trying to get a version
project The project object containing requested version
Returns
  • VerionsResult object

public void increaseVersionSequence (VersionService.MoveVersionValidationResult moveVersionValidationResult)

Move a version to have a lower sequence number - ie make it earlier.

Parameters
moveVersionValidationResult Move Version Validation Result

public boolean isOverdue (Version version)

Is the passed version overdue? This method does no permission checks on the passed version.

Parameters
version the version to check.
Returns
  • true if the passed version is overdue.

public void merge (JiraServiceContext context, VersionService.ValidationResult result)

Merges a version into another, then removes the original version.

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

public void moveToEndVersionSequence (VersionService.MoveVersionValidationResult moveVersionValidationResult)

Move a version to the end of the version sequence.

Parameters
moveVersionValidationResult Move Version Validation Result

public void moveToStartVersionSequence (VersionService.MoveVersionValidationResult moveVersionValidationResult)

Move a version to the start of the version list.

Parameters
moveVersionValidationResult Move Version Validation Result

public void moveUnreleasedToNewVersion (User user, Version currentVersion, Version newVersion)

Using 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.

Parameters
user The user trying to release a version
currentVersion The current version being released.
newVersion The version to move issues to.

public void moveVersionAfter (VersionService.MoveVersionValidationResult moveVersionValidationResult)

Move a version after another version.

Parameters
moveVersionValidationResult Move Version Validation Result

public VersionService.VersionBuilder newBuilder (Version version)

Creates a builder to be used when updating an existing Version. The builder encapsulates all the fields which need to be specified on update.

Parameters
version the Version object to update
Returns
  • the builder instance

public VersionService.VersionBuilder newBuilder ()

Creates a builder to be used when creating a new Version. The builder encapsulates all the fields which need to be specified on create.

Returns
  • the builder instance

public Version releaseVersion (VersionService.ReleaseVersionValidationResult result)

Using 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.

Parameters
result a ReleaseVersionValidationResult containg required data
Returns
  • a released version object

public ServiceOutcome<Version> setReleaseDate (User user, Version version, String releaseDate)

This method is deprecated.
Use validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and update(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult).

Modify the release date of a version without performing a release/unrelease.

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

public ServiceOutcome<Version> setReleaseDate (User user, Version version, Date releaseDate)

This method is deprecated.
Use validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and update(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult).

Modify the release date of a version without performing a release/unrelease.

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

public ServiceOutcome<Version> setVersionDetails (User user, Version version, String name, String description)

This method is deprecated.
Use validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and update(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult).

Set the name and description of a version, if you have edit permission.

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
Throws
IllegalArgumentException if the name is null or duplicates an existing name

public Version unarchiveVersion (VersionService.ArchiveVersionValidationResult result)

Takes a validation result and performs the unarchive operation.

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
Throws
IllegalStateException if the result passed in is not valid.

public Version unreleaseVersion (VersionService.ReleaseVersionValidationResult result)

Using 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.

Parameters
result a ReleaseVersionValidationResult containg required data
Returns
  • a unreleased version object

public ServiceOutcome<Version> update (User user, VersionService.VersionBuilderValidationResult validationResult)

Updates the existing Version, based on the validation result from calling validateUpdate(User, VersionBuilder).

Parameters
user the user
validationResult the result of validation
Returns
  • the updated Version object; errors if not successful.

public VersionService.ArchiveVersionValidationResult validateArchiveVersion (User user, Version version)

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.

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

public VersionService.VersionBuilderValidationResult validateCreate (User user, VersionService.VersionBuilder versionBuilder)

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

public VersionService.CreateVersionValidationResult validateCreateVersion (User user, Project project, String versionName, String releaseDate, String description, Long scheduleAfterVersion)

This method is deprecated.
Use validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and create(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult)

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.

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

public VersionService.CreateVersionValidationResult validateCreateVersion (User user, Project project, String versionName, Date releaseDate, String description, Long scheduleAfterVersion)

This method is deprecated.
Use validateCreate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and create(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult)

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.

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

public VersionService.MoveVersionValidationResult validateDecreaseVersionSequence (User user, long versionId)

Validate Move a version to have a higher sequence number - ie make it later.

Parameters
user The user trying to move a version
Returns
  • a validation result, containing any errors or the version details on success

public VersionService.ValidationResult validateDelete (JiraServiceContext context, Long versionId, VersionService.VersionAction affectsAction, VersionService.VersionAction fixAction)

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.

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 REMOVE_ACTION, SWAP_ACTION
fixAction Used to decide wether to move all the issues to a different 'fix' version or just remove them. See REMOVE_ACTION, SWAP_ACTION
Returns

public VersionService.MoveVersionValidationResult validateIncreaseVersionSequence (User user, long versionId)

Validate Move a version to have a lower sequence number - ie make it earlier.

Parameters
user The user trying to move a version
Returns
  • a validation result, containing any errors or the version details on success

public VersionService.ValidationResult validateMerge (JiraServiceContext context, Long versionId, Long swapVersionId)

Validates an attempt to merge a version into another. Merging is essentially the same as Deleting with the actions set to SWAP_ACTION.

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

public VersionService.MoveVersionValidationResult validateMoveToEndVersionSequence (User user, long versionId)

Validate Move a version to the end of the version sequence.

Parameters
user The user trying to move a version
Returns
  • a validation result, containing any errors or the version details on success

public VersionService.MoveVersionValidationResult validateMoveToStartVersionSequence (User user, long versionId)

Validate Move a version to the start of the version list.

Parameters
user The user trying to move a version
Returns
  • a validation result, containing any errors or the version details on success

public VersionService.MoveVersionValidationResult validateMoveVersionAfter (User user, long versionId, Long scheduleAfterVersion)

Validate Move a version after another version.

Parameters
user The user trying to move a version
versionId version to reschedule
scheduleAfterVersion 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

public ServiceOutcome<Version> validateReleaseDate (User user, Version version, String releaseDate)

This method is deprecated.
Use validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and update(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult).

Validate the release date of a version without performing a release/unrelease.

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

public VersionService.ReleaseVersionValidationResult validateReleaseVersion (User user, Version version, String releaseDate)

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.

Parameters
user The user trying to release a version
version The version to release
releaseDate The version release date (optional)
Returns
  • ReleaseVersionValidationResult object

public VersionService.ReleaseVersionValidationResult validateReleaseVersion (User user, Version version, Date releaseDate)

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.

Parameters
user The user trying to release a version
version The version to release
releaseDate The version release date (optional)
Returns
  • ReleaseVersionValidationResult object

public VersionService.ArchiveVersionValidationResult validateUnarchiveVersion (User user, Version version)

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.

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

public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion (User user, Version version, Date releaseDate)

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.

Parameters
user The user trying to unrelease a version
version The version to release
releaseDate The version release date (optional)
Returns
  • ReleaseVersionValidationResult object

public VersionService.ReleaseVersionValidationResult validateUnreleaseVersion (User user, Version version, String releaseDate)

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.

Parameters
user The user trying to unrelease a version
version The version to release
releaseDate The version release date (optional)
Returns
  • ReleaseVersionValidationResult object

public VersionService.VersionBuilderValidationResult validateUpdate (User user, VersionService.VersionBuilder versionBuilder)

Validates the update of an existing Version object, specified with a VersionService.VersionBuilder.

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

Parameters
user the user who is performing the update
versionBuilder the builder which specified the update to the existing Version
Returns
  • the result

public ErrorCollection validateVersionDetails (User user, Version version, String name, String description)

This method is deprecated.
Use validateUpdate(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilder) and update(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.project.version.VersionService.VersionBuilderValidationResult).

Validate the name and description of a version, if you have edit permission.

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
Throws
IllegalArgumentException if the name is null or duplicates an existing name