Search in sources :

Example 1 with MProcNewMessage

use of org.mobicents.smsc.mproc.MProcNewMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcDelivery.

public MProcResult applyMProcDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, boolean deliveryFailure, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryProcessorImpl pap = new PostDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger, deliveryFailure);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryState() && rule.matchesPostDelivery(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Delivery phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostDelivery(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDelivery(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : PostDeliveryProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl) MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 2 with MProcNewMessage

use of org.mobicents.smsc.mproc.MProcNewMessage in project smscgateway by RestComm.

the class MProcRuleDefaultImpl method onPostArrival.

@Override
public void onPostArrival(final MProcRuleRaProvider anMProcRuleRa, PostArrivalProcessor factory, MProcMessage message) throws Exception {
    if (this.dropOnArrival) {
        factory.dropMessage();
    }
    if (this.rejectOnArrival != null) {
        switch(this.rejectOnArrival) {
            case NONE:
                break;
            case DEFAULT:
                factory.rejectMessage();
                break;
            case UNEXPECTED_DATA_VALUE:
                factory.rejectMessage(SmppConstants.STATUS_INVSERTYP, MAPErrorCode.unexpectedDataValue, HttpCode.LOCAL_RESPONSE_2.getCode());
                break;
            case SYSTEM_FAILURE:
                factory.rejectMessage(SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, HttpCode.LOCAL_RESPONSE_3.getCode());
                break;
            case THROTTLING:
                factory.rejectMessage(SmppConstants.STATUS_THROTTLED, MAPErrorCode.resourceLimitation, HttpCode.LOCAL_RESPONSE_4.getCode());
                break;
            case FACILITY_NOT_SUPPORTED:
                factory.rejectMessage(SmppConstants.STATUS_X_P_APPN, MAPErrorCode.facilityNotSupported, HttpCode.LOCAL_RESPONSE_5.getCode());
                break;
            default:
                break;
        }
    }
    if (this.makeCopy) {
        MProcNewMessage copy = factory.createNewCopyMessage(message);
        factory.postNewMessage(copy);
    }
    if (this.newNetworkId != -1) {
        factory.updateMessageNetworkId(message, this.newNetworkId);
    }
    if (this.addDestDigPrefix != null && !this.addDestDigPrefix.equals("") && !this.addDestDigPrefix.equals("-1")) {
        String destAddr = this.getAddDestDigPrefix() + message.getDestAddr();
        factory.updateMessageDestAddr(message, destAddr);
    }
    if (this.addSourceDigPrefix != null && !this.addSourceDigPrefix.equals("") && !this.addSourceDigPrefix.equals("-1")) {
        String sourceAddr = this.getAddSourceDigPrefix() + message.getSourceAddr();
        factory.updateMessageSourceAddr(message, sourceAddr);
    }
    if (this.newDestNpi != -1) {
        factory.updateMessageDestAddrNpi(message, this.newDestNpi);
    }
    if (this.newDestTon != -1) {
        factory.updateMessageDestAddrTon(message, this.newDestTon);
    }
    if (this.newSourceAddr != null && !this.newSourceAddr.equals("") && !this.newSourceAddr.equals("-1")) {
        factory.updateMessageSourceAddr(message, this.newSourceAddr);
    }
    if (this.newSourceNpi != -1) {
        factory.updateMessageSourceAddrNpi(message, this.newSourceNpi);
    }
    if (this.newSourceTon != -1) {
        factory.updateMessageSourceAddrTon(message, this.newSourceTon);
    }
    if (this.mtLocalSccpGt != null && !this.mtLocalSccpGt.equals("") && !this.mtLocalSccpGt.equals("-1")) {
        factory.updateMessageMtLocalSccpGt(message, this.mtLocalSccpGt);
    }
    if (this.mtRemoteSccpTt != -1) {
        factory.updateMessageMtRemoteSccpTt(message, this.mtRemoteSccpTt);
    }
    if (this.tlvTagToRemove != -1) {
        factory.removeTlvParameter(message, this.tlvTagToRemove);
    }
    if (this.removeDestDigPrefix > 0) {
        String newAddr = MProcUtility.removeDestDigPrefix(message.getDestAddr(), removeDestDigPrefix);
        factory.updateMessageDestAddr(message, newAddr);
    }
}
Also used : MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage)

Example 3 with MProcNewMessage

use of org.mobicents.smsc.mproc.MProcNewMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcPreDelivery.

public MProcResult applyMProcPreDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostPreDeliveryProcessorImpl pap = new PostPreDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostPreDeliveryState() && rule.matchesPostPreDelivery(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at PreDelivery phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostPreDelivery(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostPreDelivery(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) PostPreDeliveryProcessorImpl(org.mobicents.smsc.mproc.impl.PostPreDeliveryProcessorImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 4 with MProcNewMessage

use of org.mobicents.smsc.mproc.MProcNewMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcArrival.

public MProcResult applyMProcArrival(final MProcRuleRaProvider anMProcRuleRa, Sms sms, PersistenseCommonInterface persistence) {
    if (this.mprocs.size() == 0) {
        FastList<Sms> res0 = new FastList<Sms>();
        res0.add(sms);
        MProcResult res = new MProcResult();
        res.setMessageList(res0);
        return res;
    }
    FastList<MProcRule> cur = this.mprocs;
    PostArrivalProcessorImpl pap = new PostArrivalProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, null, persistence);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostArrivalState() && rule.matchesPostArrival(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Arrival phase to a message: rule: " + rule + "message: " + sms);
                }
                pap.setRuleIdInProcessing(rule.getId());
                rule.onPostArrival(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcArrival: " + e.getMessage(), e);
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    res.setMessageList(res0);
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    if (pap.isNeedDropMessage()) {
        res.setMessageDropped(true);
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else if (pap.isNeedRejectMessage()) {
        res.setMessageRejected(true);
        // res.setMprocRejectingRuleId(pap.);
        res.setMapErrorCode(pap.getMapErrorCode());
        res.setHttpErrorCode(pap.getHttpErrorCode());
        res.setSmppErrorCode(pap.getSmppErrorCode());
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else {
        res0.add(sms);
    }
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) PostArrivalProcessorImpl(org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 5 with MProcNewMessage

use of org.mobicents.smsc.mproc.MProcNewMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcDeliveryTempFailure.

public MProcResult applyMProcDeliveryTempFailure(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryTempFailureProcessorImpl pap = new PostDeliveryTempFailureProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryTempFailureState() && rule.matchesPostDeliveryTempFailure(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at DeliveryTempFailure phase to a message: rule: " + rule + "message: " + sms);
                }
                rule.onPostDeliveryTempFailure(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDeliveryTempFailure(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) PostDeliveryTempFailureProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Aggregations

MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)5 FastList (javolution.util.FastList)4 Sms (org.mobicents.smsc.library.Sms)4 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)4 MProcRule (org.mobicents.smsc.mproc.MProcRule)4 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)4 PostArrivalProcessorImpl (org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl)1 PostDeliveryProcessorImpl (org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl)1 PostDeliveryTempFailureProcessorImpl (org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl)1 PostPreDeliveryProcessorImpl (org.mobicents.smsc.mproc.impl.PostPreDeliveryProcessorImpl)1