Example usage for com.liferay.portal.atom AtomPager getEnd

List of usage examples for com.liferay.portal.atom AtomPager getEnd

Introduction

In this page you can find the example usage for com.liferay.portal.atom AtomPager getEnd.

Prototype

public int getEnd() 

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  a va 2  s .c  o 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.document.library.internal.atom.FileEntryAtomCollectionAdapter.java

License:Open Source License

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

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

    long repositoryId = 0;

    if (folderId != 0) {
        Folder folder = _dlAppService.getFolder(folderId);

        repositoryId = folder.getRepositoryId();
    } else {/*from ww  w. j a v  a 2  s .  co m*/
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = _dlAppService.getFileEntriesCount(repositoryId, folderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return _dlAppService.getFileEntries(repositoryId, folderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new RepositoryModelTitleComparator<FileEntry>());
}

From source file:com.liferay.document.library.internal.atom.FolderAtomCollectionAdapter.java

License:Open Source License

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

    long repositoryId = 0L;

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

    if (parentFolderId != 0) {
        Folder parentFolder = _dlAppService.getFolder(parentFolderId);

        repositoryId = parentFolder.getRepositoryId();
    } else {/*from  w w w .ja va  2s  .c o m*/
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = _dlAppService.getFoldersCount(repositoryId, parentFolderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return _dlAppService.getFolders(repositoryId, parentFolderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new FolderNameComparator());
}

From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

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

    List<JournalArticle> journalArticles = new ArrayList<>();

    long companyId = CompanyThreadLocal.getCompanyId();
    long groupId = atomRequestContext.getLongParameter("groupId");

    if ((companyId <= 0) || (groupId <= 0)) {
        return journalArticles;
    }//from  ww  w  .ja va  2 s . c o  m

    List<Long> folderIds = Collections.emptyList();
    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String ddmStructureKey = null;
    String ddmTemplateKey = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator<JournalArticle> obc = new ArticleVersionComparator();

    int count = _journalArticleService.searchCount(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = _journalArticleService.search(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}

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);
        }//from   w w  w.  j  a v a  2s. c  o  m

        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();
}

From source file:com.liferay.portlet.documentlibrary.atom.FileEntryAtomCollectionAdapter.java

License:Open Source License

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

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

    long repositoryId = 0;

    if (folderId != 0) {
        Folder folder = DLAppServiceUtil.getFolder(folderId);

        repositoryId = folder.getRepositoryId();
    } else {//w ww .j a v  a2 s  . c om
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = DLAppServiceUtil.getFileEntriesCount(repositoryId, folderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return DLAppServiceUtil.getFileEntries(repositoryId, folderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new EntryNameComparator());
}

From source file:com.liferay.portlet.documentlibrary.atom.FolderAtomCollectionAdapter.java

License:Open Source License

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

    long repositoryId = 0;

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

    if (parentFolderId != 0) {
        Folder parentFolder = DLAppServiceUtil.getFolder(parentFolderId);

        repositoryId = parentFolder.getRepositoryId();
    } else {//from www. j a  va  2  s  . c o  m
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = DLAppServiceUtil.getFoldersCount(repositoryId, parentFolderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return DLAppServiceUtil.getFolders(repositoryId, parentFolderId, atomPager.getStart(),
            atomPager.getEnd() + 1, new EntryNameComparator());
}

From source file:com.liferay.portlet.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

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

    List<JournalArticle> journalArticles = new ArrayList<JournalArticle>();

    long companyId = CompanyThreadLocal.getCompanyId();
    long groupId = atomRequestContext.getLongParameter("groupId");

    if ((companyId <= 0) || (groupId <= 0)) {
        return journalArticles;
    }/*from w w  w. j  a  v a  2s  .c o  m*/

    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String type = atomRequestContext.getParameter("type", "general");
    String structureId = null;
    String templateId = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator obc = new ArticleVersionComparator();

    int count = JournalArticleLocalServiceUtil.searchCount(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = JournalArticleLocalServiceUtil.search(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}

From source file:com.liferay.portlet.usersadmin.atom.UserAtomCollectionAdapter.java

License:Open Source License

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

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

    if (groupId > 0) {
        List<User> users = UserLocalServiceUtil.getGroupUsers(groupId);

        return users;
    }//from ww w  . ja v  a  2  s .c om

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

    if (organizationId > 0) {
        List<User> users = UserLocalServiceUtil.getOrganizationUsers(organizationId);

        return users;
    }

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

    if (userGroupId > 0) {
        List<User> users = UserLocalServiceUtil.getUserGroupUsers(userGroupId);

        return users;
    }

    long companyId = CompanyThreadLocal.getCompanyId();

    if (companyId > 0) {
        int usersCount = UserLocalServiceUtil.getCompanyUsersCount(companyId);

        AtomPager atomPager = new AtomPager(atomRequestContext, usersCount);

        AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

        List<User> users = UserLocalServiceUtil.getCompanyUsers(companyId, atomPager.getStart(),
                atomPager.getEnd() + 1);

        return users;
    }

    return Collections.emptyList();
}