code: public CmsPermissionSetCustom getPermissions(CmsUser user, List<CmsGroup> groups, List<CmsRole> roles) {
  
          CmsPermissionSetCustom sum = new CmsPermissionSetCustom();
          boolean hasPermissions = false;
          CmsPermissionSet p = m_permissions.get(user.getId());
          if (p != null) {
              sum.addPermissions(p);
              hasPermissions = true;
          }
          if (groups != null) {
              int size = groups.size();
              for (int i = 0; i < size; i++) {
                  I_CmsPrincipal principal = groups.get(i);
                  p = m_permissions.get(principal.getId());
                  if (p != null) {
                      sum.addPermissions(p);
                      hasPermissions = true;
                  }
              }
          }
          if (roles != null) {
              int size = roles.size();
              for (int i = 0; i < size; i++) {
                  CmsRole role = roles.get(i);
                  p = m_permissions.get(role.getId());
                  if (p != null) {
                      sum.addPermissions(p);
                      hasPermissions = true;
                  }
              }
          }
          if (!hasPermissions) {
              // if no applicable entry is found check the 'all others' entry
              p = m_permissions.get(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID);
              if (p != null) {
                  sum.addPermissions(p);
              }
          }
          return sum;
      }
docs: Calculates the permissions of the given user and his groups from the access control list.<p>
  
  @param user the user
  @param groups the groups of this user
  @param roles the roles of this user
  
  @return the summarized permission set of the user