List of usage examples for org.dom4j QName get
public static QName get(String qualifiedName, String uri)
From source file:net.emiva.crossfire.plugin.muc.spi.IQMUCSearchHandler.java
License:Open Source License
/** * Utility method that returns a 'jabber:iq:search' child element filled * with a blank dataform.//from ww w . ja va 2s.c o m * * @return Element, named 'query', escaped by the 'jabber:iq:search' * namespace, filled with a blank dataform. */ private static Element getDataElement() { final DataForm searchForm = new DataForm(DataForm.Type.form); searchForm.setTitle("Chat Rooms Search"); searchForm.addInstruction("Instructions"); final FormField typeFF = searchForm.addField(); typeFF.setVariable("FORM_TYPE"); typeFF.setType(FormField.Type.hidden); typeFF.addValue("jabber:iq:search"); final FormField nameFF = searchForm.addField(); nameFF.setVariable("name"); nameFF.setType(FormField.Type.text_single); nameFF.setLabel("Name"); nameFF.setRequired(false); final FormField matchFF = searchForm.addField(); matchFF.setVariable("name_is_exact_match"); matchFF.setType(FormField.Type.boolean_type); matchFF.setLabel("Name must match exactly"); matchFF.setRequired(false); final FormField subjectFF = searchForm.addField(); subjectFF.setVariable("subject"); subjectFF.setType(FormField.Type.text_single); subjectFF.setLabel("Subject"); subjectFF.setRequired(false); final FormField userAmountFF = searchForm.addField(); userAmountFF.setVariable("num_users"); userAmountFF.setType(FormField.Type.text_single); userAmountFF.setLabel("Number of users"); userAmountFF.setRequired(false); final FormField maxUsersFF = searchForm.addField(); maxUsersFF.setVariable("num_max_users"); maxUsersFF.setType(FormField.Type.text_single); maxUsersFF.setLabel("Max number allowed of users"); maxUsersFF.setRequired(false); final FormField includePasswordProtectedFF = searchForm.addField(); includePasswordProtectedFF.setVariable("include_password_protected"); includePasswordProtectedFF.setType(FormField.Type.boolean_type); includePasswordProtectedFF.setLabel("Include password protected rooms"); includePasswordProtectedFF.setRequired(false); final Element probeResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:search")); probeResult.add(searchForm.getElement()); return probeResult; }
From source file:net.emiva.crossfire.plugin.muc.spi.IQMUCSearchHandler.java
License:Open Source License
/** * Constructs an answer on a IQ stanza that contains a search request. The * answer will be an IQ stanza of type 'result' or 'error'. * // ww w . j a v a 2s. c om * @param iq * The IQ stanza that is the search request. * @return An answer to the provided request. */ public IQ handleIQ(IQ iq) { final IQ reply = IQ.createResultIQ(iq); final Element formElement = iq.getChildElement().element(QName.get("x", "jabber:x:data")); if (formElement == null) { reply.setChildElement(getDataElement()); return reply; } // parse params from request. final DataForm df = new DataForm(formElement); boolean name_is_exact_match = false; String subject = null; int numusers = -1; int numaxusers = -1; boolean includePasswordProtectedRooms = true; final Set<String> names = new HashSet<String>(); for (final FormField field : df.getFields()) { if (field.getVariable().equals("name")) { names.add(field.getFirstValue()); } } final FormField matchFF = df.getField("name_is_exact_match"); if (matchFF != null) { final String b = matchFF.getFirstValue(); if (b != null) { name_is_exact_match = b.equals("1") || b.equalsIgnoreCase("true") || b.equalsIgnoreCase("yes"); } } final FormField subjectFF = df.getField("subject"); if (subjectFF != null) { subject = subjectFF.getFirstValue(); } try { final FormField userAmountFF = df.getField("num_users"); if (userAmountFF != null) { String value = userAmountFF.getFirstValue(); if (value != null && !"".equals(value)) { numusers = Integer.parseInt(value); } } final FormField maxUsersFF = df.getField("num_max_users"); if (maxUsersFF != null) { String value = maxUsersFF.getFirstValue(); if (value != null && !"".equals(value)) { numaxusers = Integer.parseInt(value); } } } catch (NumberFormatException e) { reply.setError(PacketError.Condition.bad_request); return reply; } final FormField includePasswordProtectedRoomsFF = df.getField("include_password_protected"); if (includePasswordProtectedRoomsFF != null) { final String b = includePasswordProtectedRoomsFF.getFirstValue(); if (b != null) { if (b.equals("0") || b.equalsIgnoreCase("false") || b.equalsIgnoreCase("no")) { includePasswordProtectedRooms = false; } } } // search for chatrooms matching the request params. final List<MUCRoom> mucs = new ArrayList<MUCRoom>(); for (MUCRoom room : mucService.getChatRooms()) { boolean find = false; if (names.size() > 0) { for (final String name : names) { if (name_is_exact_match) { if (name.equalsIgnoreCase(room.getNaturalLanguageName())) { find = true; break; } } else { if (room.getNaturalLanguageName().toLowerCase().indexOf(name.toLowerCase()) != -1) { find = true; break; } } } } if (subject != null && room.getSubject().toLowerCase().indexOf(subject.toLowerCase()) != -1) { find = true; } if (numusers > -1 && room.getParticipants().size() < numusers) { find = false; } if (numaxusers > -1 && room.getMaxUsers() < numaxusers) { find = false; } if (!includePasswordProtectedRooms && room.isPasswordProtected()) { find = false; } if (find && canBeIncludedInResult(room)) { mucs.add(room); } } final ResultSet<MUCRoom> searchResults = new ResultSetImpl<MUCRoom>(sortByUserAmount(mucs)); // See if the requesting entity would like to apply 'result set // management' final Element set = iq.getChildElement() .element(QName.get("set", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT)); final List<MUCRoom> mucrsm; // apply RSM only if the element exists, and the (total) results // set is not empty. final boolean applyRSM = set != null && !mucs.isEmpty(); if (applyRSM) { if (!ResultSet.isValidRSMRequest(set)) { reply.setError(Condition.bad_request); return reply; } try { mucrsm = searchResults.applyRSMDirectives(set); } catch (NullPointerException e) { final IQ itemNotFound = IQ.createResultIQ(iq); itemNotFound.setError(Condition.item_not_found); return itemNotFound; } } else { // if no rsm, all found rooms are part of the result. mucrsm = new ArrayList<MUCRoom>(searchResults); } final Element res = DocumentHelper.createElement(QName.get("query", "jabber:iq:search")); final DataForm resultform = new DataForm(DataForm.Type.result); boolean atLeastoneResult = false; for (MUCRoom room : mucrsm) { final Map<String, Object> fields = new HashMap<String, Object>(); fields.put("name", room.getNaturalLanguageName()); fields.put("subject", room.getSubject()); fields.put("num_users", room.getOccupantsCount()); fields.put("num_max_users", room.getMaxUsers()); fields.put("is_password_protected", room.isPasswordProtected()); fields.put("is_member_only", room.isMembersOnly()); fields.put("jid", room.getRole().getRoleAddress().toString()); resultform.addItemFields(fields); atLeastoneResult = true; } if (atLeastoneResult) { resultform.addReportedField("name", "Name", FormField.Type.text_single); resultform.addReportedField("subject", "Subject", FormField.Type.text_single); resultform.addReportedField("num_users", "Number of users", FormField.Type.text_single); resultform.addReportedField("num_max_users", "Max number allowed of users", FormField.Type.text_single); resultform.addReportedField("is_password_protected", "Is a password protected room.", FormField.Type.boolean_type); resultform.addReportedField("is_member_only", "Is a member only room.", FormField.Type.boolean_type); resultform.addReportedField("jid", "JID", FormField.Type.jid_single); } res.add(resultform.getElement()); if (applyRSM) { res.add(searchResults.generateSetElementFromResults(mucrsm)); } reply.setChildElement(res); return reply; }
From source file:net.emiva.crossfire.plugin.muc.spi.IQOwnerHandler.java
License:Open Source License
/** * Handles the IQ packet sent by an owner of the room. Possible actions are: * <ul>/*from w ww . j a v a2s . c om*/ * <li>Return the list of owners</li> * <li>Return the list of admins</li> * <li>Change user's affiliation to owner</li> * <li>Change user's affiliation to admin</li> * <li>Change user's affiliation to member</li> * <li>Change user's affiliation to none</li> * <li>Destroy the room</li> * <li>Return the room configuration within a dataform</li> * <li>Update the room configuration based on the sent dataform</li> * </ul> * * @param packet the IQ packet sent by an owner of the room. * @param role the role of the user that sent the packet. * @throws ForbiddenException if the user does not have enough permissions (ie. is not an owner). * @throws ConflictException If the room was going to lose all of its owners. */ @SuppressWarnings("unchecked") public void handleIQ(IQ packet, MUCRole role) throws ForbiddenException, ConflictException, CannotBeInvitedException { // Only owners can send packets with the namespace "http://jabber.org/protocol/muc#owner" if (MUCRole.Affiliation.owner != role.getAffiliation()) { throw new ForbiddenException(); } IQ reply = IQ.createResultIQ(packet); Element element = packet.getChildElement(); // Analyze the action to perform based on the included element Element formElement = element.element(QName.get("x", "jabber:x:data")); if (formElement != null) { handleDataFormElement(role, formElement); } else { Element destroyElement = element.element("destroy"); if (destroyElement != null) { if (((MultiUserChatServiceImpl) room.getMUCService()).getMUCDelegate() != null) { if (!((MultiUserChatServiceImpl) room.getMUCService()).getMUCDelegate() .destroyingRoom(room.getName(), role.getUserAddress())) { // Delegate said no, reject destroy request. throw new ForbiddenException(); } } room.destroyRoom(destroyElement.attributeValue("jid"), destroyElement.elementTextTrim("reason")); } else { List<Element> itemsList = element.elements("item"); if (!itemsList.isEmpty()) { handleItemsElement(itemsList, role, reply); } else { // If no element was included in the query element then answer the // configuration form if (!element.elementIterator().hasNext()) { refreshConfigurationFormValues(); reply.setChildElement(probeResult.createCopy()); } // An unknown and possibly incorrect element was included in the query // element so answer a BAD_REQUEST error else { reply.setChildElement(packet.getChildElement().createCopy()); reply.setError(PacketError.Condition.bad_request); } } } } if (reply.getTo() != null) { // Send a reply only if the sender of the original packet was from a real JID. (i.e. not // a packet generated locally) router.route(reply); } }
From source file:net.emiva.crossfire.plugin.muc.spi.IQOwnerHandler.java
License:Open Source License
private void refreshConfigurationFormValues() { room.lock.readLock().lock();/*from w w w . jav a2 s .c o m*/ try { FormField field = configurationForm.getField("muc#roomconfig_roomname"); field.clearValues(); field.addValue(room.getNaturalLanguageName()); field = configurationForm.getField("muc#roomconfig_roomdesc"); field.clearValues(); field.addValue(room.getDescription()); field = configurationForm.getField("muc#roomconfig_changesubject"); field.clearValues(); field.addValue((room.canOccupantsChangeSubject() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_maxusers"); field.clearValues(); field.addValue(Integer.toString(room.getMaxUsers())); field = configurationForm.getField("muc#roomconfig_presencebroadcast"); field.clearValues(); for (String roleToBroadcast : room.getRolesToBroadcastPresence()) { field.addValue(roleToBroadcast); } field = configurationForm.getField("muc#roomconfig_publicroom"); field.clearValues(); field.addValue((room.isPublicRoom() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_persistentroom"); field.clearValues(); field.addValue((room.isPersistent() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_moderatedroom"); field.clearValues(); field.addValue((room.isModerated() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_membersonly"); field.clearValues(); field.addValue((room.isMembersOnly() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_allowinvites"); field.clearValues(); field.addValue((room.canOccupantsInvite() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_passwordprotectedroom"); field.clearValues(); field.addValue((room.isPasswordProtected() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_roomsecret"); field.clearValues(); field.addValue(room.getPassword()); field = configurationForm.getField("muc#roomconfig_whois"); field.clearValues(); field.addValue((room.canAnyoneDiscoverJID() ? "anyone" : "moderators")); field = configurationForm.getField("muc#roomconfig_enablelogging"); field.clearValues(); field.addValue((room.isLogEnabled() ? "1" : "0")); field = configurationForm.getField("x-muc#roomconfig_reservednick"); field.clearValues(); field.addValue((room.isLoginRestrictedToNickname() ? "1" : "0")); field = configurationForm.getField("x-muc#roomconfig_canchangenick"); field.clearValues(); field.addValue((room.canChangeNickname() ? "1" : "0")); field = configurationForm.getField("x-muc#roomconfig_registration"); field.clearValues(); field.addValue((room.isRegistrationEnabled() ? "1" : "0")); field = configurationForm.getField("muc#roomconfig_roomadmins"); field.clearValues(); for (String jid : room.getAdmins()) { field.addValue(jid); } field = configurationForm.getField("muc#roomconfig_roomowners"); field.clearValues(); for (String jid : room.getOwners()) { field.addValue(jid); } // Remove the old element probeResult.remove(probeResult.element(QName.get("x", "jabber:x:data"))); // Add the new representation of configurationForm as an element probeResult.add(configurationForm.getElement()); } finally { room.lock.readLock().unlock(); } }
From source file:net.emiva.crossfire.plugin.muc.spi.IQOwnerHandler.java
License:Open Source License
private void init() { Element element = DocumentHelper.createElement(QName.get("query", "http://jabber.org/protocol/muc#owner")); configurationForm = new DataForm(DataForm.Type.form); configurationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.conf.title")); List<String> params = new ArrayList<String>(); params.add(room.getName());//from w w w. j a v a 2 s.c o m configurationForm.addInstruction(LocaleUtils.getLocalizedString("muc.form.conf.instruction", params)); configurationForm.addField("FORM_TYPE", null, Type.hidden) .addValue("http://jabber.org/protocol/muc#roomconfig"); configurationForm.addField("muc#roomconfig_roomname", LocaleUtils.getLocalizedString("muc.form.conf.owner_roomname"), Type.text_single); configurationForm.addField("muc#roomconfig_roomdesc", LocaleUtils.getLocalizedString("muc.form.conf.owner_roomdesc"), Type.text_single); configurationForm.addField("muc#roomconfig_changesubject", LocaleUtils.getLocalizedString("muc.form.conf.owner_changesubject"), Type.boolean_type); final FormField maxUsers = configurationForm.addField("muc#roomconfig_maxusers", LocaleUtils.getLocalizedString("muc.form.conf.owner_maxusers"), Type.list_single); maxUsers.addOption("10", "10"); maxUsers.addOption("20", "20"); maxUsers.addOption("30", "30"); maxUsers.addOption("40", "40"); maxUsers.addOption("50", "50"); maxUsers.addOption(LocaleUtils.getLocalizedString("muc.form.conf.none"), "0"); final FormField broadcast = configurationForm.addField("muc#roomconfig_presencebroadcast", LocaleUtils.getLocalizedString("muc.form.conf.owner_presencebroadcast"), Type.list_multi); broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderator"); broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.participant"), "participant"); broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.visitor"), "visitor"); configurationForm.addField("muc#roomconfig_publicroom", LocaleUtils.getLocalizedString("muc.form.conf.owner_publicroom"), Type.boolean_type); configurationForm.addField("muc#roomconfig_persistentroom", LocaleUtils.getLocalizedString("muc.form.conf.owner_persistentroom"), Type.boolean_type); configurationForm.addField("muc#roomconfig_moderatedroom", LocaleUtils.getLocalizedString("muc.form.conf.owner_moderatedroom"), Type.boolean_type); configurationForm.addField("muc#roomconfig_membersonly", LocaleUtils.getLocalizedString("muc.form.conf.owner_membersonly"), Type.boolean_type); configurationForm.addField(null, null, Type.fixed) .addValue(LocaleUtils.getLocalizedString("muc.form.conf.allowinvitesfixed")); configurationForm.addField("muc#roomconfig_allowinvites", LocaleUtils.getLocalizedString("muc.form.conf.owner_allowinvites"), Type.boolean_type); configurationForm.addField("muc#roomconfig_passwordprotectedroom", LocaleUtils.getLocalizedString("muc.form.conf.owner_passwordprotectedroom"), Type.boolean_type); configurationForm.addField(null, null, Type.fixed) .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomsecretfixed")); configurationForm.addField("muc#roomconfig_roomsecret", LocaleUtils.getLocalizedString("muc.form.conf.owner_roomsecret"), Type.text_private); final FormField whois = configurationForm.addField("muc#roomconfig_whois", LocaleUtils.getLocalizedString("muc.form.conf.owner_whois"), Type.list_single); whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderators"); whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.anyone"), "anyone"); configurationForm.addField("muc#roomconfig_enablelogging", LocaleUtils.getLocalizedString("muc.form.conf.owner_enablelogging"), Type.boolean_type); configurationForm.addField("x-muc#roomconfig_reservednick", LocaleUtils.getLocalizedString("muc.form.conf.owner_reservednick"), Type.boolean_type); configurationForm.addField("x-muc#roomconfig_canchangenick", LocaleUtils.getLocalizedString("muc.form.conf.owner_canchangenick"), Type.boolean_type); configurationForm.addField("x-muc#roomconfig_registration", LocaleUtils.getLocalizedString("muc.form.conf.owner_registration"), Type.boolean_type); configurationForm.addField(null, null, Type.fixed) .addValue(LocaleUtils.getLocalizedString("muc.form.conf.owner_registration")); configurationForm.addField("muc#roomconfig_roomadmins", LocaleUtils.getLocalizedString("muc.form.conf.owner_roomadmins"), Type.jid_multi); configurationForm.addField(null, null, Type.fixed) .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomownersfixed")); configurationForm.addField("muc#roomconfig_roomowners", LocaleUtils.getLocalizedString("muc.form.conf.owner_roomowners"), Type.jid_multi); // Create the probeResult and add the basic info together with the configuration form probeResult = element; probeResult.add(configurationForm.getElement()); }
From source file:net.emiva.crossfire.plugin.muc.spi.LocalMUCRole.java
License:Open Source License
/** * Create a new role./*from ww w . j a v a 2s. c o m*/ * * @param chatserver the server hosting the role. * @param chatroom the room the role is valid in. * @param nickname the nickname of the user in the role. * @param role the role of the user in the room. * @param affiliation the affiliation of the user in the room. * @param chatuser the user on the chat server. * @param presence the presence sent by the user to join the room. * @param packetRouter the packet router for sending messages from this role. */ public LocalMUCRole(MultiUserChatService chatserver, LocalMUCRoom chatroom, String nickname, MUCRole.Role role, MUCRole.Affiliation affiliation, LocalMUCUser chatuser, Presence presence, PacketRouter packetRouter) { this.room = chatroom; this.nick = nickname; this.user = chatuser; this.server = chatserver; this.router = packetRouter; this.role = role; this.affiliation = affiliation; // Cache the user's session (will only work for local users) this.session = XMPPServer.getInstance().getSessionManager().getSession(presence.getFrom()); extendedInformation = DocumentHelper.createElement(QName.get("x", "http://jabber.org/protocol/muc#user")); calculateExtendedInformation(); rJID = new JID(room.getName(), server.getServiceDomain(), nick); setPresence(presence); // Check if new occupant wants to be a deaf occupant Element element = presence.getElement().element(QName.get("x", "http://jivesoftware.org/protocol/muc")); if (element != null) { voiceOnly = element.element("deaf-occupant") != null; } // Add the new role to the list of roles user.addRole(room.getName(), this); }
From source file:net.emiva.crossfire.plugin.muc.spi.LocalMUCRole.java
License:Open Source License
public void setPresence(Presence newPresence) { // Try to remove the element whose namespace is "http://jabber.org/protocol/muc" since we // don't need to include that element in future presence broadcasts Element element = newPresence.getElement().element(QName.get("x", "http://jabber.org/protocol/muc")); if (element != null) { newPresence.getElement().remove(element); }/*from ww w . ja v a 2s. c o m*/ this.presence = newPresence; this.presence.setFrom(getRoleAddress()); if (extendedInformation != null) { extendedInformation.setParent(null); presence.getElement().add(extendedInformation); } }
From source file:net.sf.kraken.BaseTransport.java
License:Open Source License
/** * Handle service discovery info request. * * @param packet An IQ packet in the disco info namespace. * @return A list of IQ packets to be returned to the user. *///w ww.ja va 2s . c om private List<Packet> handleDiscoInfo(IQ packet) { // TODO: why return a list? we're sure to return always exactly one result. List<Packet> reply = new ArrayList<Packet>(); JID from = packet.getFrom(); IQ result = IQ.createResultIQ(packet); if (packet.getTo().getNode() == null) { // Requested info from transport itself. if (from.getNode() == null || RegistrationManager.getInstance().isRegistered(from, this.transportType) || permissionManager.hasAccess(from)) { Element response = DocumentHelper.createElement(QName.get("query", NameSpace.DISCO_INFO)); response.addElement("identity").addAttribute("category", "gateway") .addAttribute("type", this.transportType.discoIdentity()) .addAttribute("name", this.description); response.addElement("feature").addAttribute("var", NameSpace.DISCO_INFO); response.addElement("feature").addAttribute("var", NameSpace.DISCO_ITEMS); response.addElement("feature").addAttribute("var", NameSpace.IQ_GATEWAY); response.addElement("feature").addAttribute("var", NameSpace.IQ_REGISTER); response.addElement("feature").addAttribute("var", NameSpace.IQ_VERSION); response.addElement("feature").addAttribute("var", NameSpace.IQ_LAST); response.addElement("feature").addAttribute("var", NameSpace.VCARD_TEMP); if (RegistrationManager.getInstance().isRegistered(from, this.transportType)) { response.addElement("feature").addAttribute("var", NameSpace.IQ_REGISTERED); } result.setChildElement(response); } else { result.setError(Condition.forbidden); } } else { // Requested info from a gateway user. final TransportSession<B> session; try { session = sessionManager.getSession(packet.getFrom()); if ((from.getNode() == null || permissionManager.hasAccess(from)) && session != null) { final Element response = DocumentHelper.createElement(QName.get("query", NameSpace.DISCO_INFO)); response.addElement("identity").addAttribute("category", "client").addAttribute("type", "pc"); response.addElement("feature").addAttribute("var", NameSpace.DISCO_INFO); for (final SupportedFeature feature : session.supportedFeatures) { response.addElement("feature").addAttribute("var", feature.getVar()); } result.setChildElement(response); } else { result.setError(Condition.forbidden); } } catch (NotFoundException ex) { result.setError(Condition.item_not_found); } } reply.add(result); return reply; }
From source file:net.sf.kraken.BaseTransport.java
License:Open Source License
/** * Handle service discovery items request. * * @param packet An IQ packet in the disco items namespace. * @return A list of IQ packets to be returned to the user. *//*from ww w . ja v a 2s.co m*/ private List<Packet> handleDiscoItems(IQ packet) { List<Packet> reply = new ArrayList<Packet>(); IQ result = IQ.createResultIQ(packet); Element response = DocumentHelper.createElement(QName.get("query", NameSpace.DISCO_ITEMS)); result.setChildElement(response); reply.add(result); return reply; }
From source file:net.sf.kraken.BaseTransport.java
License:Open Source License
/** * Handle gateway translation service request. * * @param packet An IQ packet in the iq gateway namespace. * @return A list of IQ packets to be returned to the user. */// ww w . jav a 2 s . c om private List<Packet> handleIQGateway(IQ packet) { List<Packet> reply = new ArrayList<Packet>(); if (packet.getType() == IQ.Type.get) { IQ result = IQ.createResultIQ(packet); Element query = DocumentHelper.createElement(QName.get("query", NameSpace.IQ_GATEWAY)); query.addElement("desc").addText(LocaleUtils.getLocalizedString("gateway.base.enterusername", "kraken", Arrays.asList(transportType.toString().toUpperCase()))); query.addElement("prompt"); result.setChildElement(query); reply.add(result); } else if (packet.getType() == IQ.Type.set) { IQ result = IQ.createResultIQ(packet); String prompt = null; Element promptEl = packet.getChildElement().element("prompt"); if (promptEl != null) { prompt = promptEl.getTextTrim(); } if (prompt == null) { result.setError(Condition.bad_request); } else { JID jid = this.convertIDToJID(prompt); Element query = DocumentHelper.createElement(QName.get("query", NameSpace.IQ_GATEWAY)); // This is what Psi expects query.addElement("prompt").addText(jid.toString()); // This is JEP complient query.addElement("jid").addText(jid.toString()); result.setChildElement(query); } reply.add(result); } return reply; }