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

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

Introduction

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

Prototype

String ADD_FOLDER

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

Click Source Link

Usage

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

License:Open Source License

@Override
public JournalFolder addFolder(long groupId, long parentFolderId, String name, String description,
        ServiceContext serviceContext) throws PortalException {

    JournalFolderPermission.check(getPermissionChecker(), groupId, parentFolderId, ActionKeys.ADD_FOLDER);

    return journalFolderLocalService.addFolder(getUserId(), groupId, parentFolderId, name, description,
            serviceContext);//from  w w  w.ja va  2 s  .c o  m
}

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

License:Open Source License

public static boolean contains(PermissionChecker permissionChecker, JournalFolder folder, String actionId) {

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

    if (actionId.equals(ActionKeys.ADD_FOLDER)) {
        actionId = ActionKeys.ADD_SUBFOLDER;
    }//from w  w w  .java 2  s  . co m

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, folder.getGroupId(),
            JournalFolder.class.getName(), folder.getFolderId(), portletId, actionId);

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

    if (actionId.equals(ActionKeys.VIEW) && PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {

        long folderId = folder.getFolderId();

        while (folderId != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            JournalFolder parentFolder = folder;

            folder = _journalFolderLocalService.fetchFolder(folderId);

            if (folder != null) {
                if (!_hasPermission(permissionChecker, folder, actionId)) {
                    return false;
                }
            } else {
                if (parentFolder.isInTrash()) {
                    folder = parentFolder;

                    break;
                } else {
                    _log.error("Unable to get journal folder " + folderId);

                    return false;
                }
            }

            folderId = folder.getParentFolderId();
        }

        return JournalPermission.contains(permissionChecker, folder.getGroupId(), actionId);
    }

    return _hasPermission(permissionChecker, folder, actionId);
}