private SoapFault createFault(NormalizedMessage nm) { Source src = nm.getContent(); QName code = (QName) nm.getProperty(JbiConstants.SOAP_FAULT_CODE); QName subcode = (QName) nm.getProperty(JbiConstants.SOAP_FAULT_SUBCODE); String reason = (String) nm.getProperty(JbiConstants.SOAP_FAULT_REASON); URI node = (URI) nm.getProperty(JbiConstants.SOAP_FAULT_NODE); URI role = (URI) nm.getProperty(JbiConstants.SOAP_FAULT_ROLE); SoapFault fault = new SoapFault(code, subcode, reason, node, role, src); return fault; }
private static void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (Object name : from.getPropertyNames()) { to.setProperty((String)name, from.getProperty((String)name)); } }
/** * Copies properties from one message to another that do not already exist * * @param from the message containing the properties * @param to the destination message where the properties are set */ protected void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (String propertyName : (Set<String>) from.getPropertyNames()) { // Do not copy existing properties or transient properties if (to.getProperty(propertyName) == null && !PojoMarshaler.BODY.equals(propertyName)) { Object value = from.getProperty(propertyName); to.setProperty(propertyName, value); } } }
@SuppressWarnings("unchecked") private void copyHeaderInformation(NormalizedMessage nm, PostMethod method) { Map<String, String> headers = (Map<String, String>) nm.getProperty(JbiConstants.PROTOCOL_HEADERS); if (headers != null) { for (String name : headers.keySet()) { String value = headers.get(name); method.addRequestHeader(name, value); } } }
/** * Copies properties from one message to another that do not already exist * * @param from the message containing the properties * @param to the destination message where the properties are set */ protected void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (String propertyName : (Set<String>) from.getPropertyNames()) { // Do not copy existing properties or transient properties if (to.getProperty(propertyName) == null && !PojoMarshaler.BODY.equals(propertyName)) { Object value = from.getProperty(propertyName); to.setProperty(propertyName, value); } } }
private Long getSequenceNumber(MessageExchange exchange) { Object number = exchange.getMessage(IN).getProperty(sequenceNumberKey); if (number instanceof Long) { return (Long) number; } else { return Long.parseLong(number.toString()); } }
protected void addMessagePropertiesToDocument(NormalizedMessage nm, Document document, String type) throws MessagingException { Set propertyNames = nm.getPropertyNames(); for (Iterator iter = propertyNames.iterator(); iter.hasNext();) { String propertyName = (String) iter.next(); Object value = nm.getProperty(propertyName); if (value instanceof String) { //org.apache.servicemix.out.myproperty document.add(Field.Keyword("org.apache.servicemix." + type + "." + propertyName, String.valueOf(value))); } } }
/** * Copy NormalizedMessage headers to SoapMessage headers */ @SuppressWarnings("unchecked") private void fromNMSHeaders(Message message, NormalizedMessage normalizedMessage) { if (normalizedMessage.getProperty(JbiConstants.PROTOCOL_HEADERS) != null) { Map<String, ?> headers = (Map<String, ?>) normalizedMessage.getProperty(JbiConstants.PROTOCOL_HEADERS); for (Map.Entry<String, ?> entry : headers.entrySet()) { QName name = QNameUtil.parse(entry.getKey()); if (name != null) { message.getSoapHeaders().put(name, (DocumentFragment) entry.getValue()); } else { message.getTransportHeaders().put(entry.getKey(), (String) entry.getValue()); } } } }
/** * Copies all of the properties from one message to another * * @param from the message containing the properties * @param to the destination messages where the properties are set */ public static void copyProperties(NormalizedMessage from, NormalizedMessage to) { for (Iterator iter = from.getPropertyNames().iterator(); iter.hasNext();) { String name = (String) iter.next(); // Do not copy transient properties if (!PojoMarshaler.BODY.equals(name)) { Object value = from.getProperty(name); to.setProperty(name, value); } } }
/** * Check if the ws addressing properties are present * * @param exchange * @return */ public static boolean checkWsaProperties(final Exchange exchange) { // Retrieve "from" address final String fromAddress = (String) exchange.getInMessage().getProperty( MailConstants.MailWSAddressing.FROM_QNAME.toString()); // Retrieve "to" Address final String toAddress = (String) exchange.getInMessage().getProperty( MailConstants.MailWSAddressing.TO_QNAME.toString()); if (!StringHelper.isNullOrEmpty(fromAddress) || !StringHelper.isNullOrEmpty(toAddress)) { return true; } return false; }
private void writeNormalizedMessage(NormalizedMessage message) { for (Object key : message.getPropertyNames()) { writeProperty(key, message.getProperty(key.toString())); } println(); println("- content -"); }
protected void assertMessageHeader(MessageList messageList, int index, String propertyName, Object expectedValue) { NormalizedMessage message = (NormalizedMessage) messageList.getMessages().get(index); assertNotNull("Message: " + index + " is null!", message); Object value = message.getProperty(propertyName); assertEquals("property: " + propertyName, expectedValue, value); }
/** * A utility method to copy properties from the input of the original * exchange to the output of the original exchange. * * @param exchange * @param srcMessage * @param @dstMessage * @throws Exception */ private void copyExchangeProperties(MessageExchange exchange, String srcMessage, String dstMessage) { NormalizedMessage src = exchange.getMessage(srcMessage); NormalizedMessage dst = exchange.getMessage(dstMessage); for (Iterator iter = src.getPropertyNames().iterator(); iter.hasNext();) { String name = (String) iter.next(); if (dst.getProperty(name) == null) { Object prop = src.getProperty(name); dst.setProperty(name, prop); } } }
public void buildAggregate(Object aggregation, NormalizedMessage message, MessageExchange exchange, boolean timeout) throws Exception { super.buildAggregate(aggregation, message, exchange, timeout); Object correlationId = message.getProperty(AbstractSplitter.SPLITTER_CORRID); message.setProperty(AbstractSplitter.SPLITTER_CORRID, null); message.setProperty(StaticRecipientList.RECIPIENT_LIST_CORRID, correlationId); }
/** * Copy properties from JBI message to JMS message. * * @param outMessage Received JBI message. * @param message Created JMS message. * @throws JMSException If there is any problems with saving JMS message * properties. */ @SuppressWarnings("unchecked") protected void copyPropertiesFromNM(NormalizedMessage outMessage, Message message) throws JMSException { Set<String> names = outMessage.getPropertyNames(); for (String name : names) { Object value = outMessage.getProperty(name); if (!isBlackListed(name)) { if (shouldIncludeHeader(name, value)) { message.setObjectProperty(name, value); } } } }
public Object chooseDestination(MessageExchange exchange, Object message) { Object property = null; if (message instanceof NormalizedMessage) { property = ((NormalizedMessage) message).getProperty(DESTINATION_KEY); } if (property instanceof Destination) { return (Destination) property; } if (property instanceof String) { return (String) property; } if (getDefaultDestination() != null) { return getDefaultDestination(); } return getDefaultDestinationName(); }
public static void transfer(NormalizedMessage source, NormalizedMessage dest) throws MessagingException { dest.setContent(source.getContent()); for (Iterator it = source.getPropertyNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.setProperty(name, source.getProperty(name)); } for (Iterator it = source.getAttachmentNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.addAttachment(name, source.getAttachment(name)); } dest.setSecuritySubject(source.getSecuritySubject()); }
/** * A helper method to return the body of the message as a POJO which could be a * bean or some DOMish model of the body. * * @param message the message on which to extract the body * @param marshaller the marshaller used to map from the XML representation to the POJO * @return the body of the message as a POJO or DOM object * @throws javax.jbi.messaging.MessagingException * */ public static Object getBody(NormalizedMessage message, PojoMarshaler marshaller) throws MessagingException { Source content = message.getContent(); if (content instanceof JavaSource) { JavaSource source = (JavaSource) content; return source.getObject(); } if (message instanceof NormalizedMessageImpl) { return ((NormalizedMessageImpl) message).getBody(marshaller); } return message.getProperty(PojoMarshaler.BODY); }
public static void transfer(NormalizedMessage source, NormalizedMessage dest) throws MessagingException { dest.setContent(source.getContent()); for (Iterator it = source.getPropertyNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.setProperty(name, source.getProperty(name)); } for (Iterator it = source.getAttachmentNames().iterator(); it.hasNext();) { String name = (String) it.next(); dest.addAttachment(name, source.getAttachment(name)); } dest.setSecuritySubject(source.getSecuritySubject()); }
protected Message fromNMS(NormalizedMessage nm, Session session) throws Exception { SoapMessage soap = new SoapMessage(); soapHelper.getJBIMarshaler().fromNMS(soap, nm); Map headers = (Map) nm.getProperty(JbiConstants.PROTOCOL_HEADERS); return endpoint.getMarshaler().toJMS(soap, headers, session); }