Search in sources :

Example 6 with MProcRule

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

the class MProcManagement method modifyMProcRule.

@Override
public MProcRule modifyMProcRule(int mProcRuleId, String parametersString) throws Exception {
    logger.info("modifyMProcRule: id=" + mProcRuleId + ", parametersString=" + parametersString);
    MProcRule mProcRule = this.getMProcRuleById(mProcRuleId);
    if (mProcRule == null) {
        throw new Exception(String.format(MProcRuleOamMessages.MODIFY_MPROC_RULE_FAIL_NOT_EXIST, mProcRuleId));
    }
    mProcRule.updateRuleParameters(parametersString);
    this.store();
    return mProcRule;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) XMLStreamException(javolution.xml.stream.XMLStreamException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) FileNotFoundException(java.io.FileNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException)

Example 7 with MProcRule

use of org.mobicents.smsc.mproc.MProcRule 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 8 with MProcRule

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

the class SMSCShellExecutor method showMProc.

/**
 * Command is "show destroy <id>" or "show destroy"
 *
 * @param args
 * @return
 * @throws Exception
 */
private String showMProc(String[] args) throws Exception {
    if (args.length < 3 || args.length > 4) {
        return SMSCOAMMessages.INVALID_COMMAND;
    }
    // show of existing MProcRule / all MProcRule
    MProcManagement mProcManagement = MProcManagement.getInstance();
    if (args.length == 3) {
        FastList<MProcRule> lst = mProcManagement.getMProcRules();
        StringBuilder sb = new StringBuilder();
        if (lst.size() == 0) {
            sb.append(SMSCOAMMessages.MPROC_NO_RULES);
        } else {
            for (MProcRule rule : lst) {
                sb.append(rule.toString());
                sb.append("\n");
            }
        }
        return sb.toString();
    } else {
        int id = Integer.parseInt(args[3]);
        MProcRule rule = mProcManagement.getMProcRuleById(id);
        if (rule == null) {
            return String.format(SMSCOAMMessages.MPROC_NO_RULE, id);
        }
        return rule.toString();
    }
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule)

Example 9 with MProcRule

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

the class SMSCShellExecutor method addMProc.

/**
 * Command is mproc add factoryName <id> desttonmask <destination type of number> destnpimask <destination numbering plan
 * indicator> destdigmask <regular expression - destination number digits mask> originatingmask <mo | hr | esme | sip>
 * networkidmask <networkId value> percent <percent value> newnetworkid <new networkId value> newdestton <new destination
 * type of number> newdestnpi <new destination numbering plan indicator> addestdigprefix <prefix> mtlocalsccpgt
 * <new gt of a local sccp address of an mt message> mtremotesccptt <new tt for remote sccp address for mt message>
 * makecopy <false | true> droponarrival <true | false> rejectonarrival <NONE | DEFAULT | UNEXPECTED_DATA_VALUE
 * | SYSTEM_FAILURE | THROTTLING | FACILITY_NOT_SUPPORTED> remove_tlv <tlv tag key> removedestdigprefix <value>
 *
 * @param args
 * @return
 * @throws Exception
 */
private String addMProc(String[] args) throws Exception {
    if (args.length < 6 || args.length > 27) {
        return SMSCOAMMessages.INVALID_COMMAND;
    }
    // create new MProcRule
    MProcManagement mProcManagement = MProcManagement.getInstance();
    String factoryName = args[3];
    int id = Integer.parseInt(args[4]);
    MProcRule mProcRule = mProcManagement.getMProcRuleById(id);
    if (mProcRule != null) {
        return String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_ALREADY_EXIST, id);
    }
    String parametersString = this.assembleString(args, 5);
    mProcManagement.createMProcRule(id, factoryName, parametersString);
    return String.format(SMSCOAMMessages.MPROC_CREATE_SUCCESS, id);
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule)

Example 10 with MProcRule

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

MProcRule (org.mobicents.smsc.mproc.MProcRule)13 FastList (javolution.util.FastList)9 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)6 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 FileNotFoundException (java.io.FileNotFoundException)4 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)4 InstanceNotFoundException (javax.management.InstanceNotFoundException)4 MBeanRegistrationException (javax.management.MBeanRegistrationException)4 MalformedObjectNameException (javax.management.MalformedObjectNameException)4 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)4 XMLStreamException (javolution.xml.stream.XMLStreamException)4 Sms (org.mobicents.smsc.library.Sms)4 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 MProcRuleFactory (org.mobicents.smsc.mproc.MProcRuleFactory)2 TreeMap (java.util.TreeMap)1 MBeanServer (javax.management.MBeanServer)1 MProcMessageHrImpl (org.mobicents.smsc.mproc.impl.MProcMessageHrImpl)1 PostArrivalProcessorImpl (org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl)1