Search in sources :

Example 1 with MProcResult

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

the class MProcManagement method applyMProcImsiRequest.

public MProcResult applyMProcImsiRequest(final MProcRuleRaProvider anMProcRuleRa, Sms sms, String imsi, String nnnDigits, int nnnNumberingPlan, int nnnAddressNature) {
    if (this.mprocs.size() == 0)
        return new MProcResult();
    FastList<MProcRule> cur = this.mprocs;
    PostImsiProcessorImpl pap = new PostImsiProcessorImpl(logger);
    MProcMessage message = new MProcMessageImpl(sms, ProcessingType.SS7_SRI, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostImsiRequestState() && rule.matchesPostImsiRequest(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at ImsiRequest phase to a message:\nrule: " + rule + "\nmessage: " + sms);
                }
                rule.onPostImsiRequest(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcImsiRequest(): " + e.getMessage(), e);
        return new MProcResult();
    }
    if (pap.isNeedDropMessages()) {
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    if (pap.isNeedRerouteMessages()) {
        MProcResult res = new MProcResult();
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
        return res;
    }
    return new MProcResult();
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) FastList(javolution.util.FastList) MProcMessage(org.mobicents.smsc.mproc.MProcMessage) PostImsiProcessorImpl(org.mobicents.smsc.mproc.impl.PostImsiProcessorImpl)

Example 2 with MProcResult

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

the class MProcManagement method applyMProcHrSri.

public MProcResult applyMProcHrSri(final MProcRuleRaProvider anMProcRuleRa, CorrelationIdValue correlationIdValue) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostHrSriProcessorImpl pap = new PostHrSriProcessorImpl(logger);
    MProcMessage message = new MProcMessageHrImpl(correlationIdValue);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostHrSriState() && rule.matchesPostHrSri(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at HrSri phase to a message:\nrule: " + rule + "\ncorrelationIdValue: " + correlationIdValue);
                }
                rule.onPostHrSri(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostHrSri(): " + e.getMessage(), e);
        return new MProcResult();
    }
    MProcResult res = new MProcResult();
    if (pap.isHrByPassed()) {
        res.setHrIsByPassed(true);
    }
    return res;
}
Also used : MProcMessageHrImpl(org.mobicents.smsc.mproc.impl.MProcMessageHrImpl) MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) FastList(javolution.util.FastList) MProcMessage(org.mobicents.smsc.mproc.MProcMessage) PostHrSriProcessorImpl(org.mobicents.smsc.mproc.impl.PostHrSriProcessorImpl)

Example 3 with MProcResult

use of org.mobicents.smsc.mproc.impl.MProcResult 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:\nrule: " + rule + "\nmessage: " + 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 4 with MProcResult

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

the class DeliveryCommonSbb method applyMProcPreDelivery.

private boolean applyMProcPreDelivery(Sms sms, ProcessingType processingType) {
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcPreDelivery(itsMProcRa, sms, processingType);
    if (mProcResult.isMessageIsRerouted()) {
        // firstly we check if rerouting attempts was not too many
        if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
            StringBuilder sb = new StringBuilder();
            sb.append("Rerouting message attempt in PreDelivery, but we have already rerouted ");
            sb.append(MAX_POSSIBLE_REROUTING);
            sb.append(" times before: targetId=");
            sb.append(sms.getSmsSet().getTargetId());
            sb.append(", newNetworkId=");
            sb.append(mProcResult.getNewNetworkId());
            sb.append(", sms=");
            sb.append(sms);
            this.logger.warning(sb.toString());
            return false;
        } else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
            // we do not reroute for the same networkId
            return true;
        } else {
            ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
            ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
            lstRerouted.add(sms);
            lstNewNetworkId.add(mProcResult.getNewNetworkId());
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Rerouting message in PreDelivery: targetId=");
                sb.append(sms.getSmsSet().getTargetId());
                sb.append(", newNetworkId=");
                sb.append(mProcResult.getNewNetworkId());
                sb.append(", sms=");
                sb.append(sms);
                this.logger.info(sb.toString());
            }
            postProcessRerouted(lstRerouted, lstNewNetworkId);
            return false;
        }
    } else if (mProcResult.isMessageDropped()) {
        if (this.logger.isInfoEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("Dropping message after in PreDelivery: targetId=");
            sb.append(sms.getSmsSet().getTargetId());
            sb.append(", sms=");
            sb.append(sms);
            this.logger.info(sb.toString());
        }
        ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
        lstPermFailured.add(sms);
        ErrorCode smStatus = ErrorCode.MPROC_PRE_DELIVERY_DROP;
        ErrorAction errorAction = ErrorAction.permanentFailure;
        String reason = "Message drop in PreDelivery";
        sms.getSmsSet().setStatus(smStatus);
        // sending of a failure response for transactional mode
        this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
        // Processing messages that were temp or permanent failed or rerouted
        this.postProcessPermFailures(lstPermFailured, null, null);
        // generating CDRs for permanent failure messages
        this.generateCDRs(lstPermFailured, CdrGenerator.CDR_MPROC_DROP_PRE_DELIVERY, reason);
        EsmeManagement esmeManagement = EsmeManagement.getInstance();
        Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
        String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
        this.generateDetailedCDRs(lstPermFailured, EventType.OUT_SMPP_ERROR, smStatus, messageType, esme.getRemoteAddressAndPort(), -1);
        // sending of failure delivery receipts
        this.generateFailureReceipts(sms.getSmsSet(), lstPermFailured, null);
        return false;
    }
    FastList<Sms> addedMessages = mProcResult.getMessageList();
    if (addedMessages != null) {
        for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
            Sms smst = n.getValue();
            TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
            this.sendNewGeneratedMessage(smst, ta);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Posting of a new message after PreDelivery: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
    return true;
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) Esme(org.restcomm.smpp.Esme) ArrayList(java.util.ArrayList) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) ErrorAction(org.mobicents.smsc.library.ErrorAction) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) ErrorCode(org.mobicents.smsc.library.ErrorCode)

Example 5 with MProcResult

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

the class DeliveryCommonSbb method applyMprocRulesOnSuccess.

// *********
// applying of mproc rules
/**
 * mproc rules applying for delivery phase for success case
 *
 * @param sms
 * @param processingType
 */
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
    // PostDeliveryProcessor - success case
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
    FastList<Sms> addedMessages = mProcResult.getMessageList();
    if (addedMessages != null) {
        for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
            Sms smst = n.getValue();
            TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
            this.sendNewGeneratedMessage(smst, ta);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Posting of a new message after DeliverySuccess: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress)

Aggregations

MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)14 FastList (javolution.util.FastList)12 Sms (org.mobicents.smsc.library.Sms)11 TargetAddress (org.mobicents.smsc.library.TargetAddress)6 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)6 MProcRule (org.mobicents.smsc.mproc.MProcRule)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 Esme (org.restcomm.smpp.Esme)4 EsmeManagement (org.restcomm.smpp.EsmeManagement)4 ArrayList (java.util.ArrayList)2 CreateException (javax.slee.CreateException)2 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)2 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)2 ErrorAction (org.mobicents.smsc.library.ErrorAction)2 ErrorCode (org.mobicents.smsc.library.ErrorCode)2 EventType (org.mobicents.smsc.library.EventType)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)1