当前位置: 首页>>代码示例>>Java>>正文


Java Group.getUsers方法代码示例

本文整理汇总了Java中gov.nih.nci.security.authorization.domainobjects.Group.getUsers方法的典型用法代码示例。如果您正苦于以下问题:Java Group.getUsers方法的具体用法?Java Group.getUsers怎么用?Java Group.getUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gov.nih.nci.security.authorization.domainobjects.Group的用法示例。


在下文中一共展示了Group.getUsers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assignUsersToGroup

import gov.nih.nci.security.authorization.domainobjects.Group; //导入方法依赖的package包/类
/**
 * add a multiple users from a group. This method is a partial replacement for
 * {@link AuthorizationManager#assignUsersToGroup(java.lang.String, java.lang.String[])} to ensure that groups are
 * loaded using the caArray (audited) Hibernate session. Does not demarcate transactions; should be called from a
 * service layer.
 * 
 * @param groupId the CSM group Id to add the users to.
 * @param userIds the CSM user Ids to add to the group.
 * @throws CSTransactionException if a hibernate exception occures.
 */
@SuppressWarnings("unchecked")
public static void assignUsersToGroup(Long groupId, Set<Long> userIds) throws CSTransactionException {
    try {
        final Session s = hibernateHelper.getCurrentSession();
        final Group group = (Group) s.load(Group.class, groupId);
        if (group.getUsers() == null) {
            group.setUsers(new HashSet<User>(userIds.size()));
        }
        for (final Long uId : userIds) {
            final User u = (User) s.load(User.class, uId);
            group.getUsers().add(u);
        }
        s.update(group);
    } catch (final HibernateException e) {
        throw new CSTransactionException(e);
    }
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:28,代码来源:SecurityUtils.java

示例2: getUsers

import gov.nih.nci.security.authorization.domainobjects.Group; //导入方法依赖的package包/类
/**
 * get all users belonging in the group identified by it's Id. This method is a partial replacement for
 * {@link AuthorizationManager#getUsers(java.lang.String)} to ensure that groups are loaded using the caArray
 * (audited) Hibernate session. Does not demarcate transactions; should be called from a service layer.
 * 
 * @param groupId CSM group id.
 * @return list of members.
 * @throws CSTransactionException if a hibernate exception occures.
 */
public static Set<User> getUsers(Long groupId) throws CSTransactionException {
    try {
        final Session s = hibernateHelper.getCurrentSession();
        final Group group = (Group) s.load(Group.class, groupId);
        @SuppressWarnings("unchecked")
        Set<User> us = group.getUsers();
        if (us == null) {
            us = Collections.emptySet();
        }
        return us;
    } catch (final HibernateException e) {
        throw new CSTransactionException(e);
    }
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:24,代码来源:SecurityUtils.java

示例3: testAddUsersToCollaboratorGroup

import gov.nih.nci.security.authorization.domainobjects.Group; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testAddUsersToCollaboratorGroup() throws CSTransactionException, CSObjectNotFoundException {
    final CollaboratorGroup created = this.permissionsManagementService.create(TEST);
    this.permissionsManagementService.addUsers(created, Arrays.asList(3L, 2L, 1L));
    final Group g = (Group) hibernateHelper.getCurrentSession().load(Group.class, created.getGroup().getGroupId());
    assertEquals(2, g.getUsers().size());
    for (final User u : (Set<User>) g.getUsers()) {
        assertTrue("caarrayuser".equals(u.getLoginName()) || "caarrayadmin".equals(u.getLoginName()));
    }
    assertEquals(TEST, g.getGroupName());
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:13,代码来源:PermissionsManagementServiceTest.java


注:本文中的gov.nih.nci.security.authorization.domainobjects.Group.getUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。