private void updateGroups() {
        if (user != null) {
            groups = new HashMap<>();
            groupIdNameMap = new HashMap<>();
            //get their groups
            ArrayList<Integer> temp = user.getGroups();

            if (temp != null) {
                groupNames = new String[temp.size()];
                Group f;

                for (int i = 0; i < groupNames.length; ++i) {
                    //get the group
                    f = (Group) MongoHelper.fetch(new Group(temp.get(i)),
                            MongoHelper.GROUP_COLLECTION);
                    //record the name
                    //System.out.println(f);
                    if (f != null) {
                        groupNames[i] = f.getName();
                        //store it in the map
                        groups.put(f.getName(), f);
                        groupIdNameMap.put(f.getId(), f.getName());
                    }
                }

                //sort
                if (groupNames.length > 1) {
                    Arrays.sort(groupNames);
                }
            }
        }
    }