How can I find the Crucible review ID from a GutterRenderer plugin?

Peter Burka June 23, 2014

I'm trying to write my first Atlassian plugin, and I found it pretty easy to get started, but now I'm stuck. I suspect someone with more experience can quickly point me in the right direction.

I'm writing a GutterRenderer plugin for Crucible. I want to display information in the diff gutter which I've stored in a database elsewhere, and which is keyed on the review ID. The GutterRenderer interface allows me to find the repository, the file paths, and the file revisions, but it doesn't provide any information about the review. (We use pre-push reviews, so I can't rely on all files having meaningful revisions).

How can I determine that my renderer is being invoked in the context of a code review, and not just a diff, and how can I discover details about the review?

1 answer

1 accepted

0 votes
Answer accepted
lpater
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 23, 2014

Hi Peter,

it seems that there's a long standing issue to provide some context (including the review id) to gutter renderers - https://jira.atlassian.com/browse/FE-1363. Please vote for it and add a comment abou the features you'd like to see.

Without the context, I think your best bet is using com.atlassian.sal.api.web.context.HttpContext to retrieve the current request, and determine the current review based on the requests's url. Reviews urls will generally have /cru/REVIEW-PERM-ID in their url.

Peter Burka June 24, 2014

Thanks for the suggestion. I figured out how to wire an HttpContext into my plugin, but sadly the requesteURL() doesn't include the CR identifier:

http://crucible34.example.com:3990/fecru/WEB-INF/jsp/crucible/review/monolithic/displayFrxInnerDiv.jsp

It looks like the referer header does include the number:

http://crucible34.example.com:3990/fecru/cru/CR-2

I'm going to use this for now, but I'm reluctant to rely on referer URLs, as there's little guarantee that the referer header will be accurate.

Crucible must be communicating this information to the child page somehow, but I don't yet see how. Perhaps it's stashed away in an Atlassian session object somewhere.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events