Changing Board Admin via Java API

Hey guys,

Thanks for the earlier feedback on looking through the source code…once I found CTRL-N in Idea, it was much easier to find what I was looking for. But now I’m stuck again. I’m trying to change the board admins for a board using the Java API but I can’t seem to figure out how to get an instance of BoardAdminService or BoardAdminManager. In the code, I can see that they Autowire:

    @Autowired
    private BoardAdminManager boardAdminManager;

But when I try it, it says:

No qualifying bean of type [com.atlassian.greenhopper.manager.rapidview.BoardAdminManager] found for dependency

I have also tried:

BoardAdminService boardService = (BoardAdminService) ComponentAccessor.getOSGiComponentInstanceOfType(BoardAdminService.class);

and

BoardAdminManager boardAdminManager = (BoardAdminManager) ComponentAccessor.getOSGiComponentInstanceOfType(BoardAdminManager.class);

But also no luck. How do you get access to these elusive services?

Thanks,

Wade

This is documented on Bitbucket. You must have a line in pom.xml under <Import-Package>.

Thanks for the reply! I really appreciate it. It doesn’t seem to work or at least I’m not doing it right. I added this to my pom.xml:

<Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            com.atlassian.greenhopper.service.rapid.view.*;resolution:="optional",
                            *
</Import-Package>

The greenhopper entry is what I added, the others were already there. Then I tried:

    @Autowired
    private BoardAdminService boardAdminService;

and had no luck so I tried

    @ComponentImport
    @Autowired
    private BoardAdminService boardAdminService;

since it says that is ‘from outside your plugin’ and had no luck. So maybe I don’t have the package name correct? I got it straight from the java docs. Also, it’s curious that I can do:

RapidViewService rapidViewService = (RapidViewService) ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService.class);

and get a valid object and RapidViewService is from the same package as BoardAdminService. I feel like I’m so close to figuring this out–it almost starts to feel like Atlassian is purposely obfuscating certain things just to fool with us =)

@Autowired belongs on the Constructor of the class you’re injecting this into. @ComponentImport belongs on the member being injected. From your snippet it looks like you’ve added both @ComponentImport and @Autowired to the member.

Thanks for the help again. I changed my code to:

    @Autowired
    public StandardAddProjectHook(@ComponentImport BoardAdminService boardAdminService) {
        this.boardAdminService = boardAdminService;
    }

But still getting:

[INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.greenhopper.service.rapid.view.BoardAdminService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}

If you are working online, can I see the repo? Otherwise, can you show me the dependency declaration in your pom file and your spring scanner configuration of the pom file?

I’m actually just going to change the way I am creating the board and filter by using the project lead’s security context instead of the logged in user (an admin). That way they will be the owner/admin of everything by default.

I have the same problem. I found out, that the BoadAdminService is available in the jira-greenhopper-plugin only.

But in my pom.xml I am using the jira-greenhopper-api.

If I change the dependency and use @JiraComponent or @JiraImport in the construtor there is no error during compilation but the plugin is not able to load…

Did you find another solution to change / update the board admins?

Not really, I just avoided the problem by creating the board with the user’s context so that they would already be the owner/admin. Since I was creating the board, this worked out–if you are trying to change an existing board I’m not sure what you would have to do.

What you are using in your pom does not matter. What matters is what is already loaded via OSGi into the running JIRA instance. If you don’t have the class files, your compiler and IDE may care, but I assure you, JIRA does not. :slight_smile:

Visit /plugins/servlet/upm/osgi on your instance (don’t forget the context, if you have one) to see what services are shared.

However, if Atlassian doesn’t make the maven package available, you probably won’t be able to get anything to compile and build to be able to load the jar.

They do make dailies available:
Visit https://packages.atlassian.com
Click the first tile, Package Search
Enter Artifact ID: jira-greenhopper-plugin and Version: 8.5.0
Click search. You will see a bunch of dailies for 8.5.0.

You may be able to use these to hack together a solution. But, don’t.

The jira-core package includes a BoardManager, but 1) don’t depend on jira-core and 2) it doesn’t do what you want. Atlassian has always been very “black box” when it comes to JIRA Agile (aka: greenhopper).


Just use the REST API. You can use this from within the Java API and it will use the currently logged in user automatically for API authentication.

I recommend searching for the endpoint in the REST API Browser plugin, to verify it hasn’t changed since that post was made.

1 Like

Hi, I just came by your discussion, and I wanted to know if you could explain how to access the TEST API from the Java API?