Search in sources :

Example 1 with MessageRequest

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;
}
Also used : Alphabet(org.jsmpp.bean.Alphabet) MessageRequest(org.jsmpp.bean.MessageRequest) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Alphabet (org.jsmpp.bean.Alphabet)1 MessageRequest (org.jsmpp.bean.MessageRequest)1