use of org.mobicents.smsc.mproc.impl.MProcResult 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.impl.MProcResult 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.impl.MProcResult 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.impl.MProcResult in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMProcPreDelivery.
private boolean applyMProcPreDelivery(Sms sms, ProcessingType processingType) {
MProcResult mProcResult = MProcManagement.getInstance().applyMProcPreDelivery(itsMProcRa, sms, processingType);
if (mProcResult.isMessageIsRerouted()) {
// firstly we check if rerouting attempts was not too many
if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message attempt in PreDelivery, but we have already rerouted ");
sb.append(MAX_POSSIBLE_REROUTING);
sb.append(" times before: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.warning(sb.toString());
return false;
} else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
// we do not reroute for the same networkId
return true;
} else {
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
lstRerouted.add(sms);
lstNewNetworkId.add(mProcResult.getNewNetworkId());
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
postProcessRerouted(lstRerouted, lstNewNetworkId);
return false;
}
} else if (mProcResult.isMessageDropped()) {
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Dropping message after in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
lstPermFailured.add(sms);
ErrorCode smStatus = ErrorCode.MPROC_PRE_DELIVERY_DROP;
ErrorAction errorAction = ErrorAction.permanentFailure;
String reason = "Message drop in PreDelivery";
sms.getSmsSet().setStatus(smStatus);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured, null, null);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured, CdrGenerator.CDR_MPROC_DROP_PRE_DELIVERY, reason);
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
this.generateDetailedCDRs(lstPermFailured, EventType.OUT_SMPP_ERROR, smStatus, messageType, esme.getRemoteAddressAndPort(), -1);
// sending of failure delivery receipts
this.generateFailureReceipts(sms.getSmsSet(), lstPermFailured, null);
return false;
}
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Posting of a new message after PreDelivery: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
return true;
}
use of org.mobicents.smsc.mproc.impl.MProcResult in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMprocRulesOnSuccess.
// *********
// applying of mproc rules
/**
* mproc rules applying for delivery phase for success case
*
* @param sms
* @param processingType
*/
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
// PostDeliveryProcessor - success case
MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Posting of a new message after DeliverySuccess: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
}
Aggregations