コード例 #1
1
  protected List<Role> getGroupRoles(long groupId, String resourceName) throws PortalException {

    List<Role> roles = groupRolesMap.get(groupId);

    if (roles != null) {
      return roles;
    }

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    roles =
        ListUtil.copy(
            ResourceActionsUtil.getRoles(group.getCompanyId(), group, resourceName, null));

    Map<Team, Role> teamRoleMap = RoleLocalServiceUtil.getTeamRoleMap(groupId);

    for (Map.Entry<Team, Role> entry : teamRoleMap.entrySet()) {
      Team team = entry.getKey();
      Role teamRole = entry.getValue();

      teamRole.setName(PermissionExporter.ROLE_TEAM_PREFIX + team.getName());
      teamRole.setDescription(team.getDescription());

      roles.add(teamRole);
    }

    groupRolesMap.put(groupId, roles);

    return roles;
  }
コード例 #2
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Team newTeam = _persistence.create(pk);

    newTeam.setMvccVersion(RandomTestUtil.nextLong());

    newTeam.setCompanyId(RandomTestUtil.nextLong());

    newTeam.setUserId(RandomTestUtil.nextLong());

    newTeam.setUserName(RandomTestUtil.randomString());

    newTeam.setCreateDate(RandomTestUtil.nextDate());

    newTeam.setModifiedDate(RandomTestUtil.nextDate());

    newTeam.setGroupId(RandomTestUtil.nextLong());

    newTeam.setName(RandomTestUtil.randomString());

    newTeam.setDescription(RandomTestUtil.randomString());

    _teams.add(_persistence.update(newTeam));

    Team existingTeam = _persistence.findByPrimaryKey(newTeam.getPrimaryKey());

    Assert.assertEquals(existingTeam.getMvccVersion(), newTeam.getMvccVersion());
    Assert.assertEquals(existingTeam.getTeamId(), newTeam.getTeamId());
    Assert.assertEquals(existingTeam.getCompanyId(), newTeam.getCompanyId());
    Assert.assertEquals(existingTeam.getUserId(), newTeam.getUserId());
    Assert.assertEquals(existingTeam.getUserName(), newTeam.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingTeam.getCreateDate()),
        Time.getShortTimestamp(newTeam.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingTeam.getModifiedDate()),
        Time.getShortTimestamp(newTeam.getModifiedDate()));
    Assert.assertEquals(existingTeam.getGroupId(), newTeam.getGroupId());
    Assert.assertEquals(existingTeam.getName(), newTeam.getName());
    Assert.assertEquals(existingTeam.getDescription(), newTeam.getDescription());
  }