Make code to list groups for a user reuasble from SSH commands

The motivation for this refactoring is to be able to implement in a
later change a new option for the 'ls-groups' command that allows to
list the groups for a specific user.

Change-Id: Ia5b2e330cb5a4f77ecd7de25d7d129417bf8376e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2011-11-21 09:43:49 +01:00
parent b908482375
commit a77f153b00
4 changed files with 40 additions and 52 deletions

View File

@@ -63,10 +63,14 @@ public class ListGroupsCommand extends BaseCommand {
final PrintWriter stdout = toPrintWriter(out);
try {
final VisibleGroups visibleGroups = visibleGroupsFactory.create();
visibleGroups.setProjects(projects);
visibleGroups.setOnlyVisibleToAll(visibleToAll);
visibleGroups.setGroupType(groupType);
final GroupList groupList = visibleGroups.get();
final GroupList groupList;
if (!projects.isEmpty()) {
groupList = visibleGroups.get(projects);
} else {
groupList = visibleGroups.get();
}
for (final GroupDetail groupDetail : groupList.getGroups()) {
stdout.print(groupDetail.group.getName() + "\n");
}