Example usage for com.liferay.portal.kernel.atom AtomRequestContext getIntParameter

List of usage examples for com.liferay.portal.kernel.atom AtomRequestContext getIntParameter

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.atom AtomRequestContext getIntParameter.

Prototype

public int getIntParameter(String name, int defaultValue);

Source Link

Usage

From source file:com.liferay.blogs.internal.atom.BlogsEntryAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<BlogsEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long groupId = atomRequestContext.getLongParameter("groupId");
    int status = WorkflowConstants.STATUS_APPROVED;

    int max = atomRequestContext.getIntParameter("max", SearchContainer.DEFAULT_DELTA);

    if (groupId > 0) {
        int page = atomRequestContext.getIntParameter("page");

        if (page == 0) {
            return _blogsEntryService.getGroupEntries(groupId, status, max);
        }/*from w ww  . j  av  a2s. co  m*/

        int count = _blogsEntryService.getGroupEntriesCount(groupId, new Date(), status);

        AtomPager atomPager = new AtomPager(page, max, count);

        AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

        return _blogsEntryService.getGroupEntries(groupId, new Date(), status, atomPager.getStart(),
                atomPager.getEnd() + 1);
    }

    long organizationId = atomRequestContext.getLongParameter("organizationId");

    if (organizationId > 0) {
        return _blogsEntryService.getOrganizationEntries(organizationId, new Date(), status, max);
    }

    long companyId = CompanyThreadLocal.getCompanyId();

    if (companyId > 0) {
        return _blogsEntryService.getCompanyEntries(companyId, new Date(), status, max);
    }

    return Collections.emptyList();
}

From source file:com.liferay.portlet.blogs.atom.BlogsEntryAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<BlogsEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long groupId = atomRequestContext.getLongParameter("groupId");
    int status = WorkflowConstants.STATUS_APPROVED;

    int max = atomRequestContext.getIntParameter("max", SearchContainer.DEFAULT_DELTA);

    if (groupId > 0) {
        int page = atomRequestContext.getIntParameter("page");

        if (page == 0) {
            return BlogsEntryServiceUtil.getGroupEntries(groupId, status, max);
        }/*w w w.j a  v  a2 s  .com*/

        int count = BlogsEntryServiceUtil.getGroupEntriesCount(groupId, new Date(), status);

        AtomPager atomPager = new AtomPager(page, max, count);

        AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

        return BlogsEntryServiceUtil.getGroupEntries(groupId, new Date(), status, atomPager.getStart(),
                atomPager.getEnd() + 1);
    }

    long organizationId = atomRequestContext.getLongParameter("organizationId");

    if (organizationId > 0) {
        return BlogsEntryServiceUtil.getOrganizationEntries(organizationId, new Date(), status, max);
    }

    long companyId = CompanyThreadLocal.getCompanyId();

    if (companyId > 0) {
        return BlogsEntryServiceUtil.getCompanyEntries(companyId, new Date(), status, max);
    }

    return Collections.emptyList();
}