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 https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/. 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.