use of org.dom4j.Element in project Openfire by igniterealtime.
the class SearchPlugin method replyDisabled.
/**
* Constructs a IQ result stanza, based on the request stanza that is provided as an argument. The stanza tells the recipient that this
* service is currently unavailable.
*
* @param packet
* The request IQ stanza to which a result will be returned.
* @return A result stanza, telling the user that this service is unavailable.
*/
private static IQ replyDisabled(IQ packet) {
IQ replyPacket = IQ.createResultIQ(packet);
Element reply = replyPacket.setChildElement("query", NAMESPACE_JABBER_IQ_SEARCH);
final DataForm unavailableForm = new DataForm(DataForm.Type.cancel);
unavailableForm.setTitle(LocaleUtils.getLocalizedString("advance.user.search.title", "search"));
unavailableForm.addInstruction(LocaleUtils.getLocalizedString("search.service_unavailable", "search"));
reply.add(unavailableForm.getElement());
return replyPacket;
}
use of org.dom4j.Element in project Openfire by igniterealtime.
the class SearchPlugin method extractSearchQuery.
/**
* This utilty method extracts the search query from the request. A query is defined as a set of key->value pairs, where the key denotes
* a search field, and the value contains the value that was filled out by the user for that field.
*
* The query can be specified in one of two ways. The first way is a query is formed is by filling out any of the the standard search
* fields. The other search method makes use of extended data forms. Search queries that are supplied to this
* {@link #extractSearchQuery(Element)} that make use of this last method get forwarded to {@link #extractExtendedSearchQuery(Element)}.
*
* @param incomingForm
* The form from which to extract the query
* @return The search query for a particular user search request.
*/
@SuppressWarnings("unchecked")
private Hashtable<String, String> extractSearchQuery(Element incomingForm) {
if (incomingForm.element(QName.get("x", "jabber:x:data")) != null) {
// forward the request.
return extractExtendedSearchQuery(incomingForm);
}
final Hashtable<String, String> searchList = new Hashtable<String, String>();
// since not all clients request which fields are available for
// searching attempt to match submitted fields with available search
// fields
Iterator<Element> iter = incomingForm.elementIterator();
while (iter.hasNext()) {
Element element = iter.next();
String name = element.getName();
if (fieldLookup.containsKey(name)) {
// make best effort to map the fields submitted by
// the client to those that Openfire can search
reverseFieldLookup.put(fieldLookup.get(name), name);
searchList.put(fieldLookup.get(name), element.getText());
}
}
return searchList;
}
use of org.dom4j.Element in project Openfire by igniterealtime.
the class SipComponent method processIQ.
private void processIQ(IQ iq) {
IQ reply = IQ.createResultIQ(iq);
String namespace = iq.getChildElement().getNamespaceURI();
Element childElement = iq.getChildElement().createCopy();
reply.setChildElement(childElement);
if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
if (iq.getTo().getNode() == null) {
// Return service identity and features
Element identity = childElement.addElement("identity");
identity.addAttribute("category", "component");
identity.addAttribute("type", "generic");
identity.addAttribute("name", "SIP Controller");
childElement.addElement("feature").addAttribute("var", "http://jabber.org/protocol/disco#info");
childElement.addElement("feature").addAttribute("var", "http://www.jivesoftware.com/protocol/sipark");
}
} else if (NAMESPACE.equals(namespace)) {
if (iq.getTo().getNode() == null && iq.getFrom() != null) {
SipAccount sipAccount = SipAccountDAO.getAccountByUser(iq.getFrom().toBareJID().split("@")[0]);
if (iq.getChildElement().element("status") == null) {
if (sipAccount != null && sipAccount.isEnabled()) {
// There is a SIP mapping for this user so return mapping information
Element registration = childElement.addElement("registration");
registration.addElement("jid").setText(sipAccount.getUsername() + "@" + componentManager.getServerName());
registration.addElement("username").setText(sipAccount.getSipUsername());
registration.addElement("authUsername").setText(sipAccount.getAuthUsername());
registration.addElement("displayPhoneNum").setText(sipAccount.getDisplayName());
registration.addElement("password").setText(sipAccount.getPassword());
registration.addElement("server").setText(sipAccount.getServer());
registration.addElement("stunServer").setText(sipAccount.getStunServer());
registration.addElement("stunPort").setText(sipAccount.getStunPort());
registration.addElement("useStun").setText(String.valueOf(sipAccount.isUseStun()));
registration.addElement("voicemail").setText(sipAccount.getVoiceMailNumber());
registration.addElement("enabled").setText(String.valueOf(sipAccount.isEnabled()));
registration.addElement("outboundproxy").setText(sipAccount.getOutboundproxy());
registration.addElement("promptCredentials").setText(String.valueOf(sipAccount.isPromptCredentials()));
} else {
// No SIP mapping was found
reply.getChildElement().addAttribute("type", "unregistered");
}
} else {
if (sipAccount != null) {
Element status = iq.getChildElement().element("status");
if (!status.getTextTrim().equals("")) {
sipAccount.setStatus(SipRegisterStatus.valueOf(status.getTextTrim()));
try {
SipAccountDAO.update(sipAccount);
} catch (SQLException e) {
Log.error(e.getMessage(), e);
}
}
}
}
}
} else {
// Answer an error since the server can't handle the requested
// namespace
reply.setError(PacketError.Condition.service_unavailable);
}
try {
componentManager.sendPacket(this, reply);
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
Log.debug("PACKET SENT: " + reply.toXML());
}
use of org.dom4j.Element in project hibernate-orm by hibernate.
the class RevisionInfoConfiguration method generateRevisionInfoRelationMapping.
private Element generateRevisionInfoRelationMapping() {
final Document document = globalCfg.getEnversService().getXmlHelper().getDocumentFactory().createDocument();
final Element revRelMapping = document.addElement("key-many-to-one");
revRelMapping.addAttribute("type", revisionPropType);
revRelMapping.addAttribute("class", revisionInfoEntityName);
if (revisionPropSqlType != null) {
// Putting a fake name to make Hibernate happy. It will be replaced later anyway.
MetadataTools.addColumn(revRelMapping, "*", null, null, null, revisionPropSqlType, null, null, false);
}
return revRelMapping;
}
use of org.dom4j.Element in project hibernate-orm by hibernate.
the class AuditMetadataGenerator method addRevisionType.
void addRevisionType(Element anyMapping, Element anyMappingEnd, boolean isKey) {
final Element revTypeProperty = MetadataTools.addProperty(anyMapping, verEntCfg.getRevisionTypePropName(), verEntCfg.getRevisionTypePropType(), true, isKey);
revTypeProperty.addAttribute("type", "org.hibernate.envers.internal.entities.RevisionTypeType");
// Adding the end revision, if appropriate
addEndRevision(anyMappingEnd);
}
Aggregations