use of org.jbei.ice.storage.model.RemoteClientModel in project ice by JBEI.
the class Groups method getGroupMembers.
/**
* Retrieves both local and remote members of the specified group if the user making the request
* has the appropriate permissions
*
* @param groupId unique local identifier of group
* @return information about specified group including remote and local members
* @throws PermissionException if the user does not have read permissions
*/
public UserGroup getGroupMembers(long groupId) {
Group group = dao.get(groupId);
if (group == null)
return null;
if (group.getType() == GroupType.PUBLIC) {
if (!accountController.isAdministrator(userId))
throw new PermissionException("Administrative privileges required");
} else if (!userId.equalsIgnoreCase(group.getOwner().getEmail())) {
Account account = accountDAO.getByEmail(this.userId);
if (account.getType() != AccountType.ADMIN)
throw new PermissionException("Missing required permissions");
}
UserGroup userGroup = group.toDataTransferObject();
for (Account account : group.getMembers()) {
userGroup.getMembers().add(account.toDataTransferObject());
}
// get remote members
List<RemoteClientModel> clients = remoteClientModelDAO.getClientsForGroup(group);
for (RemoteClientModel clientModel : clients) {
userGroup.getRemoteMembers().add(clientModel.toDataTransferObject());
}
return userGroup;
}
Aggregations