use of org.mobicents.smsc.mproc.impl.MProcNewMessageImpl 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.MProcNewMessageImpl 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;
}
use of org.mobicents.smsc.mproc.impl.MProcNewMessageImpl in project smscgateway by RestComm.
the class MProcManagement method applyMProcArrival.
public MProcResult applyMProcArrival(final MProcRuleRaProvider anMProcRuleRa, Sms sms, PersistenseCommonInterface persistence) {
if (this.mprocs.size() == 0) {
FastList<Sms> res0 = new FastList<Sms>();
res0.add(sms);
MProcResult res = new MProcResult();
res.setMessageList(res0);
return res;
}
FastList<MProcRule> cur = this.mprocs;
PostArrivalProcessorImpl pap = new PostArrivalProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
MProcMessage message = new MProcMessageImpl(sms, null, persistence);
try {
for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
MProcRule rule = n.getValue();
if (rule.isForPostArrivalState() && rule.matchesPostArrival(message)) {
if (logger.isDebugEnabled()) {
logger.debug("MRule matches at Arrival phase to a message:\nrule: " + rule + "\nmessage: " + sms);
}
pap.setRuleIdInProcessing(rule.getId());
rule.onPostArrival(anMProcRuleRa, pap, message);
}
}
} catch (Throwable e) {
logger.error("Exception when invoking rule.matches(message) or applyMProcArrival: " + e.getMessage(), e);
MProcResult res = new MProcResult();
res.setMessageDropped(true);
return res;
}
MProcResult res = new MProcResult();
FastList<Sms> res0 = new FastList<Sms>();
res.setMessageList(res0);
FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
if (pap.isNeedDropMessage()) {
res.setMessageDropped(true);
res.setRuleIdDropReject(pap.getRuleIdDropReject());
} else if (pap.isNeedRejectMessage()) {
res.setMessageRejected(true);
// res.setMprocRejectingRuleId(pap.);
res.setMapErrorCode(pap.getMapErrorCode());
res.setHttpErrorCode(pap.getHttpErrorCode());
res.setSmppErrorCode(pap.getSmppErrorCode());
res.setRuleIdDropReject(pap.getRuleIdDropReject());
} else {
res0.add(sms);
}
for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
res0.add(newMsg.getSmsContent());
}
return res;
}
use of org.mobicents.smsc.mproc.impl.MProcNewMessageImpl in project smscgateway by RestComm.
the class MProcManagement method applyMProcPreDelivery.
public MProcResult applyMProcPreDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
if (this.mprocs.size() == 0) {
return new MProcResult();
}
FastList<MProcRule> cur = this.mprocs;
PostPreDeliveryProcessorImpl pap = new PostPreDeliveryProcessorImpl(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.isForPostPreDeliveryState() && rule.matchesPostPreDelivery(message)) {
if (logger.isDebugEnabled()) {
logger.debug("MRule matches at PreDelivery phase to a message:\nrule: " + rule + "\nmessage: " + sms);
}
rule.onPostPreDelivery(anMProcRuleRa, pap, message);
}
}
} catch (Throwable e) {
logger.error("Exception when invoking rule.matches(message) or onPostPreDelivery(): " + 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