Class DefaultProjectService
- All Implemented Interfaces:
ProjectService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA GetProjectResult that indicates the calling user does not have permission to perform an action on a project.protected classA GetProjectResult that indicates a project was not found.Nested classes/interfaces inherited from interface com.atlassian.jira.bc.project.ProjectService
ProjectService.AbstractProjectResult, ProjectService.AbstractProjectValidationResult, ProjectService.CreateProjectValidationResult, ProjectService.DeleteProjectResult, ProjectService.DeleteProjectValidationResult, ProjectService.GetProjectResult, ProjectService.UpdateProjectRequest, ProjectService.UpdateProjectSchemesValidationResult, ProjectService.UpdateProjectValidationResult -
Field Summary
Fields inherited from interface com.atlassian.jira.bc.project.ProjectService
DEFAULT_NAME_LENGTH, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MIN_NAME_LENGTH, PROJECT_CATEGORY_ID, PROJECT_DESCRIPTION, PROJECT_KEY, PROJECT_LEAD, PROJECT_NAME, PROJECT_TYPE, PROJECT_URL -
Constructor Summary
ConstructorsConstructorDescriptionDefaultProjectService(JiraAuthenticationContext jiraAuthenticationContext, ProjectManager projectManager, ApplicationProperties applicationProperties, PermissionManager permissionManager, GlobalPermissionManager globalPermissionManager, PermissionSchemeManager permissionSchemeManager, NotificationSchemeManager notificationSchemeManager, IssueSecuritySchemeManager issueSecuritySchemeManager, SchemeFactory schemeFactory, WorkflowSchemeManager workflowSchemeManager, IssueTypeScreenSchemeManager issueTypeScreenSchemeManager, CustomFieldManager customFieldManager, NodeAssociationStore nodeAssociationStore, VersionManager versionManager, ProjectComponentManager projectComponentManager, SharePermissionDeleteUtils sharePermissionDeleteUtils, AvatarManager avatarManager, I18nHelper.BeanFactory i18nFactory, WorkflowManager workflowManager, UserManager userManager, ProjectEventManager projectEventManager, ProjectKeyStore projectKeyStore, ProjectTypeValidator projectTypeValidator, ProjectCreateNotifier projectCreateNotifier, ProjectTypeUpdatedNotifier projectTypeUpdatedNotifier, com.atlassian.beehive.ClusterLockService clusterLockService, ProjectTemplateManager projectTemplateManager, ProjectSchemeAssociationManager projectSchemeAssociationManager, TaskManager taskManager, IssueManager issueManager, AccessDeniedAuditHandler auditHandler) -
Method Summary
Modifier and TypeMethodDescriptionUsing the validation result fromProjectService.validateCreateProject(ApplicationUser, ProjectCreationData)a new project will be created.deleteProject(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult) Deletes the project provided by the deleteProjectValidationResult.deleteProjectAsynchronous(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult) Deletes the project provided by the deleteProjectValidationResult in a background task and provides a progress URL that may be used to monitor the delete progress.findProjects(String query, boolean allowEmptyQuery, boolean includeArchived) Finds all the projects visible to the currently logged-in user that have the project key or name matching the provided query.Used to retrieve a list ofProjectobjects.getAllProjectsForAction(ApplicationUser user, ProjectAction action) Used to retrieve a list ofProjectobjects.getAllProjectsForAction(ApplicationUser user, ProjectAction action, boolean includeArchived) Used to retrieve a list ofProjectobjects.protected final I18nHelpergetI18nBean(ApplicationUser user) intUsed to retrieve the maximum length allowed for new project keys.intUsed to retrieve the maximum length allowed for new project names.getProjectById(ApplicationUser user, Long id) Used to retrieve aProjectobject by id.getProjectById(Long id) Used to retrieve aProjectobject by id.getProjectByIdForAction(ApplicationUser user, Long id, ProjectAction action) Used to retrieve aProjectobject by id providing the user can perform the passed action on the project.getProjectByKey(ApplicationUser user, String key) Used to retrieve aProjectobject by key.getProjectByKey(String key) Used to retrieve aProjectobject by key.getProjectByKeyForAction(ApplicationUser user, String key, ProjectAction action) Used to retrieve aProjectobject by key providing the user can perform the passed action on the project.longUsed to retrieve the total number ofProjects, regardless of the permission to see those projects.Get the project key description from the properties file.protected JiraServiceContextgetServiceContext(ApplicationUser user, ErrorCollection errorCollection) booleanisValidAllProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData) booleanisValidProjectKey(JiraServiceContext serviceContext, String key) Validates the given project key.booleanisValidRequiredProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData) Validate the fields required for creating a project.protected final ErrorCollectionmakeErrorCollection(ApplicationUser user, String i18nKey, ErrorCollection.Reason reason, String... params) Creates a new ErrorCollection instance for a single error message.Using the validation result fromProjectService.validateUpdateProject(ApplicationUser, String, String, String, String, String, Long)this method performs the actual update on the project.voidUpdates the project schemes for a particular project, given a validation result and project to update.io.atlassian.fugue.Either<Project, ErrorCollection> updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType) Updates the type of project.validateCreateProject(ApplicationUser user, ProjectCreationData projectCreationData) This method needs to be called before creating a project to ensure all parameters are correct.validateCreateProjectBasedOnExistingProject(ApplicationUser user, Long existingProjectId, ProjectCreationData input) Validates if the current user can create a new project with shared schemes based on the existing project provided.validateDeleteProject(ApplicationUser user, String key) Validation to delete a project is quite straightforward.validateUpdateProject(ApplicationUser user, ProjectService.UpdateProjectRequest updateProjectRequest) Validates updating a project's details.validateUpdateProject(ApplicationUser applicationUser, Project originalProject, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId) Validates updating a project's details.validateUpdateProject(ApplicationUser applicationUser, Project originalProject, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId) Validates updating a project's details.validateUpdateProject(ApplicationUser user, String key) Validates that the given user is authorised to update a project.validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType) Validates updating a project's details.validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId) Validates updating a project's details.validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType) Validates updating a project's details.validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId) Validates updating a project's details.validateUpdateProjectSchemes(ApplicationUser user, Long permissionSchemeId, Long notificationSchemeId, Long issueSecuritySchemeId) If the scheme ids are not null or -1 (-1 is often used to reset schemes), then an attempt will be made to retrieve the scheme.
-
Constructor Details
-
Method Details
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the key provided. If no project with the key provided can be found, an appropriate error will be added to the result. Validation performed will be the same as for theProjectService.validateCreateProject(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).- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
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.- Returns:
- A validation result containing any errors and all project details
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the key provided. If no project with the key provided can be found, an appropriate error will be added to the result. Validation performed will be the same as for theProjectService.validateCreateProject(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).- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
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.- Returns:
- A validation result containing any errors and all project details
-
validateDeleteProject
public ProjectService.DeleteProjectValidationResult validateDeleteProject(ApplicationUser user, String key) Description copied from interface:ProjectServiceValidation to delete a project is quite straightforward. The user must have global admin rights and the project about to be deleted needs to exist.- Specified by:
validateDeleteProjectin interfaceProjectService- Parameters:
user- The user trying to delete a projectkey- The key of the project to delete- Returns:
- A validation result containing any errors and all project details
-
deleteProject
public ProjectService.DeleteProjectResult deleteProject(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult) Description copied from interface:ProjectServiceDeletes the project provided by the deleteProjectValidationResult. There's a number of steps involved in deleting a project, which are carried out in the following order:- Delete all the issues in the project
- Remove any custom field associations for the project
- Remove the IssueTypeScreenSchemeAssociation for the project
- Remove any other associations of this project (to permission schemes, notification schemes...)
- Remove any versions in this project
- Remove any components in this project
- Delete all portlets that rely on this project (either directly or via filters)
- Delete all the filters for this project
- Delete the project itself in the database
- Flushing the issue, project and workflow scheme caches
- Specified by:
deleteProjectin interfaceProjectService- Parameters:
user- The user trying to delete a projectdeleteProjectValidationResult- Result from the validation, which also contains all the project's details.- Returns:
- A result containing any errors. Users of this method should check the result.
-
deleteProjectAsynchronous
public ProjectService.DeleteProjectResult deleteProjectAsynchronous(ApplicationUser user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult) Description copied from interface:ProjectServiceDeletes the project provided by the deleteProjectValidationResult in a background task and provides a progress URL that may be used to monitor the delete progress. There's a number of steps involved in deleting a project, which are carried out in the following order:- Delete all the issues in the project
- Remove any custom field associations for the project
- Remove the IssueTypeScreenSchemeAssociation for the project
- Remove any other associations of this project (to permission schemes, notification schemes...)
- Remove any versions in this project
- Remove any components in this project
- Delete all portlets that rely on this project (either directly or via filters)
- Delete all the filters for this project
- Delete the project itself in the database
- Flushing the issue, project and workflow scheme caches
- Specified by:
deleteProjectAsynchronousin interfaceProjectService- Parameters:
user- The user trying to delete a projectdeleteProjectValidationResult- Result from the validation, which also contains all the project's details.- Returns:
- URL of the progress page for monitoring this event.
-
getProjectById
Description copied from interface:ProjectServiceUsed to retrieve aProjectobject 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
ProjectService.getProjectById(com.atlassian.jira.user.ApplicationUser, Long)instead.- Specified by:
getProjectByIdin interfaceProjectService- Parameters:
id- The id of the project.- Returns:
- A ProjectResult object
-
getProjectByKey
Description copied from interface:ProjectServiceUsed to retrieve a
Projectobject by key. This method returns aProjectService.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
ProjectService.getProjectByKey(com.atlassian.jira.user.ApplicationUser, String)instead.- Specified by:
getProjectByKeyin interfaceProjectService- Parameters:
key- The key of the project.- Returns:
- A GetProjectResult object
-
validateCreateProject
@Nonnull public ProjectService.CreateProjectValidationResult validateCreateProject(ApplicationUser user, @Nonnull ProjectCreationData projectCreationData) Description copied from interface:ProjectServiceThis method needs to be called before creating a project to ensure all parameters are correct. There are a number of required parameters, such as a project name, key and lead. The validation will also check if a project with the name or key provided already exists and throw an appropriate error. The project key will be validated that it matches the allowed key pattern, and it is not a reserved word. A validation error will also be added if no user exists for the lead username provided. Optional validation will be done for the url, assigneetype and avatarId parameters. The url needs to be a valid URL and the assigneeType needs to be eitherAssigneeTypes.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 viaProjectCreationData.getProjectTypeKey()or indirectly viaProjectCreationData.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 receivedProjectCreationData, 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 aProjectService.CreateProjectValidationResultwhich contains an ErrorCollection with any potential errors and all the project's details.- Specified by:
validateCreateProjectin interfaceProjectService- Parameters:
user- The user performing the actionprojectCreationData- An object encapsulating all the data for the project that will get created- Returns:
- A validation result containing any errors and all project details
-
validateCreateProjectBasedOnExistingProject
@Nonnull public ProjectService.CreateProjectValidationResult validateCreateProjectBasedOnExistingProject(ApplicationUser user, @Nonnull Long existingProjectId, @Nonnull ProjectCreationData input) Description copied from interface:ProjectServiceValidates if the current user can create a new project with shared schemes based on the existing project provided. This method validates that the passed project exists and that the current user hasProjectAction.EDIT_PROJECT_CONFIGpermissions for it. Beyond these checks, validation rules will be the same asProjectService.validateCreateProject(ApplicationUser, ProjectCreationData).- Specified by:
validateCreateProjectBasedOnExistingProjectin interfaceProjectService- Parameters:
user- The user performing the actionexistingProjectId- An existing project id to use as the base for the new project being createdinput- An object encapsulating all the data for the project that will get created- Returns:
- A validation result containing any errors and all project details
-
getServiceContext
protected JiraServiceContext getServiceContext(ApplicationUser user, ErrorCollection errorCollection) -
createProject
Description copied from interface:ProjectServiceUsing the validation result fromProjectService.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 a new project will be associated with the same schemes as the existing project:- Permission Scheme
- Notification Scheme
- Issue Security Scheme
- Workflow Scheme
- Issue Type Scheme
- Issue Type Screen Scheme
- Specified by:
createProjectin interfaceProjectService- Parameters:
result- Result from the validation, which also contains all the project's details.- Returns:
- The new project
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the key provided. If no project with the key provided can be found, an appropriate error will be added to the result. Validation performed will be the same as for theProjectService.validateCreateProject(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.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
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.- Returns:
- A validation result containing any errors and all project details
-
validateUpdateProject
Description copied from interface:ProjectServiceValidates that the given user is authorised to update a project. A project can be updated by any user with the global admin permission or project admin permission for the project in question.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
user- The user trying to update a projectkey- The project key of the project to update.- Returns:
- a ServiceResult, which will contain errors if the user is not authorised to update the project
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser applicationUser, Project originalProject, String name, String key, String description, ApplicationUser lead, String url, Long assigneeType, Long avatarId) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the project object. You may change the project key. Validation performed will be the same as for theProjectService.validateCreateProject(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.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
applicationUser- The user trying to update a projectoriginalProject- The project to update with the values put in arguments (Projectobject 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.- Returns:
- A validation result containing any errors and all project details
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser applicationUser, Project originalProject, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the project object. You may change the project key. Validation performed will be the same as for theProjectService.validateCreateProject(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.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
applicationUser- The user trying to update a projectoriginalProject- The project to update with the values put in arguments (Projectobject 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. It may be either project lead, or unassigned if unassigned issues are enabled.- Returns:
- A validation result containing any errors and all project details
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, String name, String key, String description, String leadName, String url, Long assigneeType, Long avatarId) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the key provided. If no project with the key provided can be found, an appropriate error will be added to the result. Validation performed will be the same as for theProjectService.validateCreateProject(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.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
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. It may be either project lead, or unassigned if unassigned issues are enabled.avatarId- the id of an existing avatar.- Returns:
- A validation result containing any errors and all project details
-
validateUpdateProject
public ProjectService.UpdateProjectValidationResult validateUpdateProject(ApplicationUser user, ProjectService.UpdateProjectRequest updateProjectRequest) Description copied from interface:ProjectServiceValidates updating a project's details. The project is looked up by the key provided. If no project with the key provided can be found, an appropriate error will be added to the result. Validation performed will be the same as for theProjectService.validateCreateProject(ApplicationUser, ProjectCreationData)method. The only difference is that the project key will obviously not be validated.- Specified by:
validateUpdateProjectin interfaceProjectService- Parameters:
updateProjectRequest- includes the changes that will be made to the project- Returns:
- A validation result containing any errors and all project details
-
updateProject
Description copied from interface:ProjectServiceUsing the validation result fromProjectService.validateUpdateProject(ApplicationUser, String, String, String, String, String, Long)this method performs the actual update on the project.- Specified by:
updateProjectin interfaceProjectService- Parameters:
result- Result from the validation, which also contains all the project's details.- Returns:
- The updated project
-
validateUpdateProjectSchemes
public ProjectService.UpdateProjectSchemesValidationResult validateUpdateProjectSchemes(ApplicationUser user, Long permissionSchemeId, Long notificationSchemeId, Long issueSecuritySchemeId) Description copied from interface:ProjectServiceIf the scheme ids are not null or -1 (-1 is often used to reset schemes), then an attempt will be made to retrieve the scheme. If this attempt fails an error will be added. IssueSecuritySchemes will only be validated in enterprise edition.- Specified by:
validateUpdateProjectSchemesin interfaceProjectService- Parameters:
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.- Returns:
- A validation result containing any errors and all scheme ids
-
updateProjectSchemes
public void updateProjectSchemes(ProjectService.UpdateProjectSchemesValidationResult result, Project project) Description copied from interface:ProjectServiceUpdates the project schemes for a particular project, given a validation result and project to update.- Specified by:
updateProjectSchemesin interfaceProjectService- Parameters:
result- Result from the validation, which also contains all the schemes details.project- The project which will have its schemes updated.
-
isValidAllProjectData
public boolean isValidAllProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData) Description copied from interface:ProjectServiceUseProjectService.validateCreateProject(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.bc.project.ProjectCreationData)instead. Validates the given project fields. Any errors will be added to theJiraServiceContext. 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.- Specified by:
isValidAllProjectDatain interfaceProjectService- Parameters:
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 created- Returns:
- true if project data is valid, false otherwise
-
isValidRequiredProjectData
public boolean isValidRequiredProjectData(JiraServiceContext serviceContext, ProjectCreationData projectCreationData) Description copied from interface:ProjectServiceValidate the fields required for creating a project. Any errors will be added to theJiraServiceContext.- Specified by:
isValidRequiredProjectDatain interfaceProjectService- Parameters:
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 created- Returns:
- true if project data is valid, false otherwise
-
isValidProjectKey
Description copied from interface:ProjectServiceValidates the given project key. Any errors will be added to theJiraServiceContext.- Specified by:
isValidProjectKeyin interfaceProjectService- Parameters:
serviceContext- containing the ErrorCollection that will be populated with any validation errors that are encounteredkey- The key to validate @Nonnull- Returns:
- true if project key is valid, false otherwise
-
getProjectKeyDescription
Description copied from interface:ProjectServiceGet the project key description from the properties file. If the user has specified a custom regex that project keys must conform to and a description for that regex, this method should return the description. If the user has not specified a custom regex, this method will return the default project key description: "Usually the key is just 3 letters - i.e. if your project name is Foo Bar Raz, a key of FBR would make sense.
The key must contain only uppercase alphabetic characters, and be at least 2 characters in length.
It is recommended to use only ASCII characters, as other characters may not work."- Specified by:
getProjectKeyDescriptionin interfaceProjectService- Returns:
- a String description of the project key format
-
getProjectByIdForAction
public ProjectService.GetProjectResult getProjectByIdForAction(ApplicationUser user, Long id, ProjectAction action) Description copied from interface:ProjectServiceUsed to retrieve aProjectobject by id providing the user can perform the passed action on the project. This method returns aProjectService.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.- Specified by:
getProjectByIdForActionin interfaceProjectService- Parameters:
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.- Returns:
- A ProjectResult object
-
getProjectById
Description copied from interface:ProjectServiceUsed to retrieve aProjectobject by id. This method returns aProjectService.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.- Specified by:
getProjectByIdin interfaceProjectService- Parameters:
user- The user retrieving the project.id- The id of the project.- Returns:
- A ProjectResult object
-
getProjectByKeyForAction
public ProjectService.GetProjectResult getProjectByKeyForAction(ApplicationUser user, String key, ProjectAction action) Description copied from interface:ProjectServiceUsed to retrieve aProjectobject by key providing the user can perform the passed action on the project. This method returns aProjectService.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.- Specified by:
getProjectByKeyForActionin interfaceProjectService- Parameters:
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.- Returns:
- A GetProjectResult object
-
getProjectByKey
Description copied from interface:ProjectServiceUsed to retrieve aProjectobject by key. This method returns aProjectService.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.- Specified by:
getProjectByKeyin interfaceProjectService- Parameters:
user- The user retrieving the project.key- The key of the project.- Returns:
- A GetProjectResult object
-
getMaximumNameLength
public int getMaximumNameLength()Description copied from interface:ProjectServiceUsed to retrieve the maximum length allowed for new project names.- Specified by:
getMaximumNameLengthin interfaceProjectService- Returns:
- The configured maximum project length
-
getMaximumKeyLength
public int getMaximumKeyLength()Description copied from interface:ProjectServiceUsed to retrieve the maximum length allowed for new project keys.- Specified by:
getMaximumKeyLengthin interfaceProjectService- Returns:
- The configured maximum project length
-
getProjectCount
public long getProjectCount()Description copied from interface:ProjectServiceUsed to retrieve the total number ofProjects, regardless of the permission to see those projects.- Specified by:
getProjectCountin interfaceProjectService- Returns:
- A long value representing the total number of projects.
-
getAllProjects
Description copied from interface:ProjectServiceUsed to retrieve a list ofProjectobjects. This method returns aServiceOutcomecontaining 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.- Specified by:
getAllProjectsin interfaceProjectService- Parameters:
user- The user retrieving the list of projects or NULL when using anonymous access.- Returns:
- A ServiceOutcome containing a list of projects
-
getAllProjectsForAction
public ServiceOutcome<List<Project>> getAllProjectsForAction(ApplicationUser user, ProjectAction action) Description copied from interface:ProjectServiceUsed to retrieve a list ofProjectobjects. This method returns aServiceOutcomecontaining 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.- Specified by:
getAllProjectsForActionin interfaceProjectService- Parameters:
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.- Returns:
- A ServiceOutcome containing a list of projects the user can perform the passed action on.
-
getAllProjectsForAction
public ServiceOutcome<List<Project>> getAllProjectsForAction(ApplicationUser user, ProjectAction action, boolean includeArchived) Description copied from interface:ProjectServiceUsed to retrieve a list ofProjectobjects. This method returns aServiceOutcomecontaining 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.- Specified by:
getAllProjectsForActionin interfaceProjectService- Parameters:
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- If set to true, return all projects including archived ones, otherwise return only active projects.- Returns:
- A ServiceOutcome containing a list of projects the user can perform the passed action on.
-
findProjects
public ServiceOutcome<List<Project>> findProjects(@Nonnull String query, boolean allowEmptyQuery, boolean includeArchived) Finds all the projects visible to the currently logged-in user that have the project key or name matching the provided query. By default, it find projects forProjectAction.VIEW_ISSUESaction.- Specified by:
findProjectsin interfaceProjectService- Parameters:
query- a user provided stringallowEmptyQuery- if true, and the query is empty, the method will return all results, otherwise it will return an empty list.includeArchived- if true, the method will return archived projects as well.- Returns:
- a list of
Projects for the query
-
updateProjectType
public io.atlassian.fugue.Either<Project,ErrorCollection> updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType) Description copied from interface:ProjectServiceUpdates the type of project. If the update completes successfully, all the registeredProjectTypeUpdatedHandlers will be notified. If an exception is thrown by one of theProjectTypeUpdatedHandler, the project type update will be rolled back.- Specified by:
updateProjectTypein interfaceProjectService- Parameters:
user- The user performing the actionproject- The project which type needs to be updatednewProjectType- The new project type- Returns:
- Either the updated project if everything went well or an error collection indicating the reasons of the failure
-
getI18nBean
- Since:
- v6.1
-
makeErrorCollection
protected final ErrorCollection makeErrorCollection(ApplicationUser user, String i18nKey, ErrorCollection.Reason reason, String... params) Creates a new ErrorCollection instance for a single error message. If the reason "forbidden" and the user is null, this method adds an additional error message along the lines of "You are not logged in, please log in".- Parameters:
user- the ApplicationUser for whom the message will be i18n'edi18nKey- a String containing an i18n keyreason- a Reason codeparams- a String array containing the i18n params @return a new ErrorCollection- Returns:
- a new ErrorCollection
- Since:
- v6.1
-