How do I create the Scrum Board (rapidView) for the project using Java in the JIRA Plugin?

Hi,
I’m developing a custom plugin in which (among other things) I would like to create a Scrum Board for the project.
I have managed to include the greenhopper dependency, and have successfully used RapidViewCreationService and RapidViewService which are both injected as follows:

import com.atlassian.greenhopper.api.rapid.view.RapidViewCreationService;
import com.atlassian.greenhopper.service.rapid.view.RapidViewService;

...
@ComponentImport
    private final RapidViewCreationService rapidViewCreationService;

@ComponentImport
    private final RapidViewService rapidViewService;
...
public MyPluginComponent(
            final RapidViewService rapidViewService,
            final RapidViewCreationService rapidViewCreationService
    ) {
...
}

Unfortunately, I had no luck injecting the com.atlassian.greenhopper.manager.rapidview.RapidViewManager (Plugin never resolved service '&rapidViewManager') nor instantiating it in any other way (through ComponentAccessor.getComponent(RapidViewManager.class), ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewManager.class) nor doing simply new RapidViewManagerImpl())

So my question is twofold:

  • how can I use RapidViewManager ?
  • is there any other way to create or copy & manipulate (setting the right filter & shares for the new project) the RapidView Board of SCRUM type?

Thanks!

Apparently sometimes it’s enough to post the question to find the answer :slight_smile:

I have somehow managed to overlook the

public ServiceOutcome<RapidView> create(@Nullable ApplicationUser au, @Nonnull String string, @Nonnull Long l, @Nonnull RapidViewPreset rvp);

method of the RapidViewService, that takes: a user, a name of the board to be created, a filter ID and a RapidViewPreset (KANBAN, SCRUM) and creates a RapidView.

I will leave this answer here, as I have searched through the whole internet today and haven’t found the answer.

Have a good day :slightly_smiling_face:

1 Like

You must Import Components like this:

private RapidViewService getRapidViewService() throws InvalidSyntaxException {
        
	    ApplicationContext appCtx = (ApplicationContext) getGreenHopperAppCtx();
	        if ( appCtx !=null ) {
	            return (RapidViewService) appCtx.getBean( "rapidViewServiceImpl" );
	        }
	        return null;
	}

private Object getGreenHopperAppCtx() throws InvalidSyntaxException {
    OsgiContainerManager osgi = ComponentAccessor.getComponentOfType(OsgiContainerManager.class);
        if ( osgi==null ) {
             java.lang.System.out.println("OSGI Not Found");
             return null;
        }
 
        Bundle[] bundles = osgi.getBundles();
 
        for(int i=0;i<bundles.length;i++) {
            Bundle bundle = bundles[i];
 
            if ( "com.atlassian.greenhopper".equals( bundle.getSymbolicName() ) ) {
 
                BundleContext bctx = bundle.getBundleContext();
                ServiceReference[] refs = bctx.getAllServiceReferences(null,null);
                if ( refs!=null ) {
                    for(int j=0; j<refs.length;j++) {
                        Object prop = refs[j].getProperty("org.springframework.context.service.name");
                        if ( "com.pyxis.greenhopper.jira".equals(prop) ) {
                            return bctx.getService( refs[j] );
                        }
                         
                    }
                }
            }
        }
        return null;
}
1 Like

@matti.kiviharju, as I’m very new to this (and not a Java developer sadly), would you mind giving some more explanation on why?
I was sure that the greenhopper is a part of Jira API anyways so no need to check for it’s existence?
And so there is no misunderstanding - my code does work.