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;
}
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();
}
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);
}
}
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;
}
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;
}
Aggregations