Search in sources :

Example 1 with PluginRegistryBean

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;
    }
}
Also used : PluginRegistryBean(io.apiman.manager.api.beans.plugins.PluginRegistryBean) IOException(java.io.IOException)

Example 2 with PluginRegistryBean

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;
}
Also used : PluginRegistryBean(io.apiman.manager.api.beans.plugins.PluginRegistryBean) ArrayList(java.util.ArrayList) URI(java.net.URI) PluginSummaryBean(io.apiman.manager.api.beans.summary.PluginSummaryBean)

Aggregations

PluginRegistryBean (io.apiman.manager.api.beans.plugins.PluginRegistryBean)2 PluginSummaryBean (io.apiman.manager.api.beans.summary.PluginSummaryBean)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1