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

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

Introduction

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

Prototype

String ADD_TO_PAGE

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

Click Source Link

Usage

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   w  w w. ja v  a2s.  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:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java

License:Open Source License

protected void checkAddUserPermission(long creatorUserId, long companyId, String emailAddress, long[] groupIds,
        long[] organizationIds, long[] roleIds, long[] userGroupIds, ServiceContext serviceContext)
        throws PortalException {

    Company company = CompanyLocalServiceUtil.getCompany(companyId);

    // Check if user has an according right assigned with add user permission; Either he owns the right itself, by his roles or by his user roles
    User creator = this.getGuestOrUser();

    long[] userIds = new long[] { creatorUserId };

    // Adding user must be member of everything he adds
    ServicePermissionUtil.checkMembership(userIds, groupIds, organizationIds, roleIds, userGroupIds);

    if (groupIds != null && groupIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_TO_PAGE);
        angularGroupService.checkGroups(0, groupIds);
    }/*from   w  w  w.  j a  va  2s . c o  m*/

    if (organizationIds != null && organizationIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ORGANIZATION);
        angularOrganizationService.checkOrganizations(0, organizationIds);
    }

    if (roleIds != null && roleIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ROLE);
        angularRoleService.checkRoles(0, roleIds);
    }

    if (userGroupIds != null && userGroupIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_USER_GROUP);
        angularUserGroupService.checkUserGroupIds(0, userGroupIds);
    }

    boolean anonymousUser = ParamUtil.getBoolean(serviceContext, "anonymousUser");

    long defaultUserId = userLocalService.getDefaultUserId(companyId);

    if (((creatorUserId != 0) && (creatorUserId != defaultUserId))
            || (!company.isStrangers() && !anonymousUser)) {
        ServicePermissionUtil.checkAllPersonalPermissions(creator, ActionKeys.ADD_USER, companyId,
                getPermissionChecker(), User.class.getName());
    }

    if ((creatorUserId == 0) || (creatorUserId == defaultUserId)) {
        if (!company.isStrangersWithMx() && company.hasCompanyMx(emailAddress)) {

            throw new UserEmailAddressException.MustNotUseCompanyMx(emailAddress);
        }
    }
}