Good Source for ne Developers or usefull documentation?

Andre Mühle February 19, 2022

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?

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 19, 2022

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.

Andre Mühle February 25, 2022

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!

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 1, 2022

Hi @Andre Mühle what code does not work? Can you share more details?

Andre Mühle March 4, 2022

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? 

Andre Mühle March 4, 2022

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;
    }
It throws this:
Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.jira.security.JiraAuthenticationContext]: No qualifying bean of type [com.atlassian.jira.security.JiraAuthenticationContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
I have this out of a Tutorial found somewhere in the atlassian Tutorial site.
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2022

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

Andre Mühle March 4, 2022

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?

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2022

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;
}
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2022

Are you using spring scanner with version > 2? https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/

Andre Mühle March 4, 2022

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.

Andre Mühle March 4, 2022

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.

Andre Mühle March 4, 2022

The issue Code works.

"Test-1" != "TEST-1" and Chrome automatically changes TEST-1 to Test-1 :-(

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 7, 2022

Suggest an answer

Log in or Sign up to answer