public SmppMessage createSmppMessage(DeliverSm deliverSm) throws Exception {
SmppMessage smppMessage = new SmppMessage(deliverSm, configuration);
if (deliverSm.isSmscDeliveryReceipt()) {
smppMessage.setHeader(MESSAGE_TYPE, SmppMessageType.DeliveryReceipt.toString());
DeliveryReceipt smscDeliveryReceipt = deliverSm.getShortMessageAsDeliveryReceipt();
smppMessage.setBody(smscDeliveryReceipt.getText());
smppMessage.setHeader(ID, smscDeliveryReceipt.getId());
smppMessage.setHeader(DELIVERED, smscDeliveryReceipt.getDelivered());
smppMessage.setHeader(DONE_DATE, smscDeliveryReceipt.getDoneDate());
if (!"000".equals(smscDeliveryReceipt.getError())) {
smppMessage.setHeader(ERROR, smscDeliveryReceipt.getError());
}
smppMessage.setHeader(SUBMIT_DATE, smscDeliveryReceipt.getSubmitDate());
smppMessage.setHeader(SUBMITTED, smscDeliveryReceipt.getSubmitted());
smppMessage.setHeader(FINAL_STATUS, smscDeliveryReceipt.getFinalStatus());
} else {
smppMessage.setHeader(MESSAGE_TYPE, SmppMessageType.DeliverSm.toString());
if (deliverSm.getShortMessage() != null) {
smppMessage.setBody(String.valueOf(new String(deliverSm.getShortMessage(),
configuration.getEncoding())));