Class RestHelper
- java.lang.Object
-
- com.atlassian.bamboo.plugins.rest.common.RestHelper
-
public final class RestHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.ws.rs.core.UriInfoaddAutoExpand(javax.ws.rs.core.UriInfo uriInfo, String expandable)static booleanareBuildPositionsRequested(javax.ws.rs.core.UriInfo uriInfo)static voidassertExecutePermission(PlanKey planKey, BambooPermissionManager bambooPermissionManager)static voidassertGlobalPermission(@NotNull BambooPermission permission)Asserts that current user has the specified permission.static voidassertGlobalPermission(@NotNull BambooPermission permission, @NotNull String errorMessage)Asserts that current user has the specified permission.static voidassertIpAddressIsLocal(@NotNull String address)static voidassertNotRssDeploymentProject(@NotNull DeploymentProject deploymentProject)Asserts deployment project is not managed by repository stored specs.static voidassertNotRssEnvironment(@NotNull Environment environment, @NotNull DeploymentProjectService deploymentProjectService)Asserts environment is not managed by repository stored specs.static voidassertNotRssPlan(@NotNull PlanKey planKey, @NotNull PlanRestService planRestService)Asserts plan is not managed by repository stored specs.static voidassertPlanPermission(@NotNull BambooPermission permission, @NotNull PlanKey planKey, BambooPermissionManager bambooPermissionManager)Check user has provided or ADMINISTRATION permission on given planstatic voidassertReadPermission()static voidassertRestrictedAdminPermission()static voidassertSystemAdminPermission()static javax.ws.rs.core.CacheControlcacheNever()Removes caching in responsestatic booleancontainsFavouriteQueryParam(javax.ws.rs.core.UriInfo uriInfo)static booleancontainsMyOnlyQueryParam(javax.ws.rs.core.UriInfo uriInfo)static booleancontainsPermissionQueryParam(javax.ws.rs.core.UriInfo uriInfo)static InputStreamexecuteGET(Get call, javax.ws.rs.core.Response.Status expectedResponseStatus)static org.codehaus.jackson.JsonNodeexecuteJsonGET(Get call)static org.codehaus.jackson.JsonNodeexecuteJsonGET(Get call, javax.ws.rs.core.Response.Status expectedResponseStatus)static StringformatDateTime(long datetime)static BuildStategetBuildStateQueryParam(@NotNull javax.ws.rs.core.UriInfo uriInfo)static @NotNull Map<String,String>getFormParamsMap(javax.ws.rs.core.MultivaluedMap<String,String> formParams)Returns first occurrence of parameters mapstatic I18nBeangetI18nBean()static @Nullable LifeCycleStategetLifeCycleStateQueryParam(@NotNull javax.ws.rs.core.UriInfo uriInfo)static Class<? extends ImmutablePlan>getPlanType(javax.ws.rs.core.UriInfo uriInfo)static @Nullable List<String>getQueryParamAsList(javax.ws.rs.core.UriInfo uriInfo, String key)static @NotNull Map<String,String>getQueryParamsMap(javax.ws.rs.core.UriInfo uriInfo)Returns first occurrence of parameters mapstatic @Nullable URIgetReturnUri(javax.ws.rs.core.UriInfo uriInfo)Content of 'returnUrl' request parameter or null if empty.static booleanhasCloverEnabledQueryParam(javax.ws.rs.core.UriInfo uriInfo)static booleanhasQueryParam(javax.ws.rs.core.UriInfo uriInfo, String key)static booleanhasWithBuildPermissionOnlyParam(javax.ws.rs.core.UriInfo uriInfo)
-
-
-
Method Detail
-
getI18nBean
public static I18nBean getI18nBean()
-
addAutoExpand
public static javax.ws.rs.core.UriInfo addAutoExpand(javax.ws.rs.core.UriInfo uriInfo, String expandable)
-
containsFavouriteQueryParam
public static boolean containsFavouriteQueryParam(javax.ws.rs.core.UriInfo uriInfo)
-
containsPermissionQueryParam
public static boolean containsPermissionQueryParam(javax.ws.rs.core.UriInfo uriInfo)
-
containsMyOnlyQueryParam
public static boolean containsMyOnlyQueryParam(javax.ws.rs.core.UriInfo uriInfo)
-
areBuildPositionsRequested
public static boolean areBuildPositionsRequested(javax.ws.rs.core.UriInfo uriInfo)
-
getPlanType
public static Class<? extends ImmutablePlan> getPlanType(javax.ws.rs.core.UriInfo uriInfo)
-
hasCloverEnabledQueryParam
public static boolean hasCloverEnabledQueryParam(javax.ws.rs.core.UriInfo uriInfo)
-
hasWithBuildPermissionOnlyParam
public static boolean hasWithBuildPermissionOnlyParam(javax.ws.rs.core.UriInfo uriInfo)
-
hasQueryParam
public static boolean hasQueryParam(javax.ws.rs.core.UriInfo uriInfo, String key)
-
getQueryParamAsList
@Nullable public static @Nullable List<String> getQueryParamAsList(javax.ws.rs.core.UriInfo uriInfo, String key)
-
getQueryParamsMap
@NotNull public static @NotNull Map<String,String> getQueryParamsMap(javax.ws.rs.core.UriInfo uriInfo)
Returns first occurrence of parameters map- Parameters:
uriInfo-- Returns:
- query parameters map
-
getFormParamsMap
@NotNull public static @NotNull Map<String,String> getFormParamsMap(javax.ws.rs.core.MultivaluedMap<String,String> formParams)
Returns first occurrence of parameters map- Parameters:
formParams-- Returns:
- query parameters map
-
getBuildStateQueryParam
public static BuildState getBuildStateQueryParam(@NotNull @NotNull javax.ws.rs.core.UriInfo uriInfo)
-
getLifeCycleStateQueryParam
@Nullable public static @Nullable LifeCycleState getLifeCycleStateQueryParam(@NotNull @NotNull javax.ws.rs.core.UriInfo uriInfo)
-
formatDateTime
public static String formatDateTime(long datetime)
-
cacheNever
public static javax.ws.rs.core.CacheControl cacheNever()
Removes caching in response
-
getReturnUri
@Nullable public static @Nullable URI getReturnUri(javax.ws.rs.core.UriInfo uriInfo)
Content of 'returnUrl' request parameter or null if empty.- Parameters:
uriInfo-- Returns:
- 'returnUrl' request parameter or null if empty
-
assertPlanPermission
public static void assertPlanPermission(@NotNull @NotNull BambooPermission permission, @NotNull @NotNull PlanKey planKey, BambooPermissionManager bambooPermissionManager)Check user has provided or ADMINISTRATION permission on given plan- Parameters:
permission-planKey-bambooPermissionManager-
-
assertReadPermission
public static void assertReadPermission()
-
assertExecutePermission
public static void assertExecutePermission(PlanKey planKey, BambooPermissionManager bambooPermissionManager)
-
assertSystemAdminPermission
public static void assertSystemAdminPermission()
-
assertRestrictedAdminPermission
public static void assertRestrictedAdminPermission()
-
assertGlobalPermission
public static void assertGlobalPermission(@NotNull @NotNull BambooPermission permission)Asserts that current user has the specified permission. If not, throwsAccessDeniedExceptionwith a generic error message.- Parameters:
permission- permission to verify- Throws:
org.acegisecurity.AccessDeniedException- if user lacks the specified permission
-
assertGlobalPermission
public static void assertGlobalPermission(@NotNull @NotNull BambooPermission permission, @NotNull @NotNull String errorMessage)Asserts that current user has the specified permission. If not, throwsAccessDeniedExceptionwith the specified message- Parameters:
permission- permission to verifyerrorMessage- exception message to be used if user lacks the specified permission- Throws:
org.acegisecurity.AccessDeniedException- if user lacks the specified permission
-
assertIpAddressIsLocal
public static void assertIpAddressIsLocal(@NotNull @NotNull String address) throws UnknownHostException- Throws:
UnknownHostException
-
assertNotRssPlan
public static void assertNotRssPlan(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull PlanRestService planRestService)Asserts plan is not managed by repository stored specs.
-
assertNotRssEnvironment
public static void assertNotRssEnvironment(@NotNull @NotNull Environment environment, @NotNull @NotNull DeploymentProjectService deploymentProjectService)Asserts environment is not managed by repository stored specs.
-
assertNotRssDeploymentProject
public static void assertNotRssDeploymentProject(@NotNull @NotNull DeploymentProject deploymentProject)Asserts deployment project is not managed by repository stored specs.
-
executeJsonGET
public static org.codehaus.jackson.JsonNode executeJsonGET(Get call) throws Exception
- Throws:
Exception
-
executeJsonGET
public static org.codehaus.jackson.JsonNode executeJsonGET(Get call, javax.ws.rs.core.Response.Status expectedResponseStatus) throws Exception
- Throws:
Exception
-
executeGET
public static InputStream executeGET(Get call, javax.ws.rs.core.Response.Status expectedResponseStatus)
-
-