Class PermissionRequest

java.lang.Object
com.atlassian.bitbucket.permission.PermissionRequest

public class PermissionRequest extends Object
Represents a permission request, which can be used to request users with a specific permission, or verify that users have a specific permission.

Note that this class does not validate the relationship between the permission and the resource that it holds. The APIs accepting instances of permission requests are responsible for verifying whether given permission request is valid.

  • Constructor Details

  • Method Details

    • getPermission

      @Nonnull public Permission getPermission()
      Returns:
      permission to satisfy the request, which can be either a global permission, or a resource permission to the specified resource
    • getResource

      @Nullable public Object getResource()
      Resource to which the permission should apply. This could be a domain object (e.g. project or repository), as well as an ID.
      Returns:
      resource to which the permission should apply, or null if this request does not concern any particular resource (which should be the case for global permissions)
    • getResourceAs

      @Nullable public <T> T getResourceAs(@Nonnull Class<T> resourceType)
      Resource to which the permission should apply, as a client-specified instance of resourceType.
      Type Parameters:
      T - resource type
      Parameters:
      resourceType - the type of the resource to cast to
      Returns:
      resource to which the permission should apply, or null if this request does not concern any particular resource (which should be the case for global permissions)
      Throws:
      ClassCastException - if the resource is not an instance of the expected resourceType
    • getUser

      @Nullable public ApplicationUser getUser()
      Returns:
      the user that should have the permission, or null if this request does not concern any particular user