RestFragmentsFactory - Get Pull Request Permissions within servlet

I am working on a plugin for Bitbucket that uses a servlet to fetch data from Bitbucket’s Java APIs in order to display it to users. I’m having a hard time getting data about Pull Request Settings via the Java API - it doesn’t sound like a public API exists for this purpose (as noted here: https://jira.atlassian.com/browse/BSERV-9817)

On that issue, Bryan suggested using RestFragmentsFactory to get this data. My issue is that I’m unsure of how to build the UriInfo parameter for construction of the DefaultRestFragmentContext (the uriInfoProxy parameter in Bryan’s example code).

From what I understand, UriInfo can be easily retrieved when inside of a REST resource built on a framework like Jersey, but my plugin uses a servlet. How can I get/construct this parameter from within the servlet?

I’d like to avoid making an actual HTTP request to the public REST API from within the servlet since that’s sloppy and introduces additional overhead.

1 Like