use of io.apiman.manager.api.beans.plugins.PluginRegistryBean in project apiman by apiman.
the class PluginResourceImpl method loadRegistry.
/**
* Loads a plugin registry from its URL. Will use the value in the
* cache if it exists. If not, it will connect to the remote URL and
* grab the registry JSON file.
* @param registryUrl the URL of the registry
*/
private PluginRegistryBean loadRegistry(URI registryUrl) {
PluginRegistryBean fromCache = registryCache.get(registryUrl);
if (fromCache != null) {
return fromCache;
}
try {
PluginRegistryBean registry = MAPPER.reader(PluginRegistryBean.class).readValue(registryUrl.toURL());
registryCache.put(registryUrl, registry);
return registry;
} catch (IOException e) {
return null;
}
}
use of io.apiman.manager.api.beans.plugins.PluginRegistryBean in project apiman by apiman.
the class PluginResourceImpl method getAvailablePlugins.
/**
* @see IPluginResource#getAvailablePlugins()
*/
@Override
public List<PluginSummaryBean> getAvailablePlugins() throws NotAuthorizedException {
securityContext.checkAdminPermissions();
List<PluginSummaryBean> rval = new ArrayList<>();
Set<URI> registries = config.getPluginRegistries();
for (URI registryUrl : registries) {
PluginRegistryBean registry = loadRegistry(registryUrl);
if (registry == null) {
// $NON-NLS-1$
LOGGER.warn("Plugin registry failed to load: {0}", registryUrl);
} else {
rval.addAll(registry.getPlugins());
}
}
// Sort before returning
rval.sort((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
return rval;
}
Aggregations