@PublicApi
public interface ProjectService
Modifier and Type | Interface and Description |
---|---|
static class |
ProjectService.AbstractProjectResult |
static class |
ProjectService.AbstractProjectValidationResult |
static class |
ProjectService.CreateProjectValidationResult |
static class |
ProjectService.DeleteProjectResult |
static class |
ProjectService.DeleteProjectValidationResult |
static class |
ProjectService.GetProjectResult |
static class |
ProjectService.UpdateProjectRequest |
static class |
ProjectService.UpdateProjectSchemesValidationResult |
static class |
ProjectService.UpdateProjectValidationResult |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NAME_LENGTH
Default project name length
|
static int |
MAX_KEY_LENGTH
Deprecated.
use getMaximumKeyLength() instead
|
static int |
MAX_NAME_LENGTH
Deprecated.
use getMaximumNameLength() instead;
|
static int |
MIN_NAME_LENGTH
The minimum length allowed for the project name field.
|
static String |
PROJECT_CATEGORY_ID
The default name of HTML fields containing the ID of a project's category.
|
static String |
PROJECT_DESCRIPTION
The default name of HTML fields containing a Project's description.
|
static String |
PROJECT_KEY
The default name of HTML fields containing a Project's key.
|
static String |
PROJECT_LEAD
The default name of HTML fields containing a Project's lead.
|
static String |
PROJECT_NAME
The default name of HTML fields containing a Project's name.
|
static String |
PROJECT_TYPE
The default name of HTML fields containing a Project's type.
|
static String |
PROJECT_URL
The default name of HTML fields containing a Project's URL.
|
static final String PROJECT_NAME
ErrorCollection
with error messages keyed
to this field name.static final String PROJECT_KEY
ErrorCollection
with error messages keyed
to this field name.static final String PROJECT_LEAD
ErrorCollection
with error messages keyed
to this field name.static final String PROJECT_URL
ErrorCollection
with error messages keyed
to this field name.static final String PROJECT_DESCRIPTION
ErrorCollection
with error messages keyed
to this field name.static final String PROJECT_CATEGORY_ID
static final String PROJECT_TYPE
ErrorCollection
with error messages keyed to this field name.static final int MAX_NAME_LENGTH
static final int MIN_NAME_LENGTH
static final int MAX_KEY_LENGTH
static final int DEFAULT_NAME_LENGTH
@Nonnull ProjectService.CreateProjectValidationResult validateCreateProject(ApplicationUser user, @Nonnull ProjectCreationData projectCreationData)
AssigneeTypes.PROJECT_LEAD
,
AssigneeTypes.UNASSIGNED
, or null to let JIRA decide on the best default
assignee. UNASSIGNED will also only be valid, if unassigned issues are enabled in the General Configuration.
All the projects created in JIRA must have a project type, and its value must correspond to one of the project types defined on the JIRA
instance. A validation error will be reported if no project type is passed or if it does not meet the previous criteria.
There are two ways to provide the project type to this method: directly via ProjectCreationData.getProjectTypeKey()
or
indirectly via ProjectCreationData.getProjectTemplateKey()
.
If a project template key is provided, this method will look up the project template and use the template's project type as
the type of the created project.
If both a project type and a template key are provided on the received ProjectCreationData
, the project
type defined on the template will be compared to the project type defined in the project creation date and, if
they don't match, a validation error will be reported.
Providing a template key is the preferred method for creating a project since templates ensure projects are created in a more
useful way for a particular use case.
The method will return a ProjectService.CreateProjectValidationResult
which
contains an ErrorCollection with any potential errors and all the project's details.user
- The user performing the actionprojectCreationData
- An object encapsulating all the data for the project that will get createdProject createProject(ProjectService.CreateProjectValidationResult createProjectValidationResult)
validateCreateProject(ApplicationUser, ProjectCreationData)
a new project will be created.
This method will throw an IllegalStateException if the validation result contains any errors.
Project creation involves creating the project itself and setting some defaults for workflow schemes and issue
type screen schemes.
If the validation result contains an existing project id, the new project will be created with shared schemes, that is
the a new project will be associated with the the same schemes as the existing project:
createProjectValidationResult
- Result from the validation, which also contains all the project's details.IllegalStateException
- if the validation result contains any errors.@Nonnull ProjectService.CreateProjectValidationResult validateCreateProjectBasedOnExistingProject(ApplicationUser user, @Nonnull Long existingProjectId, ProjectCreationData projectCreationData)
ProjectAction.EDIT_PROJECT_CONFIG
permissions for it. Beyond these checks, validation rules will be the same as validateCreateProject(ApplicationUser, ProjectCreationData)
.user
- The user performing the actionexistingProjectId
- An existing project id to use as the base for the new project being createdprojectCreationData
- An object encapsulating all the data for the project that will get createdServiceResult validateUpdateProject(ApplicationUser user, String key)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2user
- The user trying to update a projectkey
- The project key of the project to update.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
The only difference is that the project key will obviously not be validated.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question.user
- The user trying to update a projectname
- The name of the new projectkey
- The project key of the project to update.description
- An optional description for the projectleadName
- The username of the lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
The only difference is that the project key will obviously not be validated.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question.
WARNING: In 6.0-6.0.5, this method is available but does not work properly for renamed users (JRA-33843).user
- The user trying to update a projectname
- The name of the new projectkey
- The project key of the project to update.description
- An optional description for the projectlead
- The lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, Project originalProject, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question. A project key can be updated by any user with the global admin permission.user
- The user trying to update a projectoriginalProject
- The project to update with the values put in arguments (Project
object should not be modified)name
- The name of the new projectkey
- The new project keydescription
- An optional description for the projectlead
- The lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, Project originalProject, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question. A project key can be updated by any user with the global admin permission.user
- The user trying to update a projectoriginalProject
- The project to update with the values put in arguments (Project
object should not be modified)name
- The name of the new projectkey
- The new project keydescription
- An optional description for the projectleadName
- The user key for the lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
The only difference is that the project key will obviously not be validated.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question.user
- The user trying to update a projectname
- The name of the new projectkey
- The project key of the project to update.description
- An optional description for the projectleadName
- The username of the lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.avatarId
- the id of an existing avatar.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId)
validateUpdateProject(ApplicationUser, UpdateProjectRequest)
instead; since v7.2validateCreateProject(ApplicationUser, ProjectCreationData)
method.
The only difference is that the project key will obviously not be validated.
A project can be updated by any user with the global admin permission or project admin permission for the project
in question.
WARNING: In 6.0-6.0.5, this method is available but does not work properly for renamed users (JRA-33843).user
- The user trying to update a projectname
- The name of the new projectkey
- The project key of the project to update.description
- An optional description for the projectlead
- The lead developer for the projecturl
- An optional URL for the projectassigneeType
- The default assignee for issues created in this project. May be either project lead, or
unassigned if unassigned issues are enabled.avatarId
- the id of an existing avatar.ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, ProjectService.UpdateProjectRequest updateProjectRequest)
validateCreateProject(ApplicationUser, ProjectCreationData)
method.
The only difference is that the project key will obviously not be validated.
updateProjectRequest
- includes the changes that will be made to the projectProject updateProject(ProjectService.UpdateProjectValidationResult updateProjectValidationResult)
validateUpdateProject(ApplicationUser, String, String,
String, String, String, Long)
this method performs the actual update on the project.updateProjectValidationResult
- Result from the validation, which also contains all the project's details.IllegalStateException
- if the validation result contains any errors.io.atlassian.fugue.Either<Project,ErrorCollection> updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType)
ProjectTypeUpdatedHandler
s will be notified.
If an exception is thrown by one of the ProjectTypeUpdatedHandler
, the project type update will be rolled back.user
- The user performing the actionproject
- The project which type needs to be updatednewProjectType
- The new project typePermissionException
- If the user does not have permission to perform the operationProjectService.DeleteProjectValidationResult validateDeleteProject(ApplicationUser user, String key)
user
- The user trying to delete a projectkey
- The key of the project to deleteProjectService.DeleteProjectResult deleteProject(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult)
user
- The user trying to delete a projectdeleteProjectValidationResult
- Result from the validation, which also contains all the project's details.ProjectService.DeleteProjectResult deleteProjectAsynchronous(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult)
user
- The user trying to delete a projectdeleteProjectValidationResult
- Result from the validation, which also contains all the project's details.ProjectService.UpdateProjectSchemesValidationResult validateUpdateProjectSchemes(ApplicationUser user, Long permissionSchemeId, Long notificationSchemeId, Long issueSecuritySchemeId)
permissionSchemeId
- The permission scheme that the new project should usenotificationSchemeId
- The notification scheme that the new project should use. Optional.issueSecuritySchemeId
- The issue security scheme that the new project should use. Optional.void updateProjectSchemes(ProjectService.UpdateProjectSchemesValidationResult result, Project project)
result
- Result from the validation, which also contains all the schemes details.project
- The project which will have its schemes updated.IllegalStateException
- if the validation result contains any errors.@Deprecated boolean isValidAllProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData)
validateCreateProject(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.bc.project.ProjectCreationData)
instead.
Validates the given project fields. Any errors will be added to the
JiraServiceContext
.
The project type is mandatory and its value must correspond to one of the project types defined on the JIRA
instance. A validation error will be reported if the passed value is null or if it does not meet the previous criteria.serviceContext
- containing the ErrorCollection that will be populated with any validation errors
that are encountered. It also contains the logged in user so the correct locale is used for the error messages.projectCreationData
- An object encapsulating all the data for the project that will get createdboolean isValidRequiredProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData)
JiraServiceContext
.serviceContext
- containing the ErrorCollection that will be populated with any validation errors that are
encounteredprojectCreationData
- An object encapsulating all the data for the project that will get createdboolean isValidProjectKey(JiraServiceContext serviceContext, String key)
JiraServiceContext
.serviceContext
- containing the ErrorCollection that will be populated with any validation errors that are
encounteredkey
- The key to validate @NonnullString getProjectKeyDescription()
ProjectService.GetProjectResult getProjectById(Long id)
Project
object by id.
This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the id
specified can be found, or if the user making the request does not have the BROWSE project permission for the
project. In both of these cases, the errorCollection in the result object will contain an appropriate error
message.
The current user will be looked up via the JiraAuthenticationContext,
so do not call this method from a background thread.
Use getProjectById(com.atlassian.jira.user.ApplicationUser, Long)
instead.
id
- The id of the project.ProjectService.GetProjectResult getProjectById(ApplicationUser user, Long id)
Project
object by id. This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the id
specified can be found, or if the user making the request does not have the BROWSE project permission for the
project. In both of these cases, the errorCollection in the result object will contain an appropriate error
message.user
- The user retrieving the project.id
- The id of the project.ProjectService.GetProjectResult getProjectByIdForAction(ApplicationUser user, Long id, ProjectAction action)
Project
object by id providing the user can perform the
passed action on the project. This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the
id specified can be found, or if the user making the request cannot perform the passed action on the project.
In both of these cases, the errorCollection in the result object will contain an appropriate error message.user
- The user retrieving the project.id
- The id of the project.action
- the action the user must be able to perform on the project.ProjectService.GetProjectResult getProjectByKey(String key)
Used to retrieve a Project
object by key. This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the
key specified can be found, or if the user making the request does not have the BROWSE project permission for the
project. In both of these cases, the errorCollection in the result object will contain an appropriate error
message.
The current user will be looked up via the JiraAuthenticationContext,
so do not call this method from a background thread.
Use getProjectByKey(com.atlassian.jira.user.ApplicationUser, String)
instead.
key
- The key of the project.ProjectService.GetProjectResult getProjectByKey(ApplicationUser user, String key)
Project
object by key. This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the
key specified can be found, or if the user making the request does not have the BROWSE project permission for the
project. In both of these cases, the errorCollection in the result object will contain an appropriate error
message.user
- The user retrieving the project.key
- The key of the project.int getMaximumNameLength()
ProjectService.GetProjectResult getProjectByKeyForAction(ApplicationUser user, String key, ProjectAction action)
Project
object by key providing the user can perform the
passed action on the project. This method returns a ProjectService.GetProjectResult
. The project will be null if no project for the
key specified can be found, or if the user making the request cannot perform the passed action on the project.
In both of these cases, the errorCollection in the result object will contain an appropriate error message.user
- The user retrieving the project.key
- The key of the project.action
- the action the user must be able to perform on the project.int getMaximumKeyLength()
long getProjectCount()
Project
s, regardless of the permission to see those projects.ServiceOutcome<List<Project>> getAllProjects(ApplicationUser user)
Project
objects. This method returns a
ServiceOutcome
containing a list of projects. The list will be empty, if the user does not have
the BROWSE project permission for any project or no projects are visible when using anonymous access.user
- The user retrieving the list of projects or NULL when using anonymous access.ServiceOutcome<List<Project>> getAllProjectsForAction(ApplicationUser user, ProjectAction action)
Project
objects. This method returns a
ServiceOutcome
containing a list of projects that the user can perform the passed
action on. The list will be empty if no projects match the passed action.user
- The user retrieving the list of projects or NULL when using anonymous access.action
- the action the user must be able to perform on the returned projects.ServiceOutcome<List<Project>> getAllProjectsForAction(ApplicationUser user, ProjectAction action, boolean includeArchived)
getAllProjectsForAction(ApplicationUser, ProjectAction)
instead. Since v7.10.Project
objects. This method returns a
ServiceOutcome
containing a list of projects that the user can perform the passed
action on. The list will be empty if no projects match the passed action.user
- The user retrieving the list of projects or NULL when using anonymous access.action
- the action the user must be able to perform on the returned projects.includeArchived
- return all projects, including the archived onesCopyright © 2002-2019 Atlassian. All Rights Reserved.