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.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article matching the resource primary key,
 * preferring articles with approved workflow status.
 *
 * @param  resourcePrimKey the primary key of the resource instance
 * @return the latest web content article matching the resource primary key,
 *         preferring articles with approved workflow status
 *//*from w  ww .ja v a2 s .  co m*/
@Override
public JournalArticle getLatestArticle(long resourcePrimKey) throws PortalException {

    JournalArticlePermission.check(getPermissionChecker(), resourcePrimKey, ActionKeys.VIEW);

    return journalArticleLocalService.getLatestArticle(resourcePrimKey);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article matching the group, article ID,
 * and workflow status./*w  w  w  .j  av a  2 s  .  com*/
 *
 * @param  groupId the primary key of the web content article's group
 * @param  articleId the primary key of the web content article
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @return the latest matching web content article
 */
@Override
public JournalArticle getLatestArticle(long groupId, String articleId, int status) throws PortalException {

    JournalArticlePermission.check(getPermissionChecker(), groupId, articleId, status, ActionKeys.VIEW);

    return journalArticleLocalService.getLatestArticle(groupId, articleId, status);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article matching the group, class name ID,
 * and class PK.//from   ww w .  ja  v  a 2s . c  o m
 *
 * @param  groupId the primary key of the web content article's group
 * @param  className the DDMStructure class name if the web content article
 *         is related to a DDM structure, the class name associated with the
 *         article, or JournalArticleConstants.CLASSNAME_ID_DEFAULT in the
 *         journal-api module otherwise
 * @param  classPK the primary key of the DDM structure, if the DDMStructure
 *         class name is given as the <code>className</code> parameter, the
 *         primary key of the class associated with the web content article,
 *         or <code>0</code> otherwise
 * @return the latest matching web content article
 */
@Override
public JournalArticle getLatestArticle(long groupId, String className, long classPK) throws PortalException {

    JournalArticle article = journalArticleLocalService.getLatestArticle(groupId, className, classPK);

    JournalArticlePermission.check(getPermissionChecker(), groupId, article.getArticleId(),
            article.getVersion(), ActionKeys.VIEW);

    return article;
}

From source file:com.liferay.journal.service.impl.JournalFeedServiceImpl.java

License:Open Source License

@Override
public JournalFeed getFeed(long feedId) throws PortalException {
    JournalFeedPermission.check(getPermissionChecker(), feedId, ActionKeys.VIEW);

    return journalFeedLocalService.getFeed(feedId);
}

From source file:com.liferay.journal.service.impl.JournalFeedServiceImpl.java

License:Open Source License

@Override
public JournalFeed getFeed(long groupId, String feedId) throws PortalException {

    JournalFeedPermission.check(getPermissionChecker(), groupId, feedId, ActionKeys.VIEW);

    return journalFeedLocalService.getFeed(groupId, feedId);
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

@Override
public JournalFolder fetchFolder(long folderId) throws PortalException {
    JournalFolder folder = journalFolderLocalService.fetchFolder(folderId);

    if (folder != null) {
        JournalFolderPermission.check(getPermissionChecker(), folder, ActionKeys.VIEW);
    }/*from w w w .ja v  a  2  s  .c  o  m*/

    return folder;
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

@Override
public JournalFolder getFolder(long folderId) throws PortalException {
    JournalFolder folder = journalFolderLocalService.getFolder(folderId);

    JournalFolderPermission.check(getPermissionChecker(), folder, ActionKeys.VIEW);

    return folder;
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

@Override
public List<Long> getFolderIds(long groupId, long folderId) throws PortalException {

    JournalFolderPermission.check(getPermissionChecker(), groupId, folderId, ActionKeys.VIEW);

    List<Long> folderIds = getSubfolderIds(groupId, folderId, true);

    folderIds.add(0, folderId);/*  w  w  w.ja va2s  .c  om*/

    return folderIds;
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

protected List<DDMStructure> filterStructures(List<DDMStructure> ddmStructures) throws PortalException {

    PermissionChecker permissionChecker = getPermissionChecker();

    ddmStructures = ListUtil.copy(ddmStructures);

    Iterator<DDMStructure> itr = ddmStructures.iterator();

    while (itr.hasNext()) {
        DDMStructure ddmStructure = itr.next();

        if (!DDMStructurePermission.contains(permissionChecker, ddmStructure, ActionKeys.VIEW)) {

            itr.remove();//from   w  w  w  .ja v  a2 s.  c om
        }
    }

    return ddmStructures;
}

From source file:com.liferay.journal.service.permission.JournalArticlePermission.java

License:Open Source License

private static boolean _contains(PermissionChecker permissionChecker, JournalArticle article, String actionId) {

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

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, article.getGroupId(),
            JournalArticle.class.getName(), article.getResourcePrimKey(), portletId, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }//from   ww  w  .  j  a  v a2  s.  co m

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

            return false;
        }
    } else if (article.isPending()) {
        hasPermission = WorkflowPermissionUtil.hasPermission(permissionChecker, article.getGroupId(),
                JournalArticle.class.getName(), article.getResourcePrimKey(), actionId);

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

    if (actionId.equals(ActionKeys.VIEW)) {
        JournalServiceConfiguration journalServiceConfiguration = null;

        try {
            journalServiceConfiguration = _configurationProvider.getCompanyConfiguration(
                    JournalServiceConfiguration.class, permissionChecker.getCompanyId());
        } catch (ConfigurationException ce) {
            _log.error("Unable to get journal service configuration for company "
                    + permissionChecker.getCompanyId(), ce);

            return false;
        }

        if (!journalServiceConfiguration.articleViewPermissionsCheckEnabled()) {

            return true;
        }

        if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
            long folderId = article.getFolderId();

            if (folderId == JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

                if (!JournalPermission.contains(permissionChecker, article.getGroupId(), actionId)) {

                    return false;
                }
            } else {
                JournalFolder folder = _journalFolderLocalService.fetchFolder(folderId);

                if (folder != null) {
                    if (!JournalFolderPermission.contains(permissionChecker, folder, ActionKeys.ACCESS)
                            && !JournalFolderPermission.contains(permissionChecker, folder, ActionKeys.VIEW)) {

                        return false;
                    }
                } else {
                    if (!article.isInTrash()) {
                        _log.error("Unable to get journal folder " + folderId);

                        return false;
                    }
                }
            }
        }
    }

    if (permissionChecker.hasOwnerPermission(article.getCompanyId(), JournalArticle.class.getName(),
            article.getResourcePrimKey(), article.getUserId(), actionId)) {

        return true;
    }

    return permissionChecker.hasPermission(article.getGroupId(), JournalArticle.class.getName(),
            article.getResourcePrimKey(), actionId);
}