public interface

RefRestrictionService

com.atlassian.stash.repository.ref.restriction.RefRestrictionService

Class Overview

A service that manages restrictions to refs. Repository admin permissions are required for all operations unless specified.

Summary

Public Methods
boolean canDelete(Repository repository, Ref branch)
Checks if the current user can delete the specified refs based on both the user's repository permissions (i.e., REPO_WRITE or higher) and branch permissions.
boolean canWrite(Repository repository, Iterable<String> refIds)
Checks if the current user can write to specified refs based on both the user's repository permissions (i.e., REPO_WRITE or higher) and branch permissions.
@Nullable RefRestriction getById(int id)
Get a RefRestriction by its ID.
boolean removeRefRestriction(int id)
Remove a RefRestriction by its ID.
@Nonnull Page<RefRestriction> search(RestrictionSearchRequest request, PageRequest pageRequest)
Search for RefRestrictions based on the RestrictionSearchRequest.
@Nonnull Page<AccessGrant> search(AccessGrantSearchRequest request, PageRequest pageRequest)
Search for AccessGrants based on the AccessGrantSearchRequest.
@Nonnull RefRestriction setRestriction(SetRestrictionRequest request)
Sets a restriction based on the SetRestrictionRequest.

Public Methods

public boolean canDelete (Repository repository, Ref branch)

Checks if the current user can delete the specified refs based on both the user's repository permissions (i.e., REPO_WRITE or higher) and branch permissions. This method does not require any permissions and can be called by any user.

Parameters
repository the Repository that the ref is in
branch the ref to check for delete permission
Returns
  • true if the user can delete the ref, false otherwise

public boolean canWrite (Repository repository, Iterable<String> refIds)

Checks if the current user can write to specified refs based on both the user's repository permissions (i.e., REPO_WRITE or higher) and branch permissions. This method does not require any permissions and can be called by any user.

Parameters
repository the Repository that the ref is in
refIds the ref ids to check for write access
Returns
  • true if the user can write, false otherwise

@Nullable public RefRestriction getById (int id)

Get a RefRestriction by its ID.

Parameters
id the ID associated with the RefRestriction
Returns

public boolean removeRefRestriction (int id)

Remove a RefRestriction by its ID.

Parameters
id the ID associated with the RefRestriction
Returns

@Nonnull public Page<RefRestriction> search (RestrictionSearchRequest request, PageRequest pageRequest)

Search for RefRestrictions based on the RestrictionSearchRequest.

Parameters
request the RestrictionSearchRequest which specifies the RefRestrictions to search for
pageRequest the PageRequest which specifies the page to return
Returns

@Nonnull public Page<AccessGrant> search (AccessGrantSearchRequest request, PageRequest pageRequest)

Search for AccessGrants based on the AccessGrantSearchRequest.

Parameters
request the AccessGrantSearchRequest which specifies the AccessGrants to search for
pageRequest the PageRequest which specifies the page to return
Returns

@Nonnull public RefRestriction setRestriction (SetRestrictionRequest request)

Sets a restriction based on the SetRestrictionRequest. If the same RefRestriction already exists it will be overwritten.

Parameters
request the SetRestrictionRequest which specifies the restriction to be set
Returns