How to handle API access to ServiceDesk organizations

For my company I need to create a central ui to crud-administrate organizations and add/remove customers to/from those organizations. I started out with a webwork module.

Then I looked into the API and found the OrganizationService interface. Sounds good, I thought. But how to access that service and use it?

My first attempt looks like so:

public class OrgadmutilWebwork extends JiraWebActionSupport {

    @ComponentImport
    private OrganizationService organizationService;

    @Inject
    public OrgadmutilWebwork(OrganizationService organizationService) {
        this.organizationService = organizationService;
    }

    public String doExecute()
    {
        return SUCCESS;
    }
}

However, that way the plugin not even gets loaded. So how to do it correctly?

Guess you have looked into that already and would prefer a Java API approach, just in case - while the resp. API endpoints are still marked as ‘experimental’, you could build out your UI atop the JSD REST API, e.g. to Add users to organization:

  • POST /rest/servicedeskapi/organization/{organizationId}/user

Here comes the solution:

You need to export the component as service, then the OrganizationService is injected correctly.

@Named
@ExportAsService({OrgadmutilWebwork.class})
public class OrgadmutilWebwork extends JiraWebActionSupport {

    @ComponentImport
    private OrganizationService organizationService;

    @Inject
    public OrgadmutilWebwork(OrganizationService organizationService) {
        this.organizationService = organizationService;
    }

    public String doExecute()
    {
        return SUCCESS;
    }
}
1 Like