* @throws UnsupportedEncodingException if the encoding is not supported
*/
public SubmitSm createSubmitSm(Exchange exchange) throws UnsupportedEncodingException {
Message in = exchange.getIn();
SubmitSm submitSm = new SubmitSm();
submitSm.setShortMessage(exchange.getIn().getBody(String.class).getBytes(configuration.getEncoding()));
if (in.getHeaders().containsKey(DEST_ADDR)) {
submitSm.setDestAddress((String) in.getHeader(DEST_ADDR));
} else {
submitSm.setDestAddress(configuration.getDestAddr());
}
if (in.getHeaders().containsKey(DEST_ADDR_TON)) {
submitSm.setDestAddrTon((Byte) in.getHeader(DEST_ADDR_TON));
} else {
submitSm.setDestAddrTon(configuration.getDestAddrTon());
}
if (in.getHeaders().containsKey(DEST_ADDR_NPI)) {
submitSm.setDestAddrNpi((Byte) in.getHeader(DEST_ADDR_NPI));
} else {
submitSm.setDestAddrNpi(configuration.getDestAddrNpi());
}
if (in.getHeaders().containsKey(SOURCE_ADDR)) {
submitSm.setSourceAddr((String) in.getHeader(SOURCE_ADDR));
} else {
submitSm.setSourceAddr(configuration.getSourceAddr());
}
if (in.getHeaders().containsKey(SOURCE_ADDR_TON)) {
submitSm.setSourceAddrTon((Byte) in.getHeader(SOURCE_ADDR_TON));
} else {
submitSm.setSourceAddrTon(configuration.getSourceAddrTon());
}
if (in.getHeaders().containsKey(SOURCE_ADDR_NPI)) {
submitSm.setSourceAddrNpi((Byte) in.getHeader(SOURCE_ADDR_NPI));
} else {
submitSm.setSourceAddrNpi(configuration.getSourceAddrNpi());
}
if (in.getHeaders().containsKey(SERVICE_TYPE)) {
submitSm.setServiceType((String) in.getHeader(SERVICE_TYPE));
} else {
submitSm.setServiceType(configuration.getServiceType());
}
if (in.getHeaders().containsKey(REGISTERED_DELIVERY)) {
submitSm.setRegisteredDelivery((Byte) in.getHeader(REGISTERED_DELIVERY));
} else {
submitSm.setRegisteredDelivery(configuration.getRegisteredDelivery());
}
if (in.getHeaders().containsKey(PROTOCOL_ID)) {
submitSm.setProtocolId((Byte) in.getHeader(PROTOCOL_ID));
} else {
submitSm.setProtocolId(configuration.getProtocolId());
}
if (in.getHeaders().containsKey(PRIORITY_FLAG)) {
submitSm.setPriorityFlag((Byte) in.getHeader(PRIORITY_FLAG));
} else {
submitSm.setPriorityFlag(configuration.getPriorityFlag());
}
if (in.getHeaders().containsKey(SCHEDULE_DELIVERY_TIME)) {
submitSm.setScheduleDeliveryTime(timeFormatter.format((Date) in.getHeader(SCHEDULE_DELIVERY_TIME)));
}
if (in.getHeaders().containsKey(VALIDITY_PERIOD)) {
submitSm.setValidityPeriod(timeFormatter.format((Date) in.getHeader(VALIDITY_PERIOD)));
}
if (in.getHeaders().containsKey(REPLACE_IF_PRESENT_FLAG)) {
submitSm.setReplaceIfPresent((Byte) in.getHeader(REPLACE_IF_PRESENT_FLAG));
} else {
submitSm.setReplaceIfPresent(configuration.getReplaceIfPresentFlag());
}
if (in.getHeaders().containsKey(DATA_CODING)) {
System.out.println("1");
submitSm.setDataCoding((Byte) in.getHeader(DATA_CODING));
} else {
System.out.println("2");
submitSm.setDataCoding(configuration.getDataCoding());
}
return submitSm;
}