Package com.liferay.portal.model

Examples of com.liferay.portal.model.Role


    if (group.getType() == GroupConstants.TYPE_COMMUNITY_OPEN) {
      UserLocalServiceUtil.addGroupUsers(
        group.getGroupId(), new long[] {themeDisplay.getUserId()});
    }
    else {
      Role role = RoleLocalServiceUtil.getRole(
        themeDisplay.getCompanyId(), "Community Administrator");

      LinkedHashMap<String, Object> userParams =
        new LinkedHashMap<String, Object>();

      userParams.put(
        "userGroupRole",
        new Long[] {new Long(group.getGroupId()),
        new Long(role.getRoleId())});

      List<User> users = UserLocalServiceUtil.search(
        themeDisplay.getCompanyId(), null, Boolean.TRUE, userParams,
        QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null);
View Full Code Here


      themeDisplay.getScopeGroupId());

    Organization organization =
      OrganizationLocalServiceUtil.getOrganization(group.getClassPK());

    Role role = RoleLocalServiceUtil.getRole(
      themeDisplay.getCompanyId(), "Organization Administrator");

    LinkedHashMap<String, Object> userParams =
      new LinkedHashMap<String, Object>();

    userParams.put(
      "userGroupRole",
      new Long[] {new Long(group.getGroupId()),
      new Long(role.getRoleId())});

    List<User> users = UserLocalServiceUtil.search(
      themeDisplay.getCompanyId(), null, Boolean.TRUE, userParams,
      QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null);
View Full Code Here

    ServiceContext serviceContext = new ServiceContext();

    // Regular roles

    for (String name : PortalUtil.getSystemRoles()) {
      Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);

      Map<Locale, String> descriptionMap = role.getDescriptionMap();
      Map<Locale, String> titleMap = role.getTitleMap();

      if (name.equals(RoleConstants.ADMINISTRATOR)) {
        _putMap(
          descriptionMap, languageId, ROLE_ADMINISTRATOR_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_ADMINISTRATOR_NAME);
      }
      else if (name.equals(RoleConstants.GUEST)) {
        _putMap(descriptionMap, languageId, ROLE_GUEST_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_GUEST_NAME);
      }
      else if (name.equals(RoleConstants.OWNER)) {
        _putMap(descriptionMap, languageId, ROLE_OWNER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_OWNER_NAME);
      }
      else if (name.equals(RoleConstants.POWER_USER)) {
        _putMap(
          descriptionMap, languageId, ROLE_POWER_USER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_POWER_USER_NAME);
      }
      else if (name.equals(RoleConstants.USER)) {
        _putMap(descriptionMap, languageId, ROLE_USER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_USER_NAME);
      }

      RoleLocalServiceUtil.updateRole(
        role.getRoleId(), name, titleMap, descriptionMap,
        RoleConstants.TYPE_REGULAR_LABEL, serviceContext);
    }

    // Organization roles

    for (String name : PortalUtil.getSystemOrganizationRoles()) {
      Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);

      Map<Locale, String> descriptionMap = role.getDescriptionMap();
      Map<Locale, String> titleMap = role.getTitleMap();

      if (name.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR)) {
        _putMap(
          descriptionMap, languageId,
          ROLE_ORGANIZATION_ADMINISTRATOR_DESCRIPTION);
        _putMap(
          titleMap, languageId, ROLE_ORGANIZATION_ADMINISTRATOR_NAME);
      }
      else if (name.equals(RoleConstants.ORGANIZATION_OWNER)) {
        _putMap(
          descriptionMap, languageId,
          ROLE_ORGANIZATION_OWNER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_ORGANIZATION_OWNER_NAME);
      }
      else if (name.equals(RoleConstants.ORGANIZATION_USER)) {
        _putMap(
          descriptionMap, languageId,
          ROLE_ORGANIZATION_USER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_ORGANIZATION_USER_NAME);
      }

      RoleLocalServiceUtil.updateRole(
        role.getRoleId(), name, titleMap, descriptionMap,
        RoleConstants.TYPE_ORGANIZATION_LABEL, serviceContext);
    }

    // Site roles

    for (String name : PortalUtil.getSystemSiteRoles()) {
      Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);

      Map<Locale, String> descriptionMap = role.getDescriptionMap();
      Map<Locale, String> titleMap = role.getTitleMap();

      if (name.equals(RoleConstants.SITE_ADMINISTRATOR)) {
        _putMap(
          descriptionMap, languageId,
          ROLE_SITE_ADMINISTRATOR_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_SITE_ADMINISTRATOR_NAME);
      }
      else if (name.equals(RoleConstants.SITE_MEMBER)) {
        _putMap(
          descriptionMap, languageId, ROLE_SITE_MEMBER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_SITE_MEMBER_NAME);
      }
      else if (name.equals(RoleConstants.SITE_OWNER)) {
        _putMap(
          descriptionMap, languageId, ROLE_SITE_OWNER_DESCRIPTION);
        _putMap(titleMap, languageId, ROLE_SITE_OWNER_NAME);
      }

      RoleLocalServiceUtil.updateRole(
        role.getRoleId(), name, titleMap, descriptionMap,
        RoleConstants.TYPE_SITE_LABEL, serviceContext);
    }
  }
View Full Code Here

    public static List<UserData> getUsersByRole(String roleName)
    {
        try
        {
          /* Search for role with given name */
          Role role = getRoleByName(roleName);
         
          List<User> liferayUsers = new ArrayList<User>();
         
          /* Get users with directly assigned role */
          liferayUsers.addAll(UserLocalServiceUtil.getRoleUsers(role.getRoleId()));
         
          /* Get user groups with assigned role */
          List<Group> liferayGroups = GroupLocalServiceUtil.getRoleGroups(role.getRoleId());
         
 
          for(Group liferayGroup: liferayGroups)
          {       
            /* Get all users from selected group. ClassPK is the id of the UserGroup instance
View Full Code Here

        /* Search for role in all companies. There is commonly only one company in system */
          long[] companyIds = PortalUtil.getCompanyIds();
          for (int i = 0; i < companyIds.length; ++i)
          {
            long companyId = companyIds[i];
            Role role = RoleLocalServiceUtil.getRole(companyId, roleName);
           
            if(role != null)
              return role;
          }
         
View Full Code Here

    public static boolean createRoleIfNotExists(String roleName, String description)
    {
      try
      {
        /* Look for the role with provided name */
          Role role = null;
          try
          {
            /* Look for the role with provided name */
            role = getRoleByName(roleName);
          }
          catch(RoleNotFoundException ex)
          {
        Map<Locale, String> titles = new HashMap<Locale,  String>();
        RoleLocalServiceUtil.addRole(0, PortalUtil.getDefaultCompanyId(), roleName, titles, description, RoleConstants.TYPE_REGULAR);
        return true;
          }

      /* Role found, maybe there is need to update description */
      if(description != null && !description.equals(role.getDescription()))
      {
        role.setDescription(description);
        RoleLocalServiceUtil.updateRole(role);
      }
      return false;
    }
    catch (Exception e)
View Full Code Here

          @Override
          public void setValues(PortletRequest portletRequest) {
            oldChecker.setValues(portletRequest);
          }
        });
        Role role = RoleServiceUtil.getRole(PortalUtil.getDefaultCompanyId(), liferayRoleName);
        if (role == null) return new HashSet<UserData>();
        long[] roleUserIds = UserServiceUtil.getRoleUserIds(role.getRoleId());
        HashSet<UserData> users = new HashSet<UserData>();
        for (long roleUserId : roleUserIds) {
          User userById = UserServiceUtil.getUserById(roleUserId);
          UserData ud = new UserData();
          ud.setLogin(userById.getLogin());
View Full Code Here

   */
  protected void setupPermissionChecker(long companyId) throws PortalException, SystemException {
    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    if (permissionChecker == null) {
      Role administratorRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
      User administratorUser = UserLocalServiceUtil.getRoleUsers(administratorRole.getRoleId()).get(0);

      try {
        permissionChecker = PermissionCheckerFactoryUtil.create(administratorUser);

        PermissionThreadLocal.setPermissionChecker(permissionChecker);
View Full Code Here

    }

    if (expandoColumn != null) {

      // Add permissions to the column so that all users can VIEW and UPDATE.
      Role userRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
      String resourceId = ExpandoColumn.class.getName();
      String primKey = String.valueOf(expandoColumn.getColumnId());
      String[] actionKeys = new String[] { ActionKeys.VIEW, ActionKeys.UPDATE };
      PermissionUtil.grantPermissions(companyId, userRole.getRoleId(), resourceId,
        ResourceConstants.SCOPE_INDIVIDUAL, primKey, actionKeys);
    }
  }
View Full Code Here

  }

  private static PermissionChecker getAdministratorPermissionChecker(long companyId) throws PortalException,
    SystemException {
    PermissionChecker administratorPermissionChecker = null;
    Role administratorRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
    List<User> administratorUsers = UserLocalServiceUtil.getRoleUsers(administratorRole.getRoleId());

    if ((administratorUsers != null) && (administratorUsers.size() > 0)) {

      User administratorUser = administratorUsers.get(0);
View Full Code Here

TOP

Related Classes of com.liferay.portal.model.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.