How to write the code to verify the customer permission using CustomerContextService

jira-server

#1

All,

Jira server app:
I have written the plugin module on the post function and updating the reporter when transitioned the ticket.
this postfunction is used in jira projects as well service desk projects.
So the issue is that the below code uses the service desk api to find the permissions on the customers. One way I got the customerContextService object using constructor injection but problem to using this way if I do not have service desk application installed. so this code is breaking.

I was trying avoid injection and try loading as below but not getting the object.
I really appreciate all your opinions and suggestions. thanks.

CustomerContextService customerContextService = ComponentAccessor.getComponent(CustomerContextService.class);
b = customerContextService.runInCustomerContext(new NoExceptionsCallable<Boolean>(){
    @Override
    public Boolean call() {
		boolean 	b = permissionManager.hasPermission(CREATE_ISSUES, project, applicationUser);
		Util.showLogMessage(applicationUser,project,b,Constants.REPORTER);
		return 	b;
	}
});