}
else {
// Check if the disco#info was sent to a given workgroup
try {
Workgroup workgroup = workgroupManager.getWorkgroup(packet.getTo());
Element iq = packet.getChildElement();
reply.setChildElement(iq.createCopy());
Element queryElement = reply.getChildElement();
// Create and add a the identity of the workgroup service
Element identity = queryElement.addElement("identity");
identity.addAttribute("category", "collaboration");
identity.addAttribute("name", workgroup.getJID().getNode());
identity.addAttribute("type", "workgroup");
// Create and add a the disco#info feature
Element feature = queryElement.addElement("feature");
feature.addAttribute("var", "http://jabber.org/protocol/disco#info");
Element form = queryElement.addElement("x", "jabber:x:data");
form.addAttribute("type", "result");
// Add static field
Element field = form.addElement("field");
field.addAttribute("var", "FORM_TYPE");
field.addAttribute("type", "hidden");
field.addElement("value").setText("http://jabber.org/protocol/workgroup#workgroupinfo");
// Add workgroup description
field = form.addElement("field");
field.addAttribute("var", "workgroup#description");
field.addAttribute("label", "Description");
field.addElement("value").setText(workgroup.getDescription() == null ?
"" : workgroup.getDescription());
// Add workgroup online status
field = form.addElement("field");
field.addAttribute("var", "workgroup#online");
field.addAttribute("label", "Status");
field.addElement("value").setText(workgroup.getStatus().name());
}
catch (UserNotFoundException e) {
// If we didn't find a workgroup then answer a not found error
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.item_not_found);