Search in sources :

Example 1 with FastList

use of javolution.util.FastList in project smscgateway by RestComm.

the class DBOperations method c2_getSipSmsRoutingRulesRange.

/**
 * Returns 100 rows of SIP_SMS_ROUTING_RULE starting from passed lastAdress. If lastAdress, first 100 rows are returned
 *
 * @param lastAdress
 * @return
 * @throws PersistenceException
 */
public List<DbSmsRoutingRule> c2_getSipSmsRoutingRulesRange(String lastAdress) throws PersistenceException {
    List<DbSmsRoutingRule> ress = new FastList<DbSmsRoutingRule>();
    try {
        PreparedStatement ps = lastAdress != null ? getSipSmsRoutingRulesRange : getSipSmsRoutingRulesRange2;
        BoundStatement boundStatement = new BoundStatement(ps);
        if (lastAdress != null) {
            boundStatement.bind(lastAdress);
        }
        ResultSet result = session.execute(boundStatement);
        int i1 = 0;
        for (Row row : result) {
            String address = row.getString(Schema.COLUMN_ADDRESS);
            String name = row.getString(Schema.COLUMN_CLUSTER_NAME);
            int networkId = row.getInt(Schema.COLUMN_NETWORK_ID);
            DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SIP, address, networkId, name);
            if (i1 == 0) {
                i1 = 1;
                if (lastAdress == null)
                    ress.add(res);
            } else {
                ress.add(res);
            }
        }
        return ress;
    } catch (Exception e) {
        String msg = "Failed to getSmsRoutingRule DbSmsRoutingRule for all records: " + e;
        throw new PersistenceException(msg, e);
    }
}
Also used : FastList(javolution.util.FastList) ResultSet(com.datastax.driver.core.ResultSet) PreparedStatement(com.datastax.driver.core.PreparedStatement) Row(com.datastax.driver.core.Row) DbSmsRoutingRule(org.mobicents.smsc.library.DbSmsRoutingRule) BoundStatement(com.datastax.driver.core.BoundStatement) XMLStreamException(javolution.xml.stream.XMLStreamException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException)

Example 2 with FastList

use of javolution.util.FastList 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 3 with FastList

use of javolution.util.FastList 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 4 with FastList

use of javolution.util.FastList 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 FastList

use of javolution.util.FastList 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

FastList (javolution.util.FastList)18 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)12 Sms (org.mobicents.smsc.library.Sms)10 MProcRule (org.mobicents.smsc.mproc.MProcRule)9 TargetAddress (org.mobicents.smsc.library.TargetAddress)6 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 XMLStreamException (javolution.xml.stream.XMLStreamException)4 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 BoundStatement (com.datastax.driver.core.BoundStatement)2 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 ResultSet (com.datastax.driver.core.ResultSet)2 Row (com.datastax.driver.core.Row)2 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2