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