Interface ProjectSettingsRestrictionService
public interface ProjectSettingsRestrictionService
Service for managing
project settings restrictions.- Since:
- 8.10
-
Method Summary
Modifier and TypeMethodDescriptioncreate(ProjectSettingsRestrictionCreateRequest restrictionRequest) Creates a newrestriction.voiddelete(Project project, SettingsKey settingsKey) Deletes the specifiedrestriction, if it exists.get(Project project, SettingsKey settingsKey) booleanhasRestriction(Project project, SettingsKey settingsKey) Retrieves a flag indicating whether arestrictionexists, specified by itsprojectsandsettings key.booleanhasRestrictions(Collection<Project> projects, SettingsKey settingsKey) Retrieves a flag indicating whether anyrestrictionsexists for the providedprojects, matching the providedsettings key.<T> TwithRestriction(Project project, SettingsKey settingsKey, ProjectSettingsRestrictionAction action, Supplier<T> operation) A wrapper method for the specifiedoperationthatupdatestherestrictionfor the specifiedprojectandsettingsKey.
-
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_ADMINpermission 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_ADMINpermission 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_VIEWpermission for the provided project
-
getAll
@Nonnull Set<ProjectSettingsRestriction> getAll(@Nonnull Project project, @Nonnull String namespace, @Nonnull String featureKey) Retrieves allrestrictionsby theirprojectwith a matchingnamespaceandfeature 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_VIEWpermission for the provided project
-
hasRestriction
Retrieves a flag indicating whether arestrictionexists, specified by itsprojectsandsettings 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:
trueif the project has a restriction for the specified settings key, otherwisefalse- Throws:
AuthorisationException- if the currently authenticated user does not havePermission.PROJECT_VIEWpermission for the provided project
-
hasRestrictions
Retrieves a flag indicating whether anyrestrictionsexists 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:
trueif at least one project has a restriction for the specified settings key, otherwisefalse- Throws:
AuthorisationException- if the currently authenticated user does not havePermission.PROJECT_VIEWpermission 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 specifiedoperationthatupdatestherestrictionfor the specifiedprojectandsettingsKey.- 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
-