public interface

ProjectSupplier

com.atlassian.bitbucket.project.ProjectSupplier
Known Indirect Subclasses

Class Overview

Allows retrieving projects by their ID or key.

This is a simplification of the ProjectService, intended to be used in cases where a component needs to be able to look up projects but doesn't need the full service functionality. Using this interface instead makes such components easier to test. Plugin developers: Plugins cannot autowire their components when importing both ProjectSupplier and ProjectService. In general, if a plugin needs ProjectService methods, it should only use the ProjectService. This interface should be used when a plugin only needs to retrieve projects.

Summary

Public Methods
@Nullable Project getById(int id)
Retrieve a Project by its ID.
@Nullable Project getByKey(String namespace, String key)
Retrieves a Project by its namespace and key.
@Nullable Project getByKey(String key)
Retrieves a Project by its key.
@Nullable Project getByName(String namespace, String name)
Retrieves a Project by its namespace and name.
@Nullable Project getByName(String name)
Retrieves a Project by its name.

Public Methods

@Nullable public Project getById (int id)

Retrieve a Project by its ID.

Parameters
id the ID 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

@Nullable public Project getByKey (String namespace, String key)

Retrieves a Project by its namespace and key.

Parameters
namespace the namespace of the project to retrieve
key the key 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
ProjectMovedException when the project key and/or namespace has been updated and the provided parameters identify the project by it's old value(s).

@Nullable public Project getByKey (String key)

Retrieves a Project by its key.

Parameters
key the key 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
ProjectMovedException when the project key has been updated and the provided key parameter is the old value

@Nullable public Project getByName (String namespace, String name)

Retrieves a Project by its namespace and name.

Parameters
namespace the namespace of the project to retrieve
name the name of the project to retrieve
Returns
  • the named 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

@Nullable public Project getByName (String name)

Retrieves a Project by its name.

Parameters
name the name 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