Interface ProjectSettingsRestrictionService
public interface ProjectSettingsRestrictionService
Service for managing
project settings restrictions
.- Since:
- 8.10
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(ProjectSettingsRestrictionCreateRequest restrictionRequest) Creates a newrestriction
.void
delete
(Project project, SettingsKey settingsKey) Deletes the specifiedrestriction
, if it exists.get
(Project project, SettingsKey settingsKey) boolean
hasRestriction
(Project project, SettingsKey settingsKey) Retrieves a flag indicating whether arestriction
exists, specified by itsprojects
andsettings key
.boolean
hasRestrictions
(Collection<Project> projects, SettingsKey settingsKey) Retrieves a flag indicating whether anyrestrictions
exists for the providedprojects
, matching the providedsettings key
.<T> T
withRestriction
(Project project, SettingsKey settingsKey, ProjectSettingsRestrictionAction action, Supplier<T> operation) A wrapper method for the specifiedoperation
thatupdates
therestriction
for the specifiedproject
andsettingsKey
.
-
Method Details
-
create
@Nonnull ProjectSettingsRestriction create(@Nonnull ProjectSettingsRestrictionCreateRequest restrictionRequest) Creates a newrestriction
.- Parameters:
restrictionRequest
- the request containing the information to store- Returns:
- the created project settings restriction
- Throws:
AuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_ADMIN
permission for the provided projectIntegrityException
- if a project settings restriction matching the request already exists
-
delete
Deletes the specifiedrestriction
, if it exists. If no restriction exists for the given key and project no operation is taken and no error is reported.- Parameters:
project
- the project to check the restriction forsettingsKey
- the settings key to check the restriction for- Throws:
ArgumentValidationException
- if the project is a personal projectAuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_ADMIN
permission for the provided projectUnprocessedProjectSettingsRestrictionException
- if the project setting restriction is unprocessed
-
get
@Nonnull Optional<ProjectSettingsRestriction> get(@Nonnull Project project, @Nonnull SettingsKey settingsKey) - Parameters:
project
- the project to check the restriction forsettingsKey
- the settings key to check the restriction for- Returns:
- an optional containing the
restriction
, orOptional.empty()
if the restriction does not exist - Throws:
AuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_VIEW
permission for the provided project
-
getAll
@Nonnull Set<ProjectSettingsRestriction> getAll(@Nonnull Project project, @Nonnull String namespace, @Nonnull String featureKey) Retrieves allrestrictions
by theirproject
with a matchingnamespace
andfeature key
.This method will return all matching restrictions including restrictions with or without
component keys
.- Parameters:
project
- the project to check the restrictions fornamespace
- the namespace of the settings key to check restrictions forfeatureKey
- the feature key of the settings key to check restrictions for- Returns:
- a set containing all matching restrictions
- Throws:
AuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_VIEW
permission for the provided project
-
hasRestriction
Retrieves a flag indicating whether arestriction
exists, specified by itsprojects
andsettings key
.This method will only return true if a restriction is found for the specified project that matches all of
SettingsKey.getNamespace()
,SettingsKey.getFeatureKey()
andSettingsKey.getComponentKey()
.- Parameters:
project
- the project to check restrictions forsettingsKey
- the settings key to check restrictions for- Returns:
true
if the project has a restriction for the specified settings key, otherwisefalse
- Throws:
AuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_VIEW
permission for the provided project
-
hasRestrictions
Retrieves a flag indicating whether anyrestrictions
exists for the providedprojects
, matching the providedsettings key
.This method will only return true if a restriction is found for the specified project that matches all of
SettingsKey.getNamespace()
,SettingsKey.getFeatureKey()
andSettingsKey.getComponentKey()
.- Parameters:
projects
- the projects to check restrictions forsettingsKey
- the settings key to check restrictions for- Returns:
true
if at least one project has a restriction for the specified settings key, otherwisefalse
- Throws:
AuthorisationException
- if the currently authenticated user does not havePermission.PROJECT_VIEW
permission for the provided projects
-
withRestriction
@Nonnull <T> T withRestriction(@Nonnull Project project, @Nonnull SettingsKey settingsKey, @Nonnull ProjectSettingsRestrictionAction action, @Nonnull Supplier<T> operation) A wrapper method for the specifiedoperation
thatupdates
therestriction
for the specifiedproject
andsettingsKey
.- Type Parameters:
T
- the return type of the supplied operation- Parameters:
project
- the project that the restriction will be applied tosettingsKey
- the settings key that the restriction will be applied toaction
- the restriction update action to performoperation
- the operation that is executed- Returns:
- the result of the supplied
operation
-