Search in sources :

Example 1 with ApiSummaryBean

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

the class EsMarshalling method unmarshallApiSummary.

/**
 * Unmarshals the given map source into a bean.
 * @param source the source
 * @return the API summary
 */
public static ApiSummaryBean unmarshallApiSummary(Map<String, Object> source) {
    if (source == null) {
        return null;
    }
    ApiSummaryBean bean = new ApiSummaryBean();
    bean.setOrganizationId(asString(source.get("organizationId")));
    bean.setOrganizationName(asString(source.get("organizationName")));
    bean.setId(asString(source.get("id")));
    bean.setName(asString(source.get("name")));
    bean.setDescription(asString(source.get("description")));
    bean.setCreatedOn(asDate(source.get("createdOn")));
    postMarshall(bean);
    return bean;
}
Also used : ApiSummaryBean(io.apiman.manager.api.beans.summary.ApiSummaryBean)

Example 2 with ApiSummaryBean

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

the class RestHelper method hideSensitiveDataFromApiSummaryBeanList.

/**
 * This method will hide sensitive data, such as created by, from the result
 *
 * @param apiSummaryBeans the summary beans
 * @return A list with beans without sensitive data
 */
public static List<ApiSummaryBean> hideSensitiveDataFromApiSummaryBeanList(List<ApiSummaryBean> apiSummaryBeans) {
    List<ApiSummaryBean> apis = new ArrayList<>();
    for (ApiSummaryBean apiSummaryBean : apiSummaryBeans) {
        ApiSummaryBean apiSummary = new ApiSummaryBean();
        apiSummary.setOrganizationId(apiSummaryBean.getOrganizationId());
        apiSummary.setOrganizationName(apiSummaryBean.getOrganizationName());
        apiSummary.setId(apiSummaryBean.getId());
        apiSummary.setName(apiSummaryBean.getName());
        apiSummary.setDescription(apiSummaryBean.getDescription());
        apiSummary.setImage(apiSummaryBean.getImage());
        apiSummary.setTags(apiSummaryBean.getTags());
        apis.add(apiSummary);
    }
    return apis;
}
Also used : ArrayList(java.util.ArrayList) ApiSummaryBean(io.apiman.manager.api.beans.summary.ApiSummaryBean)

Example 3 with ApiSummaryBean

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

the class EsStorage method getApisInOrgs.

/**
 * @see io.apiman.manager.api.core.IStorageQuery#getApisInOrgs(java.util.Set)
 */
@Override
public List<ApiSummaryBean> getApisInOrgs(Set<String> organizationIds) throws StorageException {
    @SuppressWarnings("nls") SearchSourceBuilder builder = new SearchSourceBuilder().sort(new FieldSortBuilder("organizationName.keyword").order(SortOrder.ASC)).sort(new FieldSortBuilder("name.keyword").order(SortOrder.ASC)).size(500);
    // $NON-NLS-1$
    TermsQueryBuilder query = QueryBuilders.termsQuery("organizationId", organizationIds.toArray(new String[organizationIds.size()]));
    builder.query(query);
    List<SearchHit> hits = listEntities(INDEX_MANAGER_POSTFIX_API, builder);
    List<ApiSummaryBean> rval = new ArrayList<>(hits.size());
    for (SearchHit hit : hits) {
        ApiSummaryBean bean = EsMarshalling.unmarshallApiSummary(hit.getSourceAsMap());
        rval.add(bean);
    }
    return rval;
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) TermsQueryBuilder(org.elasticsearch.index.query.TermsQueryBuilder) ArrayList(java.util.ArrayList) FieldSortBuilder(org.elasticsearch.search.sort.FieldSortBuilder) ApiSummaryBean(io.apiman.manager.api.beans.summary.ApiSummaryBean) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder)

Aggregations

ApiSummaryBean (io.apiman.manager.api.beans.summary.ApiSummaryBean)3 ArrayList (java.util.ArrayList)2 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