I have been working on this for days now.....
I need a plugin in JIRA that can query Bitbucket. The result of the queries need to be presented on a panel on the right side. So started with the tutorial DueDateIndicator to get control of the UI.
Next (and this is my headache) I want to get a reference to the applinks, But it fails, never enabling the plugin
import com.atlassian.applinks.api.ApplicationLinkResponseHandler;
import com.atlassian.applinks.api.application.stash.StashApplicationType;
import com.atlassian.applinks.api.ApplicationLink;
import com.atlassian.applinks.api.ApplicationLinkService;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
public class DueDateIndicator extends AbstractJiraContextProvider
{
private static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
private final ApplicationLinkService applicationLinkService;
public DueDateIndicator (ApplicationLinkService applicationLinkService)
{
this.applicationLinkService = applicationLinkService;
}
@Override
public Map getContextMap(User user, JiraHelper jiraHelper) {
ApplicationLink application_link = this.applicationLinkService.getPrimaryApplicationLink(com.atlassian.applinks.api.application.stash.StashApplicationType.class);
Map contextMap = new HashMap();
Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
Timestamp dueDate = currentIssue.getDueDate();
if (dueDate != null)
{
int currentTimeInDays = (int) (System.currentTimeMillis() / MILLIS_IN_DAY);
int dueDateTimeInDays = (int) (dueDate.getTime() / MILLIS_IN_DAY);
int daysAwayFromDueDateCalc = dueDateTimeInDays - currentTimeInDays + 1;
contextMap.put("daysAwayFromDueDate", daysAwayFromDueDateCalc);
}
return contextMap;
}
}
This should not be the hard part right?
My fallback is to just use perl scripting outside of JAVA.... I would really hate going into this direction
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.