Is a user a Service Desk agent

Hi, is it possible to determine if a user is a Service Desk agent. I see that there is a jira-servicedesk-users group but I’m not sure how bullet proof this is

Thanks
Paul

Doe this maybe help: How to Retrieve Application Access of a User in Jira | Jira | Atlassian Documentation ?

Or this Java API: ServiceDeskPermissionService (JIRA Service Desk API 3.8.1 API)

Hi @tobitheo, for the Rest API, that could be good as long as having the application role jira-servicedesk means you are an agent. I’ll have a look around and see what I can find. Would probably try something similar using the appropriate Java manager class

Thanks
Paul

Hi @tobitheo, for the ServiceDeskPermissionService interface I had actually tried that earlier (probably should have mentioned it :slight_smile: ). I tried to get it using the ServiceDeskComponentAccessor class. My problem with that was it has to all be done using reflection because the plugin may be in a non-service desk instance of Jira (so I can’t use the usual autowiring). I kept getting class not found errors even though the Jira instance had Service Desk. Any ideas for this?

Thanks
Paul

The Servicedesk plugin is also just a plugin and as such, it can happen that it starts after your plugin.
You’ll have to check for its availability every time you try to access it.

When I was trying to access everything had been running for quite a while. I’m not sure if something is needed in the atlassian-plugin.xml but if it does then that probably wouldn’t work with non service desk Jira.

I’ll dig around in the application access stuff and see what I can find

Thanks
Paul

Here’s some code we use to try and get the OrganizationService, maybe it helps:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.plugin.osgi.container.OsgiContainerManager;
import com.atlassian.servicedesk.api.organization.OrganizationService;
import org.osgi.util.tracker.ServiceTracker;

// ... later:

        OsgiContainerManager osgiContainerManager = ComponentAccessor.getComponentOfType(OsgiContainerManager.class);
        ServiceTracker serviceTracker = osgiContainerManager.getServiceTracker("com.atlassian.servicedesk.api.organization.OrganizationService");
        if(serviceTracker == null) {
            // Not available
        } else {
            Object service = serviceTracker.getService();
            if(service != null && service instanceof OrganizationService) {
                // Service is available, do something with it
            } else {
                // Service is null or no OrganizationService
            }
        }
1 Like

Thanks @tobitheo, I’ll give it a go

Thanks
Paul

Ok that worked great for getting an instance of com.atlassian.servicedesk.api.permission.ServiceDeskPermissionService, now all I have to do is figure out how to get the com.atlassian.servicedesk.api.ServiceDesk for the project which shouldn’t be too hard.

Thanks for your help, much appreciated
Paul

1 Like