/** * Populates the given XMPP packet from the inbound exchange */ public void populateXmppPacket(Packet packet, Exchange exchange) { Set<Map.Entry<String, Object>> entries = exchange.getIn().getHeaders().entrySet(); for (Map.Entry<String, Object> entry : entries) { String name = entry.getKey(); Object value = entry.getValue(); if (!headerFilterStrategy.applyFilterToCamelHeaders(name, value, exchange)) { try { JivePropertiesManager.addProperty(packet, name, value); LOG.debug("Added property name: " + name + " value: " + value.toString()); } catch (IllegalArgumentException iae) { LOG.debug("Not adding property " + name + " to XMPP message due to " + iae); } } } String id = exchange.getExchangeId(); if (id != null) { JivePropertiesManager.addProperty(packet, "exchangeId", id); } }
/** * Populates the given XMPP message from the inbound exchange */ public void populateXmppMessage(Message message, Exchange exchange) { message.setBody(exchange.getIn().getBody(String.class)); Set<Map.Entry<String, Object>> entries = exchange.getIn().getHeaders().entrySet(); for (Map.Entry<String, Object> entry : entries) { String name = entry.getKey(); Object value = entry.getValue(); if (!headerFilterStrategy.applyFilterToCamelHeaders(name, value, exchange)) { if ("subject".equalsIgnoreCase(name)) { // special for subject String subject = exchange.getContext().getTypeConverter().convertTo(String.class, value); message.setSubject(subject); } else if ("language".equalsIgnoreCase(name)) { // special for language String language = exchange.getContext().getTypeConverter().convertTo(String.class, value); message.setLanguage(language); } else { try { JivePropertiesManager.addProperty(message, name, value); LOG.trace("Added property name: {} value: {}", name, value.toString()); } catch (IllegalArgumentException iae) { if (LOG.isDebugEnabled()) { LOG.debug("Cannot add property " + name + " to XMPP message due: ", iae); } } } } } String id = exchange.getExchangeId(); if (id != null) { JivePropertiesManager.addProperty(message, "exchangeId", id); } }