/** * Convert an XMPPBean to an XMPPIQ to send it via the MXAProxy/MXA. * * @param bean the bean to convert * @param mergePayload true if the playload should be merged * @return the XMPPIQ */ public XMPPIQ beanToIQ(XMPPBean bean, boolean mergePayload) { // default XMPP IQ type int type = XMPPIQ.TYPE_GET; switch (bean.getType()) { case XMPPBean.TYPE_GET: type = XMPPIQ.TYPE_GET; break; case XMPPBean.TYPE_SET: type = XMPPIQ.TYPE_SET; break; case XMPPBean.TYPE_RESULT: type = XMPPIQ.TYPE_RESULT; break; case XMPPBean.TYPE_ERROR: type = XMPPIQ.TYPE_ERROR; break; } XMPPIQ iq; if (mergePayload) iq = new XMPPIQ(bean.getFrom(), bean.getTo(), type, null, null, bean.toXML()); else iq = new XMPPIQ( bean.getFrom(), bean.getTo(), type, bean.getChildElement(), bean.getNamespace(), bean.payloadToXML()); iq.packetID = bean.getId(); return iq; }
/** * Formats a Bean to a string. * * @param bean the bean * @return the formatted string of the Bean */ public String beanToString(XMPPBean bean) { String str = "XMPPBean: [NS=" + bean.getNamespace() + " id=" + bean.getId() + " from=" + bean.getFrom() + " to=" + bean.getTo() + " type=" + bean.getType() + " payload=" + bean.payloadToXML(); if (bean.errorCondition != null) str += " errorCondition=" + bean.errorCondition; if (bean.errorText != null) str += " errorText=" + bean.errorText; if (bean.errorType != null) str += " errorType=" + bean.errorType; str += "]"; return str; }