use of org.jsmpp.bean.MessageRequest in project camel by apache.
the class SmppMessage method createBody.
@Override
protected Object createBody() {
if (command instanceof MessageRequest) {
MessageRequest msgRequest = (MessageRequest) command;
byte[] shortMessage = msgRequest.getShortMessage();
if (shortMessage == null || shortMessage.length == 0) {
return null;
}
Alphabet alphabet = Alphabet.parseDataCoding(msgRequest.getDataCoding());
if (SmppUtils.is8Bit(alphabet)) {
return shortMessage;
}
String encoding = IOHelper.getCharsetName(getExchange(), false);
if (ObjectHelper.isEmpty(encoding) || !Charset.isSupported(encoding)) {
encoding = configuration.getEncoding();
}
try {
return new String(shortMessage, encoding);
} catch (UnsupportedEncodingException e) {
LOG.info("Unsupported encoding \"{}\". Using system default encoding.", encoding);
}
return new String(shortMessage);
}
return null;
}
Aggregations