This document will guide you through the migration of your Marketplace app from REST v1 to REST v2. Bitbucket Data Center has migrated to REST v2 as part of the upgrade to Platform 7.
These documents include Atlassian REST v2 migration guides:
The rest of this documentation will be Bitbucket specific REST v2 migration.
REST v1 dependencies | REST v2 dependencies |
---|---|
<dependency> <groupId>com.atlassian.bitbucket.server</groupId> <artifactId>bitbucket-rest-api</artifactId> <scope>provided</scope> <dependency> | <dependency> <groupId>com.atlassian.bitbucket.server</groupId> <artifactId>bitbucket-rest-v2-api</artifactId> <scope>provided</scope> <dependency> |
<dependency> <groupId>com.atlassian.bitbucket.server</groupId> <artifactId>bitbucket-rest-spi</artifactId> <scope>provided</scope> <dependency> | <dependency> <groupId>com.atlassian.bitbucket.server</groupId> <artifactId>bitbucket-rest-v2-spi</artifactId> <scope>provided</scope> <dependency> |
<dependency> <groupId>com.atlassian.bitbucket.server</groupId> <artifactId>bitbucket-rest-model</artifactId> <scope>provided</scope> <dependency> | removed in REST v2. Most classes migrated to bitbucket-rest-v2-api . |
Update @Context
with @BeanParams
for injecting custom resolvers constructed from request parameters into a resource.
Then, use the custom resolvers to get the appropriate object.
1 2// REST v1 public Response getProjectData(@Context Project project) { ... } // REST v2 public Response getProjectData(@BeanParam ProjectResolver projectResolver) { Project project = projectResolver.getProject(); ... }
The custom resolvers that we currently support may require additional OSGi imports:
Resolver | Required OSGi imports |
---|---|
com.atlassian.bitbucket.rest.v2.api.resolver.ProjectResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.RepositoryResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.PullRequestResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.CommentResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.UserResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.PageRequestResolver |
|
com.atlassian.bitbucket.rest.v2.api.resolver.DiffContentFilterResolver |
|
com.atlassian.bitbucket.rest.util.RestUtils
was separated into helper classes as below:
RestUtils (REST v1) | REST v2 location |
---|---|
com.atlassian.bitbucket.rest.util.RestUtils constants | com.atlassian.bitbucket.rest.v2.api.util.RestConstants |
com.atlassian.bitbucket.rest.util.RestUtils#makeAvatarRequest | com.atlassian.bitbucket.rest.v2.api.enrich.AvatarRequestHelper#makeAvatarRequest |
com.atlassian.bitbucket.rest.util.RestUtils#processAvatarResponse | com.atlassian.bitbucket.rest.v2.api.enrich.AvatarRequestHelper#processAvatarResponse |
com.atlassian.bitbucket.rest.util.RestUtils#makePageRequest | use com.atlassian.bitbucket.rest.v2.api.resolver.PageRequestResolver |
com.atlassian.bitbucket.rest.util.RestUtils#makeRenderContext | removed from API. |
com.atlassian.bitbucket.rest.util.RestUtils#isImmutableObjectId | removed from API, see com.atlassian.bitbucket.rest.v2.api.util.CachePolicies#getCacheControlForObjectId |
com.atlassian.bitbucket.rest.util.RestUtils#isImmutableBetween | removed from API, see com.atlassian.bitbucket.rest.v2.api.util.CachePolicies#getCacheControlForRange |
com.atlassian.bitbucket.rest.util.RestUtils#processEntities | com.atlassian.bitbucket.rest.v2.api.enrich.EnrichProcessor#processEntities |
com.atlassian.bitbucket.rest.exception.UnhandledExceptionMapper
was removed in REST v2.
All the standard Bitbucket exceptions will be mapped to the appropriate status code by the Bitbucket application.
javax.ws.rs.ext.ExceptionMapper
and override the toResponse
method.@Provider
for runtime discovery.1 2@Provider @Singleton public class CustomExceptionMapper implements ExceptionMapper<CustomException> { @Override public Response toResponse(CustomException exception) { return ResponseFactory.status(Response.Status.FORBIDDEN) .entity(new RestErrors(exception.getLocalizedMessage())) .build(); } }
@com.atlassian.bitbucket.rest.annotation.SecondaryRepository
annotation was removed in REST v2.
com.atlassian.bitbucket.rest.util.StreamingResponse
was removed in REST v2.
com.atlassian.bitbucket.rest.RestResource
was removed in REST v2. Resources relying on RestResource
previously must now throw their own exceptions directly.
RestFragments
have migrated from bitbucket-rest-spi
to bitbucket-rest-v2-spi
.
The imports have changed from com.atlassian.bitbucket.rest.fragment.*
to com.atlassian.bitbucket.rest.v2.fragment.*
.
Its configuration remains the same, more information available on REST fragment plugin module
Rate this page: