1 package com.atlassian.plugin;
2
3 import com.atlassian.plugin.manager.PluginEnabledState;
4
5 import java.util.Map;
6
7 /**
8 * A snapshot of persistent state data for all plugins -- whether the plugin has been disabled by the user, and
9 * whether anything special is to happen on restart.
10 *
11 * This class does not know whether a Plugin has successfully started -- it is just reporting whether the plugin has
12 * been explicitly disabled.
13 *
14 * The methods on this interface were pulled up from PluginPersistentState
15 *
16 * @since 5.1.0
17 */
18 public interface StoredPluginState {
19 /**
20 * Get the map of all states with the update timestamp for each of them.
21 *
22 * If the plugin or module has no entry in the Map, then it is in the default state.
23 *
24 * @return a map of plugins and modules' keys to their stored state
25 */
26 Map<String, PluginEnabledState> getStatesMap();
27
28 /**
29 * Whether or not a plugin is enabled, calculated from its persisted state AND default state.
30 *
31 * The default state is 'enabled' unless there is a disabled='true' attribute in atlassian-plugin.xml, or the
32 * minimum java-version specified in atlassian-plugin.xml is higher than the version we are running in.
33 *
34 * This does not report whether the plugin has successfully started -- use {@link PluginAccessor} for that
35 * information.
36 */
37 boolean isEnabled(Plugin plugin);
38
39 /**
40 * Whether or not a given plugin module is enabled, calculated from its persisted state AND default state.
41 *
42 * The default state is 'enabled' unless there is a disabled='true' attribute in atlassian-plugin.xml, or the
43 * minimum java-version specified in atlassian-plugin.xml is higher than the version we are running in.
44 *
45 * This does not report whether the plugin has successfully started -- use {@link PluginAccessor} for that
46 * information.
47 */
48 boolean isEnabled(ModuleDescriptor<?> pluginModule);
49
50 /**
51 * Get state map of the given plugin and its modules.
52 *
53 * If the plugin or module has no entry in the Map, then it is in the default state.
54 *
55 * @param plugin the plugin
56 * @return a map of plugin and module keys to their stored state
57 */
58 Map<String, PluginEnabledState> getPluginEnabledStateMap(Plugin plugin);
59
60 /**
61 * Gets whether the plugin is expected to be upgraded, installed, or removed on next restart.
62 *
63 * @param pluginKey The plugin to query
64 * @return The state of the plugin on restart
65 */
66 PluginRestartState getPluginRestartState(String pluginKey);
67 }