use of com.gitblit.models.PluginRegistry in project gitblit by gitblit.
the class PluginManager method getRegistries.
protected List<PluginRegistry> getRegistries() {
List<PluginRegistry> list = new ArrayList<PluginRegistry>();
File folder = runtimeManager.getFileOrFolder(Keys.plugins.folder, "${baseFolder}/plugins");
FileFilter jsonFilter = new FileFilter() {
@Override
public boolean accept(File file) {
return !file.isDirectory() && file.getName().toLowerCase().endsWith(".json");
}
};
File[] files = folder.listFiles(jsonFilter);
if (files == null || files.length == 0) {
// automatically retrieve the registry if we don't have a local copy
refreshRegistry(true);
files = folder.listFiles(jsonFilter);
}
if (files == null || files.length == 0) {
return list;
}
for (File file : files) {
PluginRegistry registry = null;
try {
String json = FileUtils.readContent(file, "\n");
registry = JsonUtils.fromJsonString(json, PluginRegistry.class);
registry.setup();
} catch (Exception e) {
logger.error("Failed to deserialize " + file, e);
}
if (registry != null) {
list.add(registry);
}
}
return list;
}
use of com.gitblit.models.PluginRegistry in project gitblit by gitblit.
the class PluginManager method getRegisteredPlugins.
@Override
public synchronized List<PluginRegistration> getRegisteredPlugins() {
List<PluginRegistration> list = new ArrayList<PluginRegistration>();
Map<String, PluginRegistration> map = new TreeMap<String, PluginRegistration>();
for (PluginRegistry registry : getRegistries()) {
list.addAll(registry.registrations);
for (PluginRegistration reg : list) {
reg.installedRelease = null;
map.put(reg.id, reg);
}
}
for (PluginWrapper pw : pf4j.getPlugins()) {
String id = pw.getDescriptor().getPluginId();
Version pv = pw.getDescriptor().getVersion();
PluginRegistration reg = map.get(id);
if (reg != null) {
reg.installedRelease = pv.toString();
}
}
return list;
}
Aggregations