@Override
    protected void addStageInformation(@Nonnull final SessionData data, Element command) {
        final Locale preferredLocale = SessionManager.getInstance().getLocaleForSession(data.getOwner());

        DataForm form = new DataForm(DataForm.Type.form);
        if (data.getStage() == 0) {
            form.setTitle(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage0.title", preferredLocale));
            form.addInstruction(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage0.instruction", preferredLocale));

            FormField field = form.addField();
            field.setType(FormField.Type.hidden);
            field.setVariable("FORM_TYPE");
            field.addValue("http://jabber.org/protocol/admin");

            field = form.addField();
            field.setType(FormField.Type.text_single);
            field.setLabel(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage0.field.group.label", preferredLocale));
            field.setVariable("group");
            field.setRequired(true);
        }
        else
        {
            // Check if groups cannot be modified (backend is read-only)
            if (GroupManager.getInstance().isReadOnly()) {
                Element note = command.addElement("note");
                note.addAttribute("type", "error");
                note.setText(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.note.groups-readonly", preferredLocale));
                return;
            }
            // Get requested group
            Group group;
            try {
                group = GroupManager.getInstance().getGroup(data.getData().get("group").get(0));
            } catch (GroupNotFoundException e) {
                // Group not found
                Element note = command.addElement("note");
                note.addAttribute("type", "error");
                note.setText(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.note.group-does-not-exist", preferredLocale));
                return;
            }

            form.setTitle(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.title", preferredLocale));
            form.addInstruction(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.instruction", preferredLocale));

            FormField field = form.addField();
            field.setType(FormField.Type.hidden);
            field.setVariable("FORM_TYPE");
            field.addValue("http://jabber.org/protocol/admin");

            field = form.addField();
            field.setType(FormField.Type.text_multi);
            field.setLabel(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.desc.label", preferredLocale));
            field.setVariable("desc");
            if (group.getDescription() != null) {
                field.addValue(group.getDescription());
            }

            field = form.addField();
            field.setType(FormField.Type.list_single);
            field.setLabel(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.showinroster.label", preferredLocale));
            field.setVariable("showInRoster");
            field.addOption(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.showinroster.option.nobody.label", preferredLocale), "nobody");
            field.addOption(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.showinroster.option.everybody.label", preferredLocale), "everybody");
            field.addOption(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.showinroster.option.onlygroup.label", preferredLocale), "onlyGroup");
            field.addOption(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.showinroster.option.spefgroups.label", preferredLocale), "spefgroups");
            field.setRequired(true);
            if (group.getSharedWith() != null) {
                final String showInRoster;
                switch (group.getSharedWith()) {
                    case nobody:
                        showInRoster = "nobody";
                        break;
                    case everybody:
                        showInRoster = "everybody";
                        break;
                    case usersOfGroups:
                        final List<String> sharedWith = group.getSharedWithUsersInGroupNames();
                        if (sharedWith.isEmpty() || (sharedWith.size() == 1 && sharedWith.contains(group.getName()))) {
                            showInRoster = "onlyGroup";
                        } else {
                            showInRoster = "spefgroups";
                        }
                        break;
                    default:
                        showInRoster = group.getSharedWith().toString();
                        break;
                }
                field.addValue(showInRoster);
            } else {
                field.addValue("nobody");
            }

            field = form.addField();
            field.setType(FormField.Type.list_multi);
            field.setVariable("groupList");
            for (Group otherGroup : GroupManager.getInstance().getGroups()) {
                field.addOption(otherGroup.getName(), otherGroup.getName());
            }
            final List<String> groupList = group.getSharedWithUsersInGroupNames();
            for (final String othergroup : groupList) {
                field.addValue(othergroup);
            }

            field = form.addField();
            field.setType(FormField.Type.text_single);
            field.setLabel(LocaleUtils.getLocalizedString("commands.admin.group.updategroup.form.stage1.field.displayname.label", preferredLocale));
            field.setVariable("displayName");
            String displayName = group.getSharedDisplayName();
            if (displayName != null) {
                field.addValue(displayName);
            }
        }

        // Add the form to the command
        command.add(form.getElement());
    }
Command that allows to update a given group.

@author Gaston Dombiak
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/group/UpdateGroup.java