We need to show different options in the configuration page of our add-on accordingly to the type of instance the add-on is running (i.e. Server or Data Center).
Is there a way to detect the type of instance in a velocity template or programmatically in a servlet?
Have you tried looking at the information you get returned from calling the serverInfo REST endpoint? https://docs.atlassian.com/jira/REST/server/#api/2/serverInfo-getServerInfo
Especially the deploymentType attribute might be able to help you out.
Although I don’t have a Data Center instance to test this on so I cannot guarantee that this works.
Another option would be to use the Java API: https://docs.atlassian.com/jira/server/com/atlassian/jira/cluster/DefaultClusterManager.html
specifically the isClusterLicensed method: https://docs.atlassian.com/jira/server/com/atlassian/jira/cluster/DefaultClusterManager.html#isClusterLicensed--
@pvandevoorde Based on my testing, the deploymentType attribute returns “Server” regardless of if it’s a licensed Server or Data Center instance.
The Java API docs look promising but probably more work to interact with.
Have you seen any other ways to detect Server vs DC outside of the Java APIs you referenced below?
Easiest way that should work against all products is to use SAL:
Take a look at LicenseHandler - easiest way to see if there’s a data center license hanging around.