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

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

Introduction

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

Prototype

String ACCESS_IN_CONTROL_PANEL

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

Click Source Link

Usage

From source file:com.liferay.announcements.web.internal.upgrade.v1_0_2.UpgradePermission.java

License:Open Source License

protected void addAnnouncementsAdminResourceActions() {
    addResourceAction(ActionKeys.ACCESS_IN_CONTROL_PANEL, _BITWISE_VALUE_ACCESS_IN_CONTROL_PANEL);
    addResourceAction(ActionKeys.VIEW, _BITWISE_VALUE_VIEW);
}

From source file:com.liferay.application.list.my.account.permissions.internal.PanelAppMyAccountPermissions.java

License:Open Source License

private void _initPermissions(long companyId, String portletId, String rootPortletId, Role userRole,
        List<String> actionIds) throws Exception {

    PortletPreferences portletPreferences = _portletPreferencesFactory.getLayoutPortletSetup(companyId,
            companyId, PortletKeys.PREFS_OWNER_TYPE_COMPANY, LayoutConstants.DEFAULT_PLID, portletId,
            PortletConstants.DEFAULT_PREFERENCES);

    if (_prefsProps.getBoolean(portletPreferences, "myAccountAccessInControlPanelPermissionsInitialized")) {

        return;//from w w w.j  a v a 2s . c  om
    }

    if (actionIds.contains(ActionKeys.ACCESS_IN_CONTROL_PANEL)) {
        _resourcePermissionLocalService.addResourcePermission(companyId, rootPortletId,
                ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), userRole.getRoleId(),
                ActionKeys.ACCESS_IN_CONTROL_PANEL);
    }

    portletPreferences.setValue("myAccountAccessInControlPanelPermissionsInitialized", StringPool.TRUE);

    portletPreferences.store();
}

From source file:com.liferay.application.list.my.account.permissions.test.PanelAppMyAccountPermissionsTest.java

License:Open Source License

private boolean _hasMyAccountPermission(long companyId, String portletId) throws Exception {

    Role userRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);

    return ResourcePermissionLocalServiceUtil.hasResourcePermission(companyId, portletId,
            ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), userRole.getRoleId(),
            ActionKeys.ACCESS_IN_CONTROL_PANEL);
}

From source file:com.liferay.exportimport.internal.staging.permission.StagingPermissionImpl.java

License:Open Source License

protected Boolean doHasPermission(PermissionChecker permissionChecker, Group group, String className,
        long classPK, String portletId, String actionId) throws Exception {

    if (!PropsValues.STAGING_LIVE_GROUP_LOCKING_ENABLED) {
        return null;
    }/*from ww w .  j ava2s  .  c o m*/

    if (!actionId.equals(ActionKeys.ACCESS) && !actionId.equals(ActionKeys.ACCESS_IN_CONTROL_PANEL)
            && !actionId.equals(ActionKeys.ADD_TO_PAGE) && !actionId.equals(ActionKeys.ASSIGN_MEMBERS)
            && !actionId.equals(ActionKeys.CONFIGURATION) && !actionId.equals(ActionKeys.CUSTOMIZE)
            && !actionId.equals(ActionKeys.DELETE) && !actionId.equals(ActionKeys.VIEW)
            && group.hasLocalOrRemoteStagingGroup()
            && (Validator.isNull(portletId) || group.isStagedPortlet(portletId))) {

        return false;
    } else {
        return null;
    }
}

From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java

License:Open Source License

public void updateActions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long roleId = ParamUtil.getLong(actionRequest, "roleId");

    Role role = _roleLocalService.getRole(roleId);

    String roleName = role.getName();

    if (roleName.equals(RoleConstants.ADMINISTRATOR)
            || roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR)
            || roleName.equals(RoleConstants.ORGANIZATION_OWNER) || roleName.equals(RoleConstants.OWNER)
            || roleName.equals(RoleConstants.SITE_ADMINISTRATOR) || roleName.equals(RoleConstants.SITE_OWNER)) {

        throw new RolePermissionsException(roleName);
    }//from w  w  w . jav a2  s. c  om

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");
    String[] relatedPortletResources = StringUtil
            .split(ParamUtil.getString(actionRequest, "relatedPortletResources"));
    String[] modelResources = StringUtil.split(ParamUtil.getString(actionRequest, "modelResources"));

    Map<String, List<String>> resourceActionsMap = new HashMap<>();

    if (Validator.isNotNull(portletResource)) {
        resourceActionsMap.put(portletResource, ResourceActionsUtil.getResourceActions(portletResource, null));
    }

    for (String relatedPortletResource : relatedPortletResources) {
        resourceActionsMap.put(relatedPortletResource,
                ResourceActionsUtil.getResourceActions(relatedPortletResource, null));
    }

    for (String modelResource : modelResources) {
        resourceActionsMap.put(modelResource, ResourceActionsUtil.getResourceActions(null, modelResource));
    }

    int rootResourceScope = ResourceConstants.SCOPE_COMPANY;
    String[] rootResourceGroupIds = null;

    String[] selectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "selectedTargets"));
    String[] unselectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "unselectedTargets"));

    for (Map.Entry<String, List<String>> entry : resourceActionsMap.entrySet()) {

        String selResource = entry.getKey();
        List<String> actions = entry.getValue();

        actions = ListUtil.sort(actions, new ActionComparator(themeDisplay.getLocale()));

        for (String actionId : actions) {
            String target = selResource + actionId;

            boolean selected = ArrayUtil.contains(selectedTargets, target);

            if (!selected && !ArrayUtil.contains(unselectedTargets, target)) {

                continue;
            }

            String[] groupIds = StringUtil.split(ParamUtil.getString(actionRequest, "groupIds" + target));

            groupIds = ArrayUtil.distinct(groupIds);

            int scope = ResourceConstants.SCOPE_COMPANY;

            if ((role.getType() == RoleConstants.TYPE_ORGANIZATION)
                    || (role.getType() == RoleConstants.TYPE_PROVIDER)
                    || (role.getType() == RoleConstants.TYPE_SITE)) {

                scope = ResourceConstants.SCOPE_GROUP_TEMPLATE;
            } else {
                if (groupIds.length > 0) {
                    scope = ResourceConstants.SCOPE_GROUP;
                }
            }

            updateAction(role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope,
                    groupIds);

            if (selected && actionId.equals(ActionKeys.ACCESS_IN_CONTROL_PANEL)) {

                updateViewControlPanelPermission(role, themeDisplay.getScopeGroupId(), selResource, scope,
                        groupIds);

                rootResourceScope = scope;
                rootResourceGroupIds = groupIds;
            }
        }
    }

    // LPS-38031

    if (rootResourceGroupIds != null) {
        updateViewRootResourcePermission(role, themeDisplay.getScopeGroupId(), portletResource,
                rootResourceScope, rootResourceGroupIds);
    }

    // Send redirect

    SessionMessages.add(actionRequest, "permissionsUpdated");

    String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

    if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
    }
}

From source file:com.liferay.trash.service.webserver.test.WebServerTrashTest.java

License:Open Source License

@Override
public void setUp() throws Exception {
    super.setUp();

    _user = UserTestUtil.addUser(null, group.getGroupId());

    String portletId = PortletProviderUtil.getPortletId(TrashEntry.class.getName(),
            PortletProvider.Action.VIEW);

    _role = RoleTestUtil.addRole("Trash Admin", RoleConstants.TYPE_REGULAR, portletId,
            ResourceConstants.SCOPE_COMPANY, String.valueOf(TestPropsValues.getCompanyId()),
            ActionKeys.ACCESS_IN_CONTROL_PANEL);

    RoleTestUtil.addResourcePermission(RoleConstants.GUEST, DLPermission.RESOURCE_NAME,
            ResourceConstants.SCOPE_GROUP_TEMPLATE, String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID),
            ActionKeys.VIEW);/*from w ww .jav a2s . com*/
}