I try to create a Gadget that fits my need. In there I need to load issues and do what I have to do. My problem is that there is no documentation beyond the Gadget tutorial.
How do I access the issues?
There is a Rest service, I guess I dont have to use that one because the plugin runs in Jira and Rest is used when outside the environment. The Java API has only the java-doc which is ok if you know what you need to search but there is no guide how to use it. Is there any usefull training or documentation how to write a Service and access jira internal resourcees?
Hi @Andre Mühle I didn't develop gadget for quite a long time but I remember I used this documentation for beginning:
https://developer.atlassian.com/server/jira/platform/writing-gadgets-for-jira/
It was also quite useful to download any App which implements gadgets and to get some inspiration from the source code.
this is the tutorial I made. It works so far.
It also refers to the rest service tutorial with not really works because the used services throw injection errors.
In the rest Tutorial there is only a comment for loading issues there. But I can not find a tutorial how to search for issues in this service. There is a link to the java doc but thats useless. How to I query issues from the rest service created in the tutorial? Any why does the tutorial code not work!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andre Mühle what code does not work? Can you share more details?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After several tries over some nights I have many diffrent folders and do not know which one has what state of error. Same when googleing for a solution I opened bazilion of links.
The problem does not really matter, I just start with a clean project when I try again.
Here is the resource for the REST Service I used:
https://developer.atlassian.com/server/framework/atlassian-sdk/rest-plugin-module/
My question is how to develop whats as comment in here:
private String getMessageFromKey(String key) {
// In reality, this data would come from a database or some component
// within the hosting application, for demonstration purpopses I will
// just return the key
return key; }
How can I now query the database and do what I want to with the Java API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So what I have tried is this:
@Path("/projects")
@Named
public class ProjectsResource {
@ComponentImport
private PermissionManager permissionManager;
@ComponentImport
private JiraAuthenticationContext authenticationContext;
/**
* Constructor.
* @Param authenticationContext context that contains authenticated user
* @Param permissionManager the JIRA object which manages permissions for users and projects
*/
@Inject
public ProjectsResource(
JiraAuthenticationContext authenticationContext,
PermissionManager permissionManager)
{
this.authenticationContext = authenticationContext;
this.permissionManager = permissionManager;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andre Mühle you will need to know some basics of Apps implementation based on Atlassian SDK. You should start here:
https://developer.atlassian.com/server/framework/atlassian-sdk/
You need to understand how to use Java API and you will find out that for example for loading Issue data you need to use IssueManager API
https://docs.atlassian.com/software/jira/docs/api/8.22.0/com/atlassian/jira/issue/IssueManager.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I made the plugin, Gadget and RestService Guide from your link =>https://developer.atlassian.com/server/framework/atlassian-sdk/
But it only creates dummy stuff. Where to go next?
The issueManager Java Doc does not tell my how to use it. What do I have to add to the POM file? How to I register the serivce for DI? Any running exmaples?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try following code?
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Path("/projects")
@Component
public class ProjectsResource {
private PermissionManager permissionManager;
private JiraAuthenticationContext authenticationContext;
/**
* Constructor.
* @Param authenticationContext context that contains authenticated user
* @Param permissionManager the JIRA object which manages permissions for users and projects
*/
@Autowired
public ProjectsResource(@ComponentImport JiraAuthenticationContext authenticationContext,
@ComponentImport PermissionManager permissionManager){
this.authenticationContext = authenticationContext;
this.permissionManager = permissionManager;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using spring scanner with version > 2? https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use what ever is used in the Gadget Tutorial: https://developer.atlassian.com/server/jira/platform/writing-gadgets-for-jira/
I can find this in my pom.xml
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
Sorry I dont have a Java Background so I need some extra rounds to see how stuff works. And it seems the like it very complicated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to use the ComponentAccessor. At least there is no error.
@Path("/issue")
public class IssueResource {
private IssueManager _issueManager;
public IssueResource() {
_issueManager = ComponentAccessor
.getIssueManager();
}
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getMessage(
@QueryParam("key") String key
)
{
System.out.println("Try to load key: " + key);
if(key == null || key.isEmpty())
{
return Response.ok(
new IssueResourceModel(
"No Issue Found"))
.build();
}
Issue issue = _issueManager
.getIssueObject(
key);
if(issue == null)
{
return Response.ok(
new IssueResourceModel(
"No Issue Found"))
.build();
}
return Response.ok(
new IssueResourceModel(
issue.getSummary()))
.build();
}
}
Somehow the Issue is always null even if the key exist. But one problem at a time... I have to stop working after 11,5h. I check your other code next night.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The issue Code works.
"Test-1" != "TEST-1" and Chrome automatically changes TEST-1 to Test-1 :-(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Andre Mühle there is a method which returns issue ignoring case:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.