Interface ProjectService
- All Superinterfaces:
ProjectSupplier
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(ProjectCreateRequest request) Creates a newProject
and sets its avatar, if provided.boolean
Deletes the specifiedproject
, if it exists.findAll
(PageRequest pageRequest) Retrieves a page of projects which are visible for the current user.Retrieves thekeys
for all projects the current user can see.getAvatar
(int projectId, int size) Retrieves the current avatar for the specified project at a requested size.getById
(int id) search
(ProjectSearchRequest searchRequest, PageRequest pageRequest) update
(ProjectUpdateRequest request) Update a project's data with new values.void
updateAvatar
(int projectId, AvatarSupplier supplier) Updates the specified project's avatar, replacing it with the one contained in the providedsupplier
.void
updateAvatar
(int projectId, String uri) Updates the specified project's avatar, replacing it with the one contained in the provided data URI.
-
Method Details
-
create
Creates a newProject
and sets its avatar, if provided.Note: Both the project key and name must be unique.
- Parameters:
request
- describes the project to create- Returns:
- the created project
- Throws:
ProjectCreationCanceledException
- if creation is canceled by an event listenerServiceException
- if the specifiedAbstractProjectRequest.getKey()
orAbstractProjectRequest.getName()
is not unique
-
delete
Deletes the specifiedproject
, if it exists.Personal projects
cannot be deleted. Additionally, if the project contains anyrepositories
, they must all be deleted before the project can be deleted.- Parameters:
project
- the project to delete- Returns:
true
if the project was deleted; otherwisefalse
if the project did not exist- Throws:
ProjectDeletionCanceledException
- if deletion is canceled by an event listenerIntegrityException
- if the project ispersonal
, or has repositoriesServiceException
- if the project exists and could not be deleted
-
findAll
Retrieves a page of projects which are visible for the current user.Note:
Personal projects
are never included in the returned page.- Parameters:
pageRequest
- the bounds of the page- Returns:
- a page containing 0 or more
projects
to which the current user has access
-
findAllKeys
Retrieves thekeys
for all projects the current user can see.Note:
Personal projects
keys are never included in the returned list.Warning: This mechanism is not paged. For systems with large numbers of projects, the returned list may be very large. For callers wishing to iterate over all existing projects,
findAll(PageRequest)
is the correct mechanism to use.- Returns:
- an unpaged list of keys for all projects the current user can see
-
getAvatar
Retrieves the current avatar for the specified project at a requested size. Avatars are square, so the size provided here is used as both height and width for the avatar.The requested size will be normalised to fall within a well-defined set sizes. The supported sizes are:
- 256
- 128
- 96
- 64
- 48
- Parameters:
projectId
- theID
of the project to retrieve the avatar forsize
- the desired height and width for the avatar- Returns:
- a supplier which can be used to access the requested avatar
-
getById
- Specified by:
getById
in interfaceProjectSupplier
- Parameters:
id
- theID
of the project to retrieve- Returns:
- the project instance or
null
if no such project exists - Throws:
AuthorisationException
- if the current user does not have permission to access the requested project
-
getByKey
- Specified by:
getByKey
in interfaceProjectSupplier
- Parameters:
key
- thekey
of the project to retrieve- Returns:
- the keyed project, or
null
if the key does not match an existing project - Throws:
AuthorisationException
- if the current user does not have permission to access the requested project
-
getByName
- Specified by:
getByName
in interfaceProjectSupplier
- Parameters:
name
- thename
of the project to retrieve- Returns:
- the named project, or
null
if the name does not match an existing project - Throws:
AuthorisationException
- if the current user does not have permission to access the requested project
-
search
@Nonnull Page<Project> search(@Nonnull ProjectSearchRequest searchRequest, @Nonnull PageRequest pageRequest) -
update
Update a project's data with new values. Projectkeys
andnames
must be unique, so if the provided values match those of anotherProject
an exception will be thrown.Personal projects
cannot be updated. Theirkeys
,names
anddescriptions
are managed by the system.- Parameters:
request
- describes the project to update and the updates to apply- Returns:
- the updated project instance
- Throws:
javax.validation.ConstraintViolationException
- if the updated key or name collide with another projectIntegrityException
- if the project ispersonal
ProjectModificationCanceledException
- if modification is canceled by an event listener
-
updateAvatar
Updates the specified project's avatar, replacing it with the one contained in the providedsupplier
.Previous avatars are not retained. When a project's avatar is updated, the previous avatar is removed. To reuse a previous avatar, it must be provided again.
Personal project
avatars cannot be updated. Their avatars are drawn from theirowning users
. If Gravatar support is enabled, personal project avatars may be updated by changing the user's avatar in Gravatar. Otherwise, they may not be updated at all.- Parameters:
projectId
- the ID of the project to update the avatar forsupplier
- a supplier providing access to the new avatar to use- Throws:
IntegrityException
- if the project ispersonal
-
updateAvatar
Updates the specified project's avatar, replacing it with the one contained in the provided data URI. The data URI is required to contain Base64-encoded image data, and should be in the format:data:(content type, e.g. image/png);base64,(data)
If the data is not Base64-encoded, or if a character set is defined in the URI, it will be rejected.Previous avatars are not retained. When a project's avatar is updated, the previous avatar is removed. To reuse a previous avatar, it must be provided again.
Personal project
avatars cannot be updated. Their avatars are drawn from theirowning users
. If Gravatar support is enabled, personal project avatars may be updated by changing the user's avatar in Gravatar. Otherwise, they may not be updated at all.- Parameters:
projectId
- the ID of the project to update the avatar foruri
- a data URI containing a Base64-encoded avatar image- Throws:
IntegrityException
- if the project ispersonal
-