code: public static IndexedContainer getGroupsOfUser(
          CmsObject cms,
          CmsUser user,
          String caption,
          String iconProp,
          String ou,
          String propStatus,
          Function<CmsGroup, CmsCssIcon> iconProvider) {
  
          IndexedContainer container = new IndexedContainer();
          container.addContainerProperty(caption, String.class, "");
          container.addContainerProperty(ou, String.class, "");
          container.addContainerProperty(propStatus, Boolean.class, new Boolean(true));
          if (iconProvider != null) {
              container.addContainerProperty(iconProp, CmsCssIcon.class, null);
          }
          try {
              for (CmsGroup group : cms.getGroupsOfUser(user.getName(), true)) {
                  Item item = container.addItem(group);
                  item.getItemProperty(caption).setValue(group.getSimpleName());
                  item.getItemProperty(ou).setValue(group.getOuFqn());
                  if (iconProvider != null) {
                      item.getItemProperty(iconProp).setValue(iconProvider.apply(group));
                  }
              }
          } catch (CmsException e) {
              LOG.error("Unable to read groups from user", e);
          }
          return container;
      }
docs: Gets container with alls groups of a certain user.
  
  @param cms cmsobject
  @param user to find groups for
  @param caption caption property
  @param iconProp property
  @param ou ou
  @param propStatus status property
  @param iconProvider the icon provider
  @return Indexed Container