If someone have the same problem. I have overwritten/replaced the create method. I have copied the logic from the muc-room-edit-form.jsp. This works for me but no guarantee Maybe this will help someone…
MUCRoomEntity ob=…;
// Set the new configuration sending an IQ packet with an dataform
FormField field;
XDataFormImpl dataForm = new XDataFormImpl(DataForm.TYPE_SUBMIT);
field = new XFormFieldImpl(“FORM_TYPE”);
field.setType(FormField.TYPE_HIDDEN);
field.addValue(“http://jabber.org/protocol/muc#roomconfig”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_roomname”);
field.addValue(ob.getNaturalName());
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_roomdesc”);
field.addValue(ob.getDescription());
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_changesubject”);
field.addValue((!ob.isCanOccupantsChangeSubject()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_maxusers”);
field.addValue(ob.getMaxUsers() + “”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_presencebroadcast”);
if (ob.getBroadcastPresenceRoles().contains(“moderator”)) {
field.addValue(“moderator”);
}
if (ob.getBroadcastPresenceRoles().contains(“participant”)) {
field.addValue(“participant”);
}
if (ob.getBroadcastPresenceRoles().contains(“visitor”)) {
field.addValue(“visitor”);
}
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_publicroom”);
field.addValue((!ob.isPublicRoom()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_persistentroom”);
field.addValue((!ob.isPersistent()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_moderatedroom”);
field.addValue((!ob.isModerated()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_membersonly”);
field.addValue((!ob.isMembersOnly()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_allowinvites”);
field.addValue((!ob.isCanOccupantsInvite()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_passwordprotectedroom”);
field.addValue((ob.getPassword() == null) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_roomsecret”);
field.addValue(ob.getPassword());
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_whois”);
field.addValue(ob.isCanAnyoneDiscoverJID() ? “anyone” : “moderator”);
dataForm.addField(field);
field = new XFormFieldImpl(“muc#roomconfig_enablelogging”);
field.addValue((!ob.isLogEnabled()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“x-muc#roomconfig_reservednick”);
field.addValue((!ob.isLoginRestrictedToNickname()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“x-muc#roomconfig_canchangenick”);
field.addValue((!ob.isCanChangeNickname()) ? “0” : “1”);
dataForm.addField(field);
field = new XFormFieldImpl(“x-muc#roomconfig_registration”);
field.addValue((!ob.isRegistrationEnabled()) ? “0” : “1”);
dataForm.addField(field);
// Keep the existing list of admins
field = new XFormFieldImpl(“muc#roomconfig_roomadmins”);
for (String jid : ob.getAdmins()) {
field.addValue(new JID(jid).toString());
}
dataForm.addField(field);
// Keep the existing list of owners
field = new XFormFieldImpl(“muc#roomconfig_roomowners”);
// Set owner
JID owner = XMPPServer.getInstance().createJID(“admin”, null);
field.addValue(owner.toString());
dataForm.addField(field);
// update subject before sending IQ (to include subject with cluster
// update)
MUCRoom room = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(“con ference”)
.getChatRoom(ob.getRoomName().toLowerCase(), owner);
if (ob.getSubject() != null) {
// Change the subject of the room by sending a new message
Message message2 = new Message();
message2.setType(Message.Type.groupchat);
message2.setSubject(ob.getSubject());
message2.setFrom(room.getRole().getRoleAddress());
message2.setTo(room.getRole().getRoleAddress());
message2.setID(“local-only”);
room.changeSubject(message2, room.getRole());
}
// Create an IQ packet and set the dataform as the main fragment
IQ iq = new IQ(IQ.Type.set);
Element element = iq.setChildElement(“query”, “http://jabber.org/protocol/muc#owner”);
element.add(dataForm.asXMLElement());
// Send the IQ packet that will modify the room’s configuration
room.getIQOwnerHandler().handleIQ(iq, room.getRole());