Example usage for com.liferay.portal.kernel.security.permission ActionKeys VIEW

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys VIEW

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys VIEW.

Prototype

String VIEW

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys VIEW.

Click Source Link

Usage

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public BlogsEntry getEntry(long groupId, String urlTitle) throws PortalException {

    BlogsEntry entry = blogsEntryLocalService.getEntry(groupId, urlTitle);

    BlogsEntryPermission.check(getPermissionChecker(), entry.getEntryId(), ActionKeys.VIEW);

    return entry;
}

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public List<BlogsEntry> getGroupsEntries(long companyId, long groupId, Date displayDate, int status, int max)
        throws PortalException {

    List<BlogsEntry> entries = new ArrayList<>();

    boolean listNotExhausted = true;

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0,
            new EntryDisplayDateComparator());

    if (status == WorkflowConstants.STATUS_ANY) {
        queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
    }/*from w  ww  . j  av a  2  s.c  o m*/

    while ((entries.size() < max) && listNotExhausted) {
        queryDefinition.setEnd(queryDefinition.getStart() + max);

        List<BlogsEntry> entryList = blogsEntryLocalService.getGroupsEntries(companyId, groupId, displayDate,
                queryDefinition);

        queryDefinition.setStart(queryDefinition.getStart() + max);

        listNotExhausted = (entryList.size() == max);

        for (BlogsEntry entry : entryList) {
            if (entries.size() >= max) {
                break;
            }

            if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) {

                entries.add(entry);
            }
        }
    }

    return entries;
}

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public List<BlogsEntry> getOrganizationEntries(long organizationId, Date displayDate, int status, int max)
        throws PortalException {

    List<BlogsEntry> entries = new ArrayList<>();

    boolean listNotExhausted = true;

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0,
            new EntryDisplayDateComparator());

    if (status == WorkflowConstants.STATUS_ANY) {
        queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
    }/*from  w ww  .j  a v a  2s .  c o  m*/

    while ((entries.size() < max) && listNotExhausted) {
        queryDefinition.setEnd(queryDefinition.getStart() + max);

        List<BlogsEntry> entryList = blogsEntryFinder.findByOrganizationId(organizationId, displayDate,
                queryDefinition);

        queryDefinition.setStart(queryDefinition.getStart() + max);

        listNotExhausted = (entryList.size() == max);

        for (BlogsEntry entry : entryList) {
            if (entries.size() >= max) {
                break;
            }

            if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) {

                entries.add(entry);
            }
        }
    }

    return entries;
}

From source file:com.liferay.blogs.service.permission.BlogsEntryPermission.java

License:Open Source License

public static boolean contains(PermissionChecker permissionChecker, BlogsEntry entry, String actionId) {

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.EDIT);

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, entry.getGroupId(),
            BlogsEntry.class.getName(), entry.getEntryId(), portletId, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }//  w ww.ja  va 2s  . c  om

    if (entry.isDraft() || entry.isScheduled()) {
        if (actionId.equals(ActionKeys.VIEW) && !contains(permissionChecker, entry, ActionKeys.UPDATE)) {

            return false;
        }
    } else if (entry.isPending()) {
        hasPermission = WorkflowPermissionUtil.hasPermission(permissionChecker, entry.getGroupId(),
                BlogsEntry.class.getName(), entry.getEntryId(), actionId);

        if (hasPermission != null) {
            return hasPermission.booleanValue();
        }
    }

    if (permissionChecker.hasOwnerPermission(entry.getCompanyId(), BlogsEntry.class.getName(),
            entry.getEntryId(), entry.getUserId(), actionId)) {

        return true;
    }

    return permissionChecker.hasPermission(entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(),
            actionId);
}

From source file:com.liferay.blogs.web.asset.BlogsEntryAssetRenderer.java

License:Open Source License

@Override
public boolean hasViewPermission(PermissionChecker permissionChecker) {
    return BlogsEntryPermission.contains(permissionChecker, _entry, ActionKeys.VIEW);
}

From source file:com.liferay.bookmarks.asset.BookmarksEntryAssetRenderer.java

License:Open Source License

@Override
public boolean hasViewPermission(PermissionChecker permissionChecker) {
    try {/* w  ww .j a v  a 2  s  .co m*/
        return BookmarksEntryPermissionChecker.contains(permissionChecker, _entry, ActionKeys.VIEW);
    } catch (Exception e) {
    }

    return true;
}

From source file:com.liferay.bookmarks.asset.BookmarksFolderAssetRenderer.java

License:Open Source License

@Override
public boolean hasViewPermission(PermissionChecker permissionChecker) throws PortalException {

    return BookmarksFolderPermissionChecker.contains(permissionChecker, _folder, ActionKeys.VIEW);
}

From source file:com.liferay.bookmarks.search.BookmarksEntryIndexer.java

License:Open Source License

@Override
public boolean hasPermission(PermissionChecker permissionChecker, String entryClassName, long entryClassPK,
        String actionId) throws Exception {

    return BookmarksEntryPermissionChecker.contains(permissionChecker, entryClassPK, ActionKeys.VIEW);
}

From source file:com.liferay.bookmarks.search.BookmarksFolderIndexer.java

License:Open Source License

@Override
public boolean hasPermission(PermissionChecker permissionChecker, String entryClassName, long entryClassPK,
        String actionId) throws Exception {

    BookmarksFolder folder = _bookmarksFolderLocalService.getFolder(entryClassPK);

    return BookmarksFolderPermissionChecker.contains(permissionChecker, folder, ActionKeys.VIEW);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksEntryServiceImpl.java

License:Open Source License

@Override
public BookmarksEntry getEntry(long entryId) throws PortalException {
    BookmarksEntryPermissionChecker.check(getPermissionChecker(), entryId, ActionKeys.VIEW);

    return bookmarksEntryLocalService.getEntry(entryId);
}