/** * {@inheritDoc} */ @Override public Map<String, DataSource> getAttachmentMap() { return getMessage().getAttachmentMap(); }
/** * {@inheritDoc} */ @Override public Map<String, DataSource> getAttachmentMap() { return getMessage().getAttachmentMap(); }
@Test public void testGetAttachmentMap() throws Exception { _message.addAttachment("attach1", new DummyDS("attach1", "text/xml")); _message.addAttachment("attach2", new DummyDS("attach1", "text/xml")); Map<String, DataSource> attachments = _message.getAttachmentMap(); // make sure the attachments we added are in the map Assert.assertTrue(attachments.containsKey("attach1")); Assert.assertTrue(attachments.containsKey("attach2")); // make sure that modifications to the map are not reflected in the message // (i.e.) the returned map is not a direct reference attachments.remove("attach1"); Assert.assertNotNull(_message.getAttachment("attach1")); }
/** * {@inheritDoc} */ @Override public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception { Message sourceMessage = exchange.getMessage(); getContextMapper().mapTo(exchange.getContext(), target); org.apache.camel.Message targetMessage = target.getMessage(); if (!sourceMessage.getAttachmentMap().isEmpty()) { for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) { targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue())); } } ServiceOperation operation = exchange.getContract().getProviderOperation(); target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName()); target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType()); target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName()); targetMessage.setBody(sourceMessage.getContent()); return target; } }
/** * {@inheritDoc} */ @Override public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception { Message sourceMessage = exchange.getMessage(); getContextMapper().mapTo(exchange.getContext(), target); org.apache.camel.Message targetMessage = target.getMessage(); if (!sourceMessage.getAttachmentMap().isEmpty()) { for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) { targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue())); } } ServiceOperation operation = exchange.getContract().getProviderOperation(); target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName()); target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType()); target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName()); targetMessage.setBody(sourceMessage.getContent()); return target; } }
/** * Maps a SwitchYard exchange to a Camel exchange. Keep in mind that the camel message created * during mapping is *not* associate with the exchange. You need to call setIn() or setOut() * with the returned reference depending on your use case. * @param syExchange switchyard exchange * @param camelExchange camel exchange * @return mapped camel message */ public static DefaultMessage mapSwitchYardToCamel( org.switchyard.Exchange syExchange, org.apache.camel.Exchange camelExchange) { DefaultMessage camelMessage = new SwitchYardMessage(); camelMessage.setBody(syExchange.getMessage().getContent()); mapSwitchYardPropertiesToCamel(syExchange.getContext(), camelExchange, camelMessage); for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) { camelMessage.addAttachment(attachmentName, new DataHandler(syExchange.getMessage().getAttachment(attachmentName))); } return camelMessage; }
for (String name : message.getAttachmentMap().keySet()) { AttachmentPart apResponse = soapMessage.createAttachmentPart(); apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));
for (String name : message.getAttachmentMap().keySet()) { AttachmentPart apResponse = soapMessage.createAttachmentPart(); apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));
for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) { camelMessage.addAttachment(attachmentName, new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));