Package org.gatein.api.common

Examples of org.gatein.api.common.Pagination


        return p;
    }

    @Override
    public List<Page> findPages(PageQuery query) {
        Pagination pagination = query.getPagination();
        Iterator<PageContext> iterator;
        if (pagination == null) {
            if (query.getSiteType() == null || query.getSiteName() == null)
                throw new IllegalArgumentException("Pagination is required when site type or site name is null.");

            SiteKey siteKey = Util.from(new SiteId(query.getSiteType(), query.getSiteName()));
            if (pageService instanceof PageServiceImpl) {
                iterator = ((PageServiceImpl) pageService).loadPages(siteKey).iterator();
            } else if (pageService instanceof PageServiceWrapper) {
                iterator = ((PageServiceWrapper) pageService).loadPages(siteKey).iterator();
            } else {
                throw new RuntimeException("Unable to retrieve all pages for " + siteKey);
            }
        } else {
            QueryResult<PageContext> result = pageService.findPages(pagination.getOffset(), pagination.getLimit(),
                Util.from(query.getSiteType()), query.getSiteName(), null, query.getDisplayName());

            iterator = result.iterator();
        }
View Full Code Here


        return new PageManagementResource(portal, modelProvider, siteId);
    }

    private ModelList _getSites(SiteQuery query, PathAddress address, String emptySitesParam, String offsetParam, String limitParam) {
        boolean emptySites = Boolean.valueOf(emptySitesParam);
        Pagination pagination = getPagination(offsetParam, limitParam, query.getPagination());
        query = new SiteQuery.Builder().from(query).includeEmptySites(emptySites).withPagination(pagination).build();

        // Query sites
        List<Site> sites = portal.findSites(query);
        return populateModel(sites, modelProvider.newModel(ModelList.class), address);
View Full Code Here

    public static Pagination getPagination(String offsetParam, String limitParam, Pagination pagination) {
        if (offsetParam != null) {
            try {
                int offset = Integer.parseInt(offsetParam);
                pagination = new Pagination(offset, pagination.getLimit());
            } catch (NumberFormatException nfe) {
                throw invalidRequestParameter("offset", offsetParam);
            }
        }
        if (limitParam != null) {
            try {
                int limit = Integer.parseInt(limitParam);
                pagination = new Pagination(pagination.getOffset(), limit);
            } catch (NumberFormatException nfe) {
                throw invalidRequestParameter("limit", limitParam);
            }
        }
View Full Code Here

    @Managed(description = "Retrieves all pages for given site")
    public ModelList getPages(@ManagedContext PathAddress address,
                              @MappedAttribute("offset") String offsetParam,
                              @MappedAttribute("limit") String limitParam) {
        Pagination pagination = getPagination(offsetParam, limitParam, pagesQuery.getPagination());
        List<Page> pages = portal.findPages(new PageQuery.Builder().from(pagesQuery).withPagination(pagination).build());

        // Populate model
        return populateModel(pages, modelProvider.newModel(ModelList.class), address);
    }
View Full Code Here

TOP

Related Classes of org.gatein.api.common.Pagination

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.