public void toNMS()

in bindings/servicemix-smpp/src/main/java/org/apache/servicemix/smpp/marshaler/DefaultSmppMarshaler.java [210:298]


    public void toNMS(NormalizedMessage message, MessageRequest mr) throws MessagingException {
        if (message == null) {
            throw new MessagingException("The NormalizedMessage is null");
        }

        if (mr == null) {
            throw new MessagingException("The MessageRequest is null");
        }

        if (mr.getSourceAddr() == null || mr.getSourceAddr().trim().length() < 1) {
            logger.error("The MessageRequest source address is not defined");
            throw new MessagingException("The MessageRequest source address is not defined");
        }

        if (mr.getDestAddress() == null || mr.getDestAddress().trim().length() < 1) {
            logger.error("The MessageRequest destination address is not defined");
            throw new MessagingException("The MessageRequest destination address is not defined");
        }

        try {
            NumberingPlanIndicator.valueOf(mr.getDestAddrNpi());
        } catch (IllegalArgumentException illegalArgumentException) {
            logger.error("The MessageRequest destination numbering plan indicator is not valid");
            throw new MessagingException("The MessageRequest destination numbering plan indicator is not valid");
        }

        try {
            TypeOfNumber.valueOf(mr.getDestAddrTon());
        } catch (IllegalArgumentException illegalArgumentException) {
            logger.error("The MessageRequest destination type of number is not valid");
            throw new MessagingException("The MessageRequest destination type of number is not valid");
        }

        try {
            determineSMSCDeliveryReceipt(mr.getRegisteredDelivery());
        } catch (IllegalArgumentException illegalArgumentException) {
            logger.error("The MessageRequest registered delivery is not valid");
            throw new MessagingException("The MessageRequest registered delivery is not valid");
        }

        if (mr.getShortMessage() == null || mr.getShortMessage().length == 0) {
            logger.warn("Received message without text content. Ignore the message");
            return;
        }

        StringBuffer data = new StringBuffer();
        data.append(TAG_MESSAGE_OPEN);

        data.append(TAG_SOURCE_OPEN);
        data.append(mr.getSourceAddr());
        data.append(TAG_SOURCE_CLOSE);

        data.append(TAG_DESTINATION_OPEN);
        data.append(mr.getDestAddress());
        data.append(TAG_DESTINATION_CLOSE);

        data.append(TAG_TEXT_OPEN);
        data.append(new String(mr.getShortMessage()));
        data.append(TAG_TEXT_CLOSE);

        data.append(TAG_NPI_OPEN);
        data.append(NumberingPlanIndicator.valueOf(mr.getDestAddrNpi()).toString());
        data.append(TAG_NPI_CLOSE);

        data.append(TAG_TON_OPEN);
        data.append(TypeOfNumber.valueOf(mr.getDestAddrTon()).toString());
        data.append(TAG_TON_CLOSE);

        data.append(TAG_REGISTERED_DELIVERY_OPEN);
        data.append(determineSMSCDeliveryReceipt(mr.getRegisteredDelivery()).toString());
        data.append(TAG_REGISTERED_DELIVERY_CLOSE);

        if (mr.getScheduleDeliveryTime() != null && mr.getScheduleDeliveryTime().trim().length() > 0) {
            data.append(TAG_SCHEDULE_DELIVERY_TIME_OPEN);
            data.append(mr.getScheduleDeliveryTime());
            data.append(TAG_SCHEDULE_DELIVERY_TIME_CLOSE);
        }

        if (mr.getValidityPeriod() != null && mr.getValidityPeriod().trim().length() > 0) {
            data.append(TAG_VALIDITY_PERIOD_OPEN);
            data.append(mr.getValidityPeriod());
            data.append(TAG_VALIDITY_PERIOD_CLOSE);
        }

        data.append(TAG_MESSAGE_CLOSE);

        message.setContent(new StringSource(data.toString()));
        applyOptionalParametersToNormalizedMessage(mr, message);
    }