Hi,
I had two situations where I wanted to use the JiraHelper
class in regards to my project-centric-view and both times it is not working out, because the JiraHelper
has nearly only null values.
This questions is a follow up to this question of @m.miessner. Maybe @sfbehnke has some time to look at it
I created a custom condition which controls whether a certain menu item shall be added to the project-centric-view or not, depending on the project which is opened. My first approach was to extend the AbstractWebCondition
class like this.
@Component
public class ProjectHasKeyBCMCondition extends AbstractWebCondition {
private List<String> allowedProjectKeys;
public ProjectHasKeyBCMCondition() {
allowedProjectKeys = new ArrayList<>();
allowedProjectKeys.add("MY_PROJECT_KEY_1");
allowedProjectKeys.add("MY_PROJECT_KEY_2");
}
@Override
public boolean shouldDisplay(ApplicationUser applicationUser, JiraHelper jiraHelper) {
return allowedProjectKeys.contains(jiraHelper.getProject().getKey());
}
}
But it turned out that the jiraHelper.getProject()
method always returns null. I had to implement it using jiraHelper.getRequest().getRequestURL()
and cutting out the relevant string part I need. Not very elegant…
The other situation was when I implemented a ContextProvider
for my project-centric-view. I tried to extend the AbstractJiraContextProvider
class. In the getContextMap()
method there is again a JiraHelper
parameter and again it does only provide a null value when calling jiraHelper.getProject()
. In both situations my understanding would be that a parameter which is called “helper” already has this value evaluated in order to help me this is the same problem as in the question I mentioned earlies. The solution was to implement the
ContextProvider
interface directly and avoid using the AbstractJiraContextProvider
class.
In both situations the usage of the JiraHelper
would be more convenient. Any idea why the jiraHelper
is not initialized like I expected?
regards,
Jens