List of usage examples for org.dom4j Element elementTextTrim
String elementTextTrim(QName qname);
From source file:org.jbpm.jpdl.xml.JpdlXmlReader.java
License:Open Source License
public ProcessDefinition readProcessDefinition() { // create a new definition processDefinition = ProcessDefinition.createNewProcessDefinition(); // initialize lists problems = new ArrayList(); unresolvedTransitionDestinations = new ArrayList(); unresolvedActionReferences = new ArrayList(); try {/*from www. j ava2s .c om*/ // parse the document into a dom tree document = JpdlParser.parse(inputSource, this); Element root = document.getRootElement(); // read the process name parseProcessDefinitionAttributes(root); // get the process description String description = root.elementTextTrim("description"); if (description != null) { processDefinition.setDescription(description); } // first pass: read most content readSwimlanes(root); readActions(root, null, null); readNodes(root, processDefinition); readEvents(root, processDefinition); readExceptionHandlers(root, processDefinition); readTasks(root, null); // second pass processing resolveTransitionDestinations(); resolveActionReferences(); verifySwimlaneAssignments(); } catch (Exception e) { log.error("couldn't parse process definition", e); addProblem(new Problem(Problem.LEVEL_ERROR, "couldn't parse process definition", e)); } if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) { throw new JpdlException(problems); } if (problems != null) { Iterator iter = problems.iterator(); while (iter.hasNext()) { Problem problem = (Problem) iter.next(); log.warn("process parse warning: " + problem.getDescription()); } } return processDefinition; }
From source file:org.jbpm.jpdl.xml.JpdlXmlReader.java
License:Open Source License
public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) { Task task = new Task(); task.setProcessDefinition(processDefinition); // get the task name String name = taskElement.attributeValue("name"); if (name != null) { task.setName(name);/*from ww w . ja v a2 s. c om*/ taskMgmtDefinition.addTask(task); } else if (taskNode != null) { task.setName(taskNode.getName()); taskMgmtDefinition.addTask(task); } // get the task description String description = taskElement.elementTextTrim("description"); if (description != null) { task.setDescription(description); } else { task.setDescription(taskElement.attributeValue("description")); } // get the condition String condition = taskElement.elementTextTrim("condition"); if (condition != null) { task.setCondition(condition); } else { task.setCondition(taskElement.attributeValue("condition")); } // parse common subelements readTaskTimers(taskElement, task); readEvents(taskElement, task); readExceptionHandlers(taskElement, task); // duedate and priority String duedateText = taskElement.attributeValue("duedate"); if (duedateText == null) { duedateText = taskElement.attributeValue("dueDate"); } task.setDueDate(duedateText); String priorityText = taskElement.attributeValue("priority"); if (priorityText != null) { task.setPriority(Task.parsePriority(priorityText)); } // if this task is in the context of a taskNode, associate them if (taskNode != null) { taskNode.addTask(task); } // blocking String blockingText = taskElement.attributeValue("blocking"); if (blockingText != null) { if (("true".equalsIgnoreCase(blockingText)) || ("yes".equalsIgnoreCase(blockingText)) || ("on".equalsIgnoreCase(blockingText))) { task.setBlocking(true); } } // signalling String signallingText = taskElement.attributeValue("signalling"); if (signallingText != null) { if (("false".equalsIgnoreCase(signallingText)) || ("no".equalsIgnoreCase(signallingText)) || ("off".equalsIgnoreCase(signallingText))) { task.setSignalling(false); } } // assignment String swimlaneName = taskElement.attributeValue("swimlane"); Element assignmentElement = taskElement.element("assignment"); // if there is a swimlane attribute specified if (swimlaneName != null) { Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName); if (swimlane == null) { addWarning("task references unknown swimlane '" + swimlaneName + "':" + taskElement.asXML()); } else { task.setSwimlane(swimlane); } // else if there is a direct assignment specified } else if (assignmentElement != null) { if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null)) { task.setActorIdExpression(assignmentElement.attributeValue("actor-id")); task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors")); } else { Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement); task.setAssignmentDelegation(assignmentDelegation); } // if no assignment or swimlane is specified } else { // the user has to manage assignment manually, so we better inform him/her. log.info("process xml information: no swimlane or assignment specified for task '" + taskElement.asXML() + "'"); } // notify String notificationsText = taskElement.attributeValue("notify"); if (notificationsText != null && ("true".equalsIgnoreCase(notificationsText) || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText))) { String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN; Event event = task.getEvent(notificationEvent); if (event == null) { event = new Event(notificationEvent); task.addEvent(event); } Delegation delegation = createMailDelegation(notificationEvent, null, null, null, null); Action action = new Action(delegation); action.setProcessDefinition(processDefinition); action.setName(task.getName()); event.addAction(action); } // task controller Element taskControllerElement = taskElement.element("controller"); if (taskControllerElement != null) { task.setTaskController(readTaskController(taskControllerElement)); } return task; }
From source file:org.jbpm.jpdl.xml.JpdlXmlReader.java
License:Open Source License
public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection) { // first put the node in its collection. this is done so that the // setName later on will be able to differentiate between nodes contained in // processDefinitions and nodes contained in superstates nodeCollection.addNode(node);//ww w .ja va 2 s . c o m // get the node name String name = nodeElement.attributeValue("name"); if (name != null) { node.setName(name); // check if this is the initial node if ((initialNodeName != null) && (initialNodeName.equals(node.getFullyQualifiedName()))) { processDefinition.setStartState(node); } } // get the node description String description = nodeElement.elementTextTrim("description"); if (description != null) { node.setDescription(description); } String asyncText = nodeElement.attributeValue("async"); if ("true".equalsIgnoreCase(asyncText)) { node.setAsync(true); } else if ("exclusive".equalsIgnoreCase(asyncText)) { node.setAsync(true); node.setAsyncExclusive(true); } // parse common subelements readNodeTimers(nodeElement, node); readEvents(nodeElement, node); readExceptionHandlers(nodeElement, node); // save the transitions and parse them at the end addUnresolvedTransitionDestination(nodeElement, node); }
From source file:org.jbpm.jpdl.xml.JpdlXmlReader.java
License:Open Source License
/** * creates the transition object and configures it by the read attributes * @return the created <code>org.jbpm.graph.def.Transition</code> object * (useful, if you want to override this method * to read additional configuration properties) *//*ww w .jav a2 s. co m*/ public Transition resolveTransitionDestination(Element transitionElement, Node node) { Transition transition = new Transition(); transition.setProcessDefinition(processDefinition); transition.setName(transitionElement.attributeValue("name")); transition.setDescription(transitionElement.elementTextTrim("description")); String condition = transitionElement.attributeValue("condition"); if (condition == null) { Element conditionElement = transitionElement.element("condition"); if (conditionElement != null) { condition = conditionElement.getTextTrim(); // for backwards compatibility if ((condition == null) || (condition.length() == 0)) { condition = conditionElement.attributeValue("expression"); } } } transition.setCondition(condition); // add the transition to the node node.addLeavingTransition(transition); // set destinationNode of the transition String toName = transitionElement.attributeValue("to"); if (toName == null) { addWarning("node '" + node.getFullyQualifiedName() + "' has a transition without a 'to'-attribute to specify its destinationNode"); } else { Node to = ((NodeCollection) node.getParent()).findNode(toName); if (to == null) { addWarning("transition to='" + toName + "' on node '" + node.getFullyQualifiedName() + "' cannot be resolved"); } else { to.addArrivingTransition(transition); } } // read the actions readActions(transitionElement, transition, Event.EVENTTYPE_TRANSITION); readExceptionHandlers(transitionElement, transition); return transition; }
From source file:org.jivesoftware.admin.LdapUserProfile.java
License:Open Source License
/** * Returns true if the vCard mappings where successfully loaded from the XML/DB * properties./* w w w. jav a2 s .com*/ * * @return true if mappings where loaded from saved property. */ public boolean loadFromProperties() { String xmlProperty = JiveGlobals.getProperty("ldap.vcard-mapping"); if (xmlProperty == null || xmlProperty.trim().length() == 0) { return false; } try { // Remove CDATA wrapping element if (xmlProperty.startsWith("<![CDATA[")) { xmlProperty = xmlProperty.substring(9, xmlProperty.length() - 3); } // Parse XML Document document = DocumentHelper.parseText(xmlProperty); Element vCard = document.getRootElement(); Element element = vCard.element("N"); if (element != null) { name = element.elementTextTrim("GIVEN"); } element = vCard.element("EMAIL"); if (element != null) { email = element.elementTextTrim("USERID"); } element = vCard.element("FN"); if (element != null) { fullName = element.getTextTrim(); } element = vCard.element("NICKNAME"); if (element != null) { nickname = element.getTextTrim(); } element = vCard.element("BDAY"); if (element != null) { birthday = element.getTextTrim(); } // Parse addresses Iterator addresses = vCard.elementIterator("ADR"); while (addresses.hasNext()) { element = (Element) addresses.next(); if (element.element("HOME") != null) { if (element.element("STREET") != null) { homeStreet = element.elementTextTrim("STREET"); } if (element.element("LOCALITY") != null) { homeCity = element.elementTextTrim("LOCALITY"); } if (element.element("REGION") != null) { homeState = element.elementTextTrim("REGION"); } if (element.element("PCODE") != null) { homeZip = element.elementTextTrim("PCODE"); } if (element.element("CTRY") != null) { homeCountry = element.elementTextTrim("CTRY"); } } else if (element.element("WORK") != null) { if (element.element("STREET") != null) { businessStreet = element.elementTextTrim("STREET"); } if (element.element("LOCALITY") != null) { businessCity = element.elementTextTrim("LOCALITY"); } if (element.element("REGION") != null) { businessState = element.elementTextTrim("REGION"); } if (element.element("PCODE") != null) { businessZip = element.elementTextTrim("PCODE"); } if (element.element("CTRY") != null) { businessCountry = element.elementTextTrim("CTRY"); } } } // Parse telephones Iterator telephones = vCard.elementIterator("TEL"); while (telephones.hasNext()) { element = (Element) telephones.next(); if (element.element("HOME") != null) { if (element.element("VOICE") != null) { homePhone = element.elementTextTrim("NUMBER"); } else if (element.element("CELL") != null) { homeMobile = element.elementTextTrim("NUMBER"); } else if (element.element("FAX") != null) { homeFax = element.elementTextTrim("NUMBER"); } else if (element.element("PAGER") != null) { homePager = element.elementTextTrim("NUMBER"); } } else if (element.element("WORK") != null) { if (element.element("VOICE") != null) { businessPhone = element.elementTextTrim("NUMBER"); } else if (element.element("CELL") != null) { businessMobile = element.elementTextTrim("NUMBER"); } else if (element.element("FAX") != null) { businessFax = element.elementTextTrim("NUMBER"); } else if (element.element("PAGER") != null) { businessPager = element.elementTextTrim("NUMBER"); } } } element = vCard.element("TITLE"); if (element != null) { businessJobTitle = element.getTextTrim(); } element = vCard.element("ORG"); if (element != null) { if (element.element("ORGUNIT") != null) { businessDepartment = element.elementTextTrim("ORGUNIT"); } } avatarStoredInDB = JiveGlobals.getBooleanProperty("ldap.override.avatar", false); } catch (DocumentException e) { Log.error("Error loading vcard mappings from property", e); return false; } return true; }
From source file:org.jivesoftware.openfire.clearspace.ClearspaceVCardTranslator.java
License:Open Source License
/** * Translates the address field from the vCard format to the Clearspace format. * * @param addressElement the vCard address * @param vCardFieldName the vCard field name * @param fieldName the Clearspace field name * @param sb the string builder to append the field string to *///from w ww. j a va2 s . co m private void translateAddressField(Element addressElement, String vCardFieldName, String fieldName, StringBuilder sb) { String field = addressElement.elementTextTrim(vCardFieldName); if (field != null && !"".equals(field)) { sb.append(fieldName).append(":").append(field).append(","); } }
From source file:org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy.java
License:Open Source License
public boolean handleIQ(IQ packet) throws UnauthorizedException { Element childElement = packet.getChildElement(); String namespace = null;/*from w w w .j ava 2 s. co m*/ // ignore errors if (packet.getType() == IQ.Type.error) { return true; } if (childElement != null) { namespace = childElement.getNamespaceURI(); } if ("http://jabber.org/protocol/disco#info".equals(namespace)) { IQ reply = XMPPServer.getInstance().getIQDiscoInfoHandler().handleIQ(packet); router.route(reply); return true; } else if ("http://jabber.org/protocol/disco#items".equals(namespace)) { // a component IQ reply = XMPPServer.getInstance().getIQDiscoItemsHandler().handleIQ(packet); router.route(reply); return true; } else if (FileTransferManager.NAMESPACE_BYTESTREAMS.equals(namespace)) { if (packet.getType() == IQ.Type.get) { IQ reply = IQ.createResultIQ(packet); Element newChild = reply.setChildElement("query", FileTransferManager.NAMESPACE_BYTESTREAMS); Element response = newChild.addElement("streamhost"); response.addAttribute("jid", getServiceDomain()); response.addAttribute("host", proxyIP); response.addAttribute("port", String.valueOf(connectionManager.getProxyPort())); router.route(reply); return true; } else if (packet.getType() == IQ.Type.set && childElement != null) { String sid = childElement.attributeValue("sid"); JID from = packet.getFrom(); JID to = new JID(childElement.elementTextTrim("activate")); IQ reply = IQ.createResultIQ(packet); try { connectionManager.activate(from, to, sid); } catch (IllegalArgumentException ie) { Log.error("Error activating connection", ie); reply.setType(IQ.Type.error); reply.setError(new PacketError(PacketError.Condition.not_allowed)); } router.route(reply); return true; } } return false; }
From source file:org.jivesoftware.openfire.forms.spi.XFormFieldImpl.java
License:Open Source License
public void parse(Element formElement) { variable = formElement.attributeValue("var"); setLabel(formElement.attributeValue("label")); setType(formElement.attributeValue("type")); Element descElement = formElement.element("desc"); if (descElement != null) { setDescription(descElement.getTextTrim()); }/*from ww w .jav a2s . c o m*/ if (formElement.element("required") != null) { setRequired(true); } Iterator valueElements = formElement.elementIterator("value"); while (valueElements.hasNext()) { addValue(((Element) valueElements.next()).getTextTrim()); } Iterator optionElements = formElement.elementIterator("option"); Element optionElement; while (optionElements.hasNext()) { optionElement = (Element) optionElements.next(); addOption(optionElement.attributeValue("label"), optionElement.elementTextTrim("value")); } }
From source file:org.jivesoftware.openfire.muc.spi.IQAdminHandler.java
License:Open Source License
/** * Handles packets that includes item elements. Depending on the item's attributes the * interpretation of the request may differ. For example, an item that only contains the * "affiliation" attribute is requesting the list of participants or members. Whilst if the item * contains the affiliation together with a jid means that the client is changing the * affiliation of the requested jid.//from w w w. j av a 2s . c om * * @param senderRole the role of the user that sent the request packet. * @param itemsList the list of items sent by the client. * @param reply the iq packet that will be sent back as a reply to the client's request. * @throws ForbiddenException If the user is not allowed to perform his request. * @throws ConflictException If the desired room nickname is already reserved for the room or * if the room was going to lose all of its owners. * @throws NotAllowedException Thrown if trying to ban an owner or an administrator. * @throws CannotBeInvitedException If the user being invited as a result of being added to a members-only room still does not have permission */ private void handleItemsElement(MUCRole senderRole, List<Element> itemsList, IQ reply) throws ForbiddenException, ConflictException, NotAllowedException, CannotBeInvitedException { Element item; String affiliation; String roleAttribute; boolean hasJID = itemsList.get(0).attributeValue("jid") != null; boolean hasNick = itemsList.get(0).attributeValue("nick") != null; // Check if the client is requesting or changing the list of moderators/members/etc. if (!hasJID && !hasNick) { // The client is requesting the list of moderators/members/participants/outcasts // Create the result that will hold an item for each // moderator/member/participant/outcast Element result = reply.setChildElement("query", "http://jabber.org/protocol/muc#admin"); for (Object anItem : itemsList) { item = (Element) anItem; affiliation = item.attributeValue("affiliation"); roleAttribute = item.attributeValue("role"); Element metaData; if ("outcast".equals(affiliation)) { // The client is requesting the list of outcasts if (MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } for (JID jid : room.getOutcasts()) { if (GroupJID.isGroup(jid)) { try { // add each group member to the result (clients don't understand groups) Group group = GroupManager.getInstance().getGroup(jid); for (JID groupMember : group.getAll()) { metaData = addAffiliationToResult(affiliation, result, groupMember); } } catch (GroupNotFoundException gnfe) { logger.warn("Invalid group JID in the outcast list: " + jid); } } else { metaData = addAffiliationToResult(affiliation, result, jid); } } } else if ("member".equals(affiliation)) { // The client is requesting the list of members // In a members-only room members can get the list of members if (!room.isMembersOnly() && MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } for (JID jid : room.getMembers()) { if (GroupJID.isGroup(jid)) { try { // add each group member to the result (clients don't understand groups) Group group = GroupManager.getInstance().getGroup(jid); for (JID groupMember : group.getAll()) { metaData = addAffiliationToResult(affiliation, result, groupMember); } } catch (GroupNotFoundException gnfe) { logger.warn("Invalid group JID in the member list: " + jid); } } else { metaData = addAffiliationToResult(affiliation, result, jid); } } } else if ("moderator".equals(roleAttribute)) { // The client is requesting the list of moderators if (MUCRole.Affiliation.admin != senderRole.getAffiliation() && MUCRole.Affiliation.owner != senderRole.getAffiliation()) { throw new ForbiddenException(); } for (MUCRole role : room.getModerators()) { metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin"); metaData.addAttribute("role", "moderator"); metaData.addAttribute("jid", role.getUserAddress().toString()); metaData.addAttribute("nick", role.getNickname()); metaData.addAttribute("affiliation", role.getAffiliation().toString()); } } else if ("participant".equals(roleAttribute)) { // The client is requesting the list of participants if (MUCRole.Role.moderator != senderRole.getRole()) { throw new ForbiddenException(); } for (MUCRole role : room.getParticipants()) { metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin"); metaData.addAttribute("role", "participant"); metaData.addAttribute("jid", role.getUserAddress().toString()); metaData.addAttribute("nick", role.getNickname()); metaData.addAttribute("affiliation", role.getAffiliation().toString()); } } else if ("owner".equals(affiliation)) { // The client is requesting the list of owners for (JID jid : room.getOwners()) { if (GroupJID.isGroup(jid)) { try { // add each group member to the result (clients don't understand groups) Group group = GroupManager.getInstance().getGroup(jid); for (JID groupMember : group.getAll()) { metaData = addAffiliationToResult(affiliation, result, groupMember); } } catch (GroupNotFoundException gnfe) { logger.warn("Invalid group JID in the owner list: " + jid); } } else { metaData = addAffiliationToResult(affiliation, result, jid); } } } else if ("admin".equals(affiliation)) { // The client is requesting the list of admins for (JID jid : room.getAdmins()) { if (GroupJID.isGroup(jid)) { try { // add each group member to the result (clients don't understand groups) Group group = GroupManager.getInstance().getGroup(jid); for (JID groupMember : group.getAll()) { metaData = addAffiliationToResult(affiliation, result, groupMember); } } catch (GroupNotFoundException gnfe) { logger.warn("Invalid group JID in the admin list: " + jid); } } else { metaData = addAffiliationToResult(affiliation, result, jid); } } } else { reply.setError(PacketError.Condition.bad_request); } } } else { // The client is modifying the list of moderators/members/participants/outcasts String nick; String target; boolean hasAffiliation; // Keep a registry of the updated presences List<Presence> presences = new ArrayList<Presence>(itemsList.size()); // Collect the new affiliations or roles for the specified jids for (Object anItem : itemsList) { try { item = (Element) anItem; affiliation = item.attributeValue("affiliation"); hasAffiliation = affiliation != null; target = (hasAffiliation ? affiliation : item.attributeValue("role")); List<JID> jids = new ArrayList<JID>(); // jid could be of the form "full JID" or "bare JID" depending if we are // going to change a role or an affiliation nick = item.attributeValue("nick"); if (hasJID) { // could be a group JID jids.add(GroupJID.fromString(item.attributeValue("jid"))); } else { // Get the JID based on the requested nick for (MUCRole role : room.getOccupantsByNickname(nick)) { if (!jids.contains(role.getUserAddress())) { jids.add(role.getUserAddress()); } } } for (JID jid : jids) { if ("moderator".equals(target)) { // Add the user as a moderator of the room based on the full JID presences.add(room.addModerator(jid, senderRole)); } else if ("owner".equals(target)) { presences.addAll(room.addOwner(jid, senderRole)); } else if ("admin".equals(target)) { presences.addAll(room.addAdmin(jid, senderRole)); } else if ("participant".equals(target)) { // Add the user as a participant of the room based on the full JID presences.add(room.addParticipant(jid, item.elementTextTrim("reason"), senderRole)); } else if ("visitor".equals(target)) { // Add the user as a visitor of the room based on the full JID presences.add(room.addVisitor(jid, senderRole)); } else if ("member".equals(target)) { // Add the user as a member of the room based on the bare JID boolean hadAffiliation = room.getAffiliation(jid) != MUCRole.Affiliation.none; presences.addAll(room.addMember(jid, nick, senderRole)); // If the user had an affiliation don't send an invitation. Otherwise // send an invitation if the room is members-only and skipping invites // are not disabled system-wide xmpp.muc.skipInvite if (!skipInvite && !hadAffiliation && room.isMembersOnly()) { List<JID> invitees = new ArrayList<JID>(); if (GroupJID.isGroup(jid)) { try { Group group = GroupManager.getInstance().getGroup(jid); for (JID inGroup : group.getAll()) { invitees.add(inGroup); } } catch (GroupNotFoundException gnfe) { logger.error("Failed to send invitations for group members", gnfe); } } else { invitees.add(jid); } for (JID invitee : invitees) { room.sendInvitation(invitee, null, senderRole, null); } } } else if ("outcast".equals(target)) { // Add the user as an outcast of the room based on the bare JID presences.addAll(room.addOutcast(jid, item.elementTextTrim("reason"), senderRole)); } else if ("none".equals(target)) { if (hasAffiliation) { // Set that this jid has a NONE affiliation based on the bare JID presences.addAll(room.addNone(jid, senderRole)); } else { // Kick the user from the room if (MUCRole.Role.moderator != senderRole.getRole()) { throw new ForbiddenException(); } presences.add(room.kickOccupant(jid, senderRole.getUserAddress(), item.elementTextTrim("reason"))); } } else { reply.setError(PacketError.Condition.bad_request); } } } catch (UserNotFoundException e) { // Do nothing } } // Send the updated presences to the room occupants for (Presence presence : presences) { room.send(presence); } } }
From source file:org.jivesoftware.openfire.muc.spi.IQOwnerHandler.java
License:Open Source License
/** * Handles the IQ packet sent by an owner of the room. Possible actions are: * <ul>//w w w . j a v a 2s.c o m * <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(); } } JID alternateJID = null; final String jid = destroyElement.attributeValue("jid"); if (jid != null) { alternateJID = new JID(jid); } room.destroyRoom(alternateJID, destroyElement.elementTextTrim("reason")); } 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); } }