Search in sources :

Example 1 with PluginSummaryBean

use of io.apiman.manager.api.beans.summary.PluginSummaryBean in project apiman by apiman.

the class EsMarshalling method unmarshallPluginSummary.

/**
 * Unmarshals the given map source into a bean.
 * @param map the search hit map
 * @return the plugin summary
 */
public static PluginSummaryBean unmarshallPluginSummary(Map<String, Object> map) {
    PluginSummaryBean bean = new PluginSummaryBean();
    bean.setId(asLong(map.get("id")));
    bean.setName(asString(map.get("name")));
    if (map.containsKey("description")) {
        bean.setDescription(asString(map.get("description")));
    }
    bean.setGroupId(asString(map.get("groupId")));
    bean.setArtifactId(asString(map.get("artifactId")));
    bean.setVersion(asString(map.get("version")));
    if (map.containsKey("type")) {
        bean.setType(asString(map.get("type")));
    }
    if (map.containsKey("classifier")) {
        bean.setClassifier(asString(map.get("classifier")));
    }
    bean.setCreatedBy(asString(map.get("createdBy")));
    bean.setCreatedOn(asDate(map.get("createdOn")));
    postMarshall(bean);
    return bean;
}
Also used : PluginSummaryBean(io.apiman.manager.api.beans.summary.PluginSummaryBean)

Example 2 with PluginSummaryBean

use of io.apiman.manager.api.beans.summary.PluginSummaryBean in project apiman by apiman.

the class EsStorage method listPlugins.

/**
 * @see io.apiman.manager.api.core.IStorageQuery#listPlugins()
 */
@Override
@SuppressWarnings("nls")
public List<PluginSummaryBean> listPlugins() throws StorageException {
    String[] fields = { "id", "artifactId", "groupId", "version", "classifier", "type", "name", "description", "createdBy", "createdOn" };
    QueryBuilder query = QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("deleted", false));
    SearchSourceBuilder builder = new SearchSourceBuilder().fetchSource(fields, null).query(query).sort(new FieldSortBuilder("name.keyword").order(SortOrder.ASC)).size(200);
    List<SearchHit> hits = listEntities(INDEX_MANAGER_POSTFIX_PLUGIN, builder);
    List<PluginSummaryBean> rval = new ArrayList<>(hits.size());
    for (SearchHit hit : hits) {
        PluginSummaryBean bean = EsMarshalling.unmarshallPluginSummary(hit.getSourceAsMap());
        rval.add(bean);
    }
    return rval;
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) ArrayList(java.util.ArrayList) FieldSortBuilder(org.elasticsearch.search.sort.FieldSortBuilder) TermsQueryBuilder(org.elasticsearch.index.query.TermsQueryBuilder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) PluginSummaryBean(io.apiman.manager.api.beans.summary.PluginSummaryBean)

Example 3 with PluginSummaryBean

use of io.apiman.manager.api.beans.summary.PluginSummaryBean 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

PluginSummaryBean (io.apiman.manager.api.beans.summary.PluginSummaryBean)3 ArrayList (java.util.ArrayList)2 PluginRegistryBean (io.apiman.manager.api.beans.plugins.PluginRegistryBean)1 URI (java.net.URI)1 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)1 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)1 TermsQueryBuilder (org.elasticsearch.index.query.TermsQueryBuilder)1 SearchHit (org.elasticsearch.search.SearchHit)1 SearchSourceBuilder (org.elasticsearch.search.builder.SearchSourceBuilder)1 FieldSortBuilder (org.elasticsearch.search.sort.FieldSortBuilder)1