use of com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin in project qcadoo by qcadoo.
the class DefaultPluginAccessor method init.
public void init() {
LOG.info("Plugin Framework initialization");
long time = System.currentTimeMillis();
pluginStateResolver.setPluginAccessor(this);
Set<InternalPlugin> enabledPluginsFromDescriptor = pluginDescriptorParser.loadPlugins();
Set<QcadooPluginPlugin> pluginsFromDatabase = pluginDao.list();
for (InternalPlugin plugin : enabledPluginsFromDescriptor) {
QcadooPluginPlugin existingPlugin = null;
for (QcadooPluginPlugin databasePlugin : pluginsFromDatabase) {
if (plugin.getIdentifier().equals(databasePlugin.getIdentifier())) {
existingPlugin = databasePlugin;
break;
}
}
if (existingPlugin == null) {
plugin.changeStateTo(PluginState.ENABLING);
} else {
plugin.changeStateTo(PluginState.valueOf(existingPlugin.getState()));
}
if (existingPlugin == null || plugin.compareVersion(new Version(existingPlugin.getVersion())) > 0) {
pluginDao.save(plugin);
} else if (plugin.compareVersion(new Version(existingPlugin.getVersion())) < 0) {
throw new IllegalStateException("Unsupported operation: downgrade, for plugin: " + plugin.getIdentifier());
}
LOG.info("Registering plugin " + plugin);
plugins.put(plugin.getIdentifier(), plugin);
}
for (QcadooPluginPlugin databasePlugin : pluginsFromDatabase) {
if (databasePlugin.getState().equals(PluginState.TEMPORARY.toString())) {
continue;
}
Plugin existingPlugin = null;
for (Plugin plugin : enabledPluginsFromDescriptor) {
if (databasePlugin.getIdentifier().equals(plugin.getIdentifier())) {
existingPlugin = plugin;
break;
}
}
if (existingPlugin == null) {
pluginDao.delete(databasePlugin);
}
}
Set<InternalPlugin> temporaryPlugins = pluginDescriptorParser.getTemporaryPlugins();
for (InternalPlugin plugin : temporaryPlugins) {
plugins.put(plugin.getIdentifier(), plugin);
}
LOG.info("Plugin Framework initialized in " + (System.currentTimeMillis() - time) + "ms");
}
use of com.qcadoo.model.beans.qcadooPlugin.QcadooPluginPlugin in project qcadoo by qcadoo.
the class DefaultPluginManager method getEnabledPluginsList.
@Override
public List<Plugin> getEnabledPluginsList() {
List<Plugin> pluginIdentifierList = new ArrayList<Plugin>();
Set<QcadooPluginPlugin> pluginList = pluginDao.list();
for (QcadooPluginPlugin qcadooPlugin : pluginList) {
Plugin plugin = pluginAccessor.getEnabledPlugin(qcadooPlugin.getIdentifier());
if (plugin != null) {
pluginIdentifierList.add(plugin);
}
}
return pluginIdentifierList;
}
Aggregations