use of hudson.PluginWrapper in project hudson-2.x by hudson.
the class PluginUtil method getWrapper.
public static PluginWrapper getWrapper(final Plugin plugin) {
assert plugin != null;
try {
Field field = Plugin.class.getDeclaredField("wrapper");
field.setAccessible(true);
return (PluginWrapper) field.get(plugin);
} catch (Exception e) {
throw new RuntimeException("Failed to access PluginWrapper", e);
}
}
use of hudson.PluginWrapper in project hudson-2.x by hudson.
the class UpdateSite method getUpdates.
/**
* Returns the list of plugins that are updates to currently installed ones.
*
* @return
* can be empty but never null.
*/
public List<Plugin> getUpdates() {
Data data = getData();
// fail to determine
if (data == null)
return Collections.emptyList();
List<Plugin> r = new ArrayList<Plugin>();
for (PluginWrapper pw : Hudson.getInstance().getPluginManager().getPlugins()) {
Plugin p = pw.getUpdateInfo();
if (p != null)
r.add(p);
}
return r;
}
use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.
the class BlueI18nTest method test_200_response_locale_match.
@Test
public void test_200_response_locale_match() {
PluginWrapper plugin = BlueI18n.getPlugin("blueocean-dashboard");
if (plugin == null) {
// Skip. See waitForPluginLoaded() above.
return;
}
String dashboardVersion = plugin.getVersion();
Map<String, Object> response1 = get("/blue/rest/i18n/blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.Messages/de", HttpServletResponse.SC_OK, Map.class);
Assert.assertEquals("ok", response1.get("status"));
Assert.assertTrue(((Map<String, Object>) response1.get("data")).containsKey("common.date.duration.format"));
}
use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.
the class BlueI18n method getBundle.
@CheckForNull
private JSONObject getBundle(BundleParams bundleParams, Locale locale) {
PluginWrapper plugin = bundleParams.getPlugin();
if (plugin == null) {
return null;
}
try {
ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleParams.bundleName, locale, plugin.classLoader);
JSONObject bundleJSON = new JSONObject();
for (String key : resourceBundle.keySet()) {
bundleJSON.put(key, resourceBundle.getString(key));
}
return bundleJSON;
} catch (MissingResourceException e) {
// fall through and return null.
}
return null;
}
use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.
the class BlueI18nTest method test_404_response_unknown_bundle.
@Test
public void test_404_response_unknown_bundle() {
PluginWrapper plugin = BlueI18n.getPlugin("blueocean-dashboard");
if (plugin == null) {
// Skip. See waitForPluginLoaded() above.
return;
}
String dashboardVersion = plugin.getVersion();
Map<String, Object> response1 = get("/blue/rest/i18n/blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.XXXUnknown/en", HttpServletResponse.SC_NOT_FOUND, Map.class);
Assert.assertEquals("error", response1.get("status"));
Assert.assertEquals("Unknown plugin or resource bundle: blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.XXXUnknown/en", response1.get("message"));
}
Aggregations