We're developing a plugin which core functionality relies on a servlet filter, this however can be disabled from upm page expanding modules of our plugin. Is there a way to hide the disable button for this specific servlet filter?
Community moderators have prevented the ability to post new answers.
An admin can always disable any module that is not flagged as a "system essential" module. You'd need to change the core code of Jira to tell it that the servlet filter is such a module, there's no way to protect it from the outside.
Best you can do is detect it as your app loads and throw an error that just stops it loading/enabling and tells the admin why it's refusing to load.
Thanks for the response @Nic Brough -Adaptavist-, let's say plugin is installed for the first time with this module enabled, so everything is good; but then, admin user decides to disable it. Is there a way to be notified of this event? If so, could I programmatically disable the whole plugin?
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That would be a lot nicer than a simple crash from your app. There may be a way to write a listener that catches "plugin/module disabled" and causes yours to be disabled if they hit that one, but I'm really not sure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic! this is how I finally solve it:
public class PluginModuleEventAware implements DisposableBean, InitializingBean {
private final EventPublisher eventPublisher;
private final PluginController pluginController;
public PluginModuleEventAware(EventPublisher eventPublisher, PluginController pluginController) {
this.pluginController = pluginController;
this.eventPublisher = eventPublisher;
}
@Override
public void afterPropertiesSet() throws Exception {
eventPublisher.register(this);
}
@Override
public void destroy() throws Exception {
eventPublisher.unregister(this);
}
@EventListener
public void onModuleDisabledEvent(PluginModuleDisabledEvent moduleDisabledEvent) {
if (moduleDisabledEvent.getModule().getKey().equals("my-core-filter")) {
pluginController.enablePluginModule(moduleDisabledEvent.getModule().getCompleteKey());
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.