public class

RestPermissionUtils

extends Object
java.lang.Object
   ↳ com.atlassian.bitbucket.rest.util.RestPermissionUtils

Class Overview

Utilities for parsing permissions from REST requests.

Summary

Public Methods
@Nullable static Permission parsePermission(I18nService i18nService, String permission, Class<?> resourceType)
A variant of parsePermission(I18nService, String, Class, Permission, String) that assumes the defaultPermission and context to be null.
@Nullable static Permission parsePermission(I18nService i18nService, String permission, Class<?> resourceType, Permission defaultPermission, String context)
Parse permission coming from a REST request parameter into a Stash Permission, optionally accepting only permissions of given type and providing a default permission should the one coming from the request be not specified.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

@Nullable public static Permission parsePermission (I18nService i18nService, String permission, Class<?> resourceType)

A variant of parsePermission(I18nService, String, Class, Permission, String) that assumes the defaultPermission and context to be null.

Parameters
i18nService to produce i18n-ed error messages
permission string permission from the request to parse, may be null
resourceType resource type that the permission should be related too. If this argument is not null, the parsed permission has to be related to this resource type
Returns
  • parsed permission, or null, if permission was a null or an empty string

@Nullable public static Permission parsePermission (I18nService i18nService, String permission, Class<?> resourceType, Permission defaultPermission, String context)

Parse permission coming from a REST request parameter into a Stash Permission, optionally accepting only permissions of given type and providing a default permission should the one coming from the request be not specified.

Parameters
i18nService to produce i18n-ed error messages
permission string permission from the request to parse, may be null
resourceType resource type that the permission should be related too. If this argument is not null, the parsed permission has to be related to this resource type
defaultPermission the default permission to use in case permission is null. May be null itself
context context for the error message
Returns
  • parsed permission, or defaultPermission, if permission was a null or an empty string
Throws
WebApplicationException with an appropriate error (400) and message in case the provided permission string is invalid - either does not match an existing Stash Permission, or the matching permission is not related to resourceType