com.atlassian.jira.bc.project
Interface ProjectService

All Known Implementing Classes:
DefaultProjectService

public interface ProjectService


Nested Class Summary
static class ProjectService.AbstractProjectResult
           
static class ProjectService.AbstractProjectValidationResult
           
static class ProjectService.CreateProjectResult
           
static class ProjectService.CreateProjectValidationResult
           
static class ProjectService.DeleteProjectResult
           
static class ProjectService.DeleteProjectValidationResult
           
static class ProjectService.GetProjectResult
           
static class ProjectService.UpdateProjectSchemesValidationResult
           
static class ProjectService.UpdateProjectValidationResult
           
 
Field Summary
static java.lang.String PROJECT_DESCRIPTION
          The default name of HTML fields containing a Project's description.
static java.lang.String PROJECT_KEY
          The default name of HTML fields containing a Project's key.
static java.lang.String PROJECT_LEAD
          The default name of HTML fields containing a Project's lead.
static java.lang.String PROJECT_NAME
          The default name of HTML fields containing a Project's name.
static java.lang.String PROJECT_URL
          The default name of HTML fields containing a Project's URL.
 
Method Summary
 Project createProject(ProjectService.CreateProjectValidationResult createProjectValidationResult)
          Using the validation result from validateCreateProject(com.opensymphony.user.User, String, String, String, String, String, Long) a new project will be created.
 ProjectService.DeleteProjectResult deleteProject(com.opensymphony.user.User user, ProjectService.DeleteProjectValidationResult deleteProjectValidationResult)
          Deletes the project provided by the deleteProjectValidationResult.
 ProjectService.GetProjectResult getProjectById(com.opensymphony.user.User user, java.lang.Long id)
          Used to retrieve a Project object by id.
 ProjectService.GetProjectResult getProjectByKey(com.opensymphony.user.User user, java.lang.String key)
          Used to retrieve a Project object by key.
 java.lang.String getProjectKeyDescription()
          Get the project key description from the properties file.
 boolean isValidAllProjectData(JiraServiceContext serviceContext, java.lang.String name, java.lang.String key, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType)
          Will validate all project fields setting the appropriate errors in the JiraServiceContext if any errors occur.
 boolean isValidAllProjectData(JiraServiceContext serviceContext, java.lang.String name, java.lang.String key, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType, java.lang.Long avatarId)
          Will validate all project fields setting the appropriate errors in the JiraServiceContext if any errors occur.
 boolean isValidRequiredProjectData(JiraServiceContext serviceContext, java.lang.String name, java.lang.String key, java.lang.String lead)
          Will validate the fields required for creating a project and setting the appropriate validation errors in the JiraServiceContext if any errors occur.
 Project updateProject(ProjectService.UpdateProjectValidationResult updateProjectValidationResult)
          Using the validation result from validateUpdateProject(com.opensymphony.user.User, String, String, String, String, String, Long) this method performs the actual update on the project.
 void updateProjectSchemes(ProjectService.UpdateProjectSchemesValidationResult result, Project project)
          Updates the project schemes for a particular project, given a validation result and project to update.
 ProjectService.CreateProjectValidationResult validateCreateProject(com.opensymphony.user.User user, java.lang.String name, java.lang.String key, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType)
          This method needs to be called before creating a project to ensure all parameters are correct.
 ProjectService.CreateProjectValidationResult validateCreateProject(com.opensymphony.user.User user, java.lang.String name, java.lang.String key, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType, java.lang.Long avatarId)
          This method needs to be called before creating a project to ensure all parameters are correct.
 ProjectService.DeleteProjectValidationResult validateDeleteProject(com.opensymphony.user.User user, java.lang.String key)
          Validation to delete a project is quite straightforward.
 ProjectService.UpdateProjectValidationResult validateUpdateProject(com.opensymphony.user.User user, java.lang.String name, java.lang.String key, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType)
          Validates updating a project's details.
 ProjectService.UpdateProjectValidationResult validateUpdateProject(com.opensymphony.user.User user, java.lang.String name, java.lang.String key, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType, java.lang.Long avatarId)
          Validates updating a project's details.
 ProjectService.UpdateProjectSchemesValidationResult validateUpdateProjectSchemes(com.opensymphony.user.User user, java.lang.Long permissionSchemeId, java.lang.Long notificationSchemeId, java.lang.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.
 

Field Detail

PROJECT_NAME

static final java.lang.String PROJECT_NAME
The default name of HTML fields containing a Project's name. Validation methods on this service (isValidAllProjectData) will return an ErrorCollection with error messages keyed to this field name.

See Also:
Constant Field Values

PROJECT_KEY

static final java.lang.String PROJECT_KEY
The default name of HTML fields containing a Project's key. Validation methods on this service (isValidAllProjectData) will return an ErrorCollection with error messages keyed to this field name.

See Also:
Constant Field Values

PROJECT_LEAD

static final java.lang.String PROJECT_LEAD
The default name of HTML fields containing a Project's lead. Validation methods on this service (isValidAllProjectData) will return an ErrorCollection with error messages keyed to this field name.

See Also:
Constant Field Values

PROJECT_URL

static final java.lang.String PROJECT_URL
The default name of HTML fields containing a Project's URL. Validation methods on this service (isValidAllProjectData) will return an ErrorCollection with error messages keyed to this field name.

See Also:
Constant Field Values

PROJECT_DESCRIPTION

static final java.lang.String PROJECT_DESCRIPTION
The default name of HTML fields containing a Project's description. Validation methods on this service (isValidAllProjectData) will return an ErrorCollection with error messages keyed to this field name.

See Also:
Constant Field Values
Method Detail

validateCreateProject

ProjectService.CreateProjectValidationResult validateCreateProject(com.opensymphony.user.User user,
                                                                   java.lang.String name,
                                                                   java.lang.String key,
                                                                   java.lang.String description,
                                                                   java.lang.String lead,
                                                                   java.lang.String url,
                                                                   java.lang.Long assigneeType)
This 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 also be validated ( see com.atlassian.jira.util.JiraKeyUtils#validProjectKey(String) and {@link com.atlassian.jira.util.JiraKeyUtils#isReservedKeyword(String)}). A validation error will also be added if no user exists for the lead username provided.

The default avatar will be used for the created project.

Optional validation will be done for the url and assigneetype parameters. The url needs to be a valid URL, and the assigneeType needs to be either {@link com.atlassian.jira.project.AssigneeTypes#PROJECT_LEAD} or {@link com.atlassian.jira.project.AssigneeTypes#UNASSIGNED}. UNASSIGNED will also only be valid, if unassigned issues are enabled in the General Configuration.

The method will return a {@link com.atlassian.jira.bc.project.ProjectService.CreateProjectValidationResult} which contains an ErrorCollection with any potential errors and all the project's details.

Parameters:
user - The user trying to create a project
name - The name of the new project
key - The project key of the new project
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the new project
assigneeType - 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

validateCreateProject

ProjectService.CreateProjectValidationResult validateCreateProject(com.opensymphony.user.User user,
                                                                   java.lang.String name,
                                                                   java.lang.String key,
                                                                   java.lang.String description,
                                                                   java.lang.String lead,
                                                                   java.lang.String url,
                                                                   java.lang.Long assigneeType,
                                                                   java.lang.Long avatarId)
This 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 also be validated ( see JiraKeyUtils.validProjectKey(String) and JiraKeyUtils.isReservedKeyword(String)). 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 either AssigneeTypes.PROJECT_LEAD or AssigneeTypes.UNASSIGNED. UNASSIGNED will also only be valid, if unassigned issues are enabled in the General Configuration.

The method will return a ProjectService.CreateProjectValidationResult which contains an ErrorCollection with any potential errors and all the project's details.

Parameters:
user - The user trying to create a project
name - The name of the new project
key - The project key of the new project
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the new project
assigneeType - 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 avatar.
Returns:
A validation result containing any errors and all project details

createProject

Project createProject(ProjectService.CreateProjectValidationResult createProjectValidationResult)
Using the validation result from validateCreateProject(com.opensymphony.user.User, String, String, String, String, String, Long) 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.

Parameters:
createProjectValidationResult - Result from the validation, which also contains all the project's details.
Returns:
The new project
Throws:
java.lang.IllegalStateException - if the validation result contains any errors.

validateUpdateProject

ProjectService.UpdateProjectValidationResult validateUpdateProject(com.opensymphony.user.User user,
                                                                   java.lang.String name,
                                                                   java.lang.String key,
                                                                   java.lang.String description,
                                                                   java.lang.String lead,
                                                                   java.lang.String url,
                                                                   java.lang.Long assigneeType)
Validates 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 the validateCreateProject(com.opensymphony.user.User, String, String, String, String, String, Long) 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.

Parameters:
user - The user trying to update a project
name - The name of the new project
key - The project key of the project to update.
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the project
assigneeType - 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

ProjectService.UpdateProjectValidationResult validateUpdateProject(com.opensymphony.user.User user,
                                                                   java.lang.String name,
                                                                   java.lang.String key,
                                                                   java.lang.String description,
                                                                   java.lang.String lead,
                                                                   java.lang.String url,
                                                                   java.lang.Long assigneeType,
                                                                   java.lang.Long avatarId)
Validates 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 the validateCreateProject(com.opensymphony.user.User, String, String, String, String, String, Long) 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.

Parameters:
user - The user trying to update a project
name - The name of the new project
key - The project key of the project to update.
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the project
assigneeType - 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

updateProject

Project updateProject(ProjectService.UpdateProjectValidationResult updateProjectValidationResult)
Using the validation result from validateUpdateProject(com.opensymphony.user.User, String, String, String, String, String, Long) this method performs the actual update on the project.

Parameters:
updateProjectValidationResult - Result from the validation, which also contains all the project's details.
Returns:
The updated project
Throws:
java.lang.IllegalStateException - if the validation result contains any errors.

validateDeleteProject

ProjectService.DeleteProjectValidationResult validateDeleteProject(com.opensymphony.user.User user,
                                                                   java.lang.String key)
Validation to delete a project is quite straightforward. The user must have global admin rights and the project about to be deleted needs to exist.

Parameters:
user - The user trying to delete a project
key - The key of the project to delete
Returns:
A validation result containing any errors and all project details

deleteProject

ProjectService.DeleteProjectResult deleteProject(com.opensymphony.user.User user,
                                                 ProjectService.DeleteProjectValidationResult deleteProjectValidationResult)
Deletes 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:

Parameters:
user - The user trying to delete a project
deleteProjectValidationResult - 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.

validateUpdateProjectSchemes

ProjectService.UpdateProjectSchemesValidationResult validateUpdateProjectSchemes(com.opensymphony.user.User user,
                                                                                 java.lang.Long permissionSchemeId,
                                                                                 java.lang.Long notificationSchemeId,
                                                                                 java.lang.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. If this attempt fails an error will be added. IssueSecuritySchemes will only be validated in enterprise edition.

Parameters:
permissionSchemeId - The permission scheme that the new project should use
notificationSchemeId - 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

void updateProjectSchemes(ProjectService.UpdateProjectSchemesValidationResult result,
                          Project project)
Updates the project schemes for a particular project, given a validation result and project to update.

Parameters:
result - Result from the validation, which also contains all the schemes details.
project - The project which will have its schemes updated.
Throws:
java.lang.IllegalStateException - if the validation result contains any errors.

isValidAllProjectData

boolean isValidAllProjectData(JiraServiceContext serviceContext,
                              java.lang.String name,
                              java.lang.String key,
                              java.lang.String lead,
                              java.lang.String url,
                              java.lang.Long assigneeType)
Will validate all project fields setting the appropriate errors in the JiraServiceContext if any errors occur.

Parameters:
serviceContext - containing the errorCollection that will be populated with any validation errors that are encountered
name - the name of the project @NotNull
key - the key of the project @NotNull
lead - the project lead @NotNull
url - the project URL (optional)
assigneeType - the default assignee type (optional - only appears on some forms)
Returns:
true if project data is valid, false otherwise

isValidAllProjectData

boolean isValidAllProjectData(JiraServiceContext serviceContext,
                              java.lang.String name,
                              java.lang.String key,
                              java.lang.String lead,
                              java.lang.String url,
                              java.lang.Long assigneeType,
                              java.lang.Long avatarId)
Will validate all project fields setting the appropriate errors in the JiraServiceContext if any errors occur.

Parameters:
serviceContext - containing the errorCollection that will be populated with any validation errors that are encountered
name - the name of the project @NotNull
key - the key of the project @NotNull
lead - the project lead @NotNull
url - the project URL (optional)
assigneeType - the default assignee type (optional - only appears on some forms)
avatarId - the id of the avatar (null indicates default avatar)
Returns:
true if project data is valid, false otherwise

isValidRequiredProjectData

boolean isValidRequiredProjectData(JiraServiceContext serviceContext,
                                   java.lang.String name,
                                   java.lang.String key,
                                   java.lang.String lead)
Will validate the fields required for creating a project and setting the appropriate validation errors in the JiraServiceContext if any errors occur.

Parameters:
serviceContext - containing the errorCollection that will be populated with any validation errors that are encountered
name - the name of the project @NotNull
key - the key of the project @NotNull
lead - the project lead @NotNull
Returns:
true if project data is valid, false otherwise

getProjectKeyDescription

java.lang.String getProjectKeyDescription()
Get 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."

Returns:
a String description of the project key format

getProjectById

ProjectService.GetProjectResult getProjectById(com.opensymphony.user.User user,
                                               java.lang.Long id)
Used to retrieve a 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.

Parameters:
user - The user retrieving the project.
id - The id of the project.
Returns:
A ProjectResult object

getProjectByKey

ProjectService.GetProjectResult getProjectByKey(com.opensymphony.user.User user,
                                                java.lang.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.

Parameters:
user - The user retrieving the project.
key - The key of the project.
Returns:
A ProjectResult object


Copyright © 2002-2010 Atlassian. All Rights Reserved.