Search in sources :

Example 1 with MProcRule

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

the class MProcManagement method destroyMProcRule.

@Override
public MProcRule destroyMProcRule(int mProcRuleId) throws Exception {
    logger.info("destroyMProcRule: id=" + mProcRuleId);
    MProcRule mProcRule = this.getMProcRuleById(mProcRuleId);
    if (mProcRule == null) {
        throw new Exception(String.format(MProcRuleOamMessages.DESTROY_MPROC_RULE_FAIL_NOT_EXIST, mProcRuleId));
    }
    FastList<MProcRule> lstTag = new FastList<MProcRule>(this.mprocs);
    lstTag.remove(mProcRule);
    this.resortRules(lstTag);
    this.store();
    this.unregisterMProcRuleMbean(mProcRule.getId());
    return mProcRule;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) FastList(javolution.util.FastList) 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 2 with MProcRule

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

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

the class MProcManagement method start.

public void start() throws Exception {
    this.smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    if (this.smscManagement != null) {
        for (MProcRuleFactory ruleFactory : this.smscManagement.getMProcRuleFactories2()) {
            this.bindAlias(ruleFactory);
        }
    }
    try {
        boolean servFound = false;
        String agentId = "jboss";
        List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
        if (servers != null && servers.size() > 0) {
            for (MBeanServer server : servers) {
                String defaultDomain = server.getDefaultDomain();
                if (defaultDomain != null && defaultDomain.equals(agentId)) {
                    mbeanServer = server;
                    servFound = true;
                    logger.info(String.format("Found MBeanServer matching for agentId=%s", agentId));
                } else {
                    logger.warn(String.format("Found non-matching MBeanServer with default domian = %s", defaultDomain));
                }
            }
        }
        if (!servFound) {
            this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
        }
        logger.info("servFound =" + servFound + ", this.mbeanServer = " + this.mbeanServer);
    } catch (Exception e) {
    }
    this.persistFile.clear();
    if (persistDir != null) {
        this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
    } else {
        persistFile.append(System.getProperty(SmscManagement.SMSC_PERSIST_DIR_KEY, System.getProperty(SmscManagement.USER_DIR_KEY))).append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
    }
    logger.info(String.format("Loading MProcRule configuration from %s", persistFile.toString()));
    try {
        this.load();
    } catch (FileNotFoundException e) {
        logger.warn(String.format("Failed to load the ProcRule configuration file. \n%s", e.getMessage()));
    }
    this.resortRules(this.mprocs);
    this.store();
    for (MProcRule rule : this.mprocs) {
        this.registerMProcRuleMbean(rule);
    }
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) FileNotFoundException(java.io.FileNotFoundException) MProcRuleFactory(org.mobicents.smsc.mproc.MProcRuleFactory) 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) MBeanServer(javax.management.MBeanServer)

Example 4 with MProcRule

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

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

the class MProcManagement method createMProcRule.

@Override
public MProcRule createMProcRule(int id, String ruleFactoryName, String parametersString) throws Exception {
    logger.info("createMProcRule: id=" + id + ", ruleFactoryName=" + ruleFactoryName + ", parametersString=" + parametersString);
    if (ruleFactoryName == null) {
        throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_RULE_CLASS_NAME_NULL_VALUE));
    }
    MProcRuleFactory ruleClass = null;
    if (this.smscManagement != null) {
        ruleClass = this.smscManagement.getRuleFactory(ruleFactoryName);
    }
    if (ruleClass == null) {
        throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_RULE_CLASS_NOT_FOUND, ruleFactoryName));
    }
    if (this.getMProcRuleById(id) != null) {
        throw new Exception(String.format(MProcRuleOamMessages.CREATE_MPROC_RULE_FAIL_ALREADY_EXIST, id));
    }
    MProcRule mProcRule = ruleClass.createMProcRuleInstance();
    mProcRule.setId(id);
    mProcRule.setInitialRuleParameters(parametersString);
    FastList<MProcRule> lstTag = new FastList<MProcRule>(this.mprocs);
    lstTag.add(mProcRule);
    this.resortRules(lstTag);
    this.store();
    this.registerMProcRuleMbean(mProcRule);
    return mProcRule;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) FastList(javolution.util.FastList) MProcRuleFactory(org.mobicents.smsc.mproc.MProcRuleFactory) 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)

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