use of org.mobicents.smsc.library.Sms 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: rule: " + rule + "message: " + 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.library.Sms in project smscgateway by RestComm.
the class CassandraTest method testingMsgIsArchive.
@Test(groups = { "cassandra" })
public void testingMsgIsArchive() throws Exception {
if (!this.cassandraDbInited)
return;
Sms sms_a1 = this.createTestSms(1, ta1.getAddr(), id1);
SmsSet smsSet = sms_a1.getSmsSet();
archiveMessage2(smsSet);
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class CassandraTest method addingNewMessages.
public long addingNewMessages() throws Exception {
Date dt = new Date();
PreparedStatementCollection psc = sbb.getStatementCollection(dt);
// adding 3 messages for "1111"
TargetAddress lock = this.sbb.obtainSynchroObject(ta1);
long dueSlot;
try {
synchronized (lock) {
Sms sms_a1 = this.createTestSms(1, ta1.getAddr(), id1);
Sms sms_a2 = this.createTestSms(2, ta1.getAddr(), id2);
Sms sms_a3 = this.createTestSms(3, ta1.getAddr(), id3);
dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
if (dueSlot == 0 || dueSlot <= sbb.c2_getCurrentDueSlot()) {
dueSlot = sbb.c2_getDueSlotForNewSms();
sbb.c2_updateDueSlotForTargetId(ta1.getTargetId(), dueSlot);
}
sms_a1.setDueSlot(dueSlot);
sms_a2.setDueSlot(dueSlot);
sms_a3.setDueSlot(dueSlot);
sbb.c2_registerDueSlotWriting(dueSlot);
try {
sbb.c2_createRecordCurrent(sms_a1);
sbb.c2_createRecordCurrent(sms_a2);
sbb.c2_createRecordCurrent(sms_a3);
} finally {
sbb.c2_unregisterDueSlotWriting(dueSlot);
}
}
} finally {
this.sbb.obtainSynchroObject(lock);
}
// adding a messages for "1112"
lock = this.sbb.obtainSynchroObject(ta2);
try {
synchronized (lock) {
Sms sms_a1 = this.createTestSms(4, ta2.getAddr(), id4);
sbb.c2_updateDueSlotForTargetId(ta2.getTargetId(), dueSlot);
sms_a1.setDueSlot(dueSlot);
sbb.c2_registerDueSlotWriting(dueSlot);
try {
sbb.c2_createRecordCurrent(sms_a1);
} finally {
sbb.c2_unregisterDueSlotWriting(dueSlot);
}
}
} finally {
this.sbb.obtainSynchroObject(lock);
}
return dueSlot;
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class CassandraTest method archiveMessage.
public void archiveMessage(SmsSet smsSet, String[] remoteMessageId, String esmeId) throws Exception {
for (int i1 = 0; i1 < 3; i1++) {
Sms sms = smsSet.getSms(i1);
sms.getSmsSet().setType(SmType.SMS_FOR_SS7);
sms.getSmsSet().setImsi("12345678900000");
ISDNAddressStringImpl networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2223334444");
LocationInfoWithLMSIImpl locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
sms.getSmsSet().setLocationInfoWithLMSI(locationInfoWithLMSI);
sbb.c2_createRecordArchive(sms, remoteMessageId[i1], esmeId, true, true);
}
Sms sms = smsSet.getSms(0);
SmsProxy smsx = sbb.obtainArchiveSms(sms.getDueSlot(), sms.getSmsSet().getDestAddr(), sms.getDbId());
this.checkTestSms(1, smsx.sms, sms.getDbId(), true);
Sms smsy = sbb.c2_getRecordArchiveForMessageId(sms.getMessageId());
this.checkTestSms(1, smsy, sms.getDbId(), true);
Long messageId = sbb.c2_getMessageIdByRemoteMessageId(remoteMessageId[0], esmeId);
assertNotNull(messageId);
assertEquals((long) messageId, sms.getMessageId());
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class CassandraTest method readAlertMessage.
public void readAlertMessage() throws Exception {
Date dt = new Date();
PreparedStatementCollection psc = sbb.getStatementCollection(dt);
// reading "1112" for Alert
TargetAddress lock = this.sbb.obtainSynchroObject(ta2);
try {
synchronized (lock) {
long dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
if (dueSlot == 0) {
fail("Bad dueSlot for reading of ta2");
}
sbb.c2_registerDueSlotWriting(dueSlot);
SmsSet smsSet;
try {
smsSet = sbb.c2_getRecordListForTargeId(dueSlot, ta2.getTargetId());
ArrayList<SmsSet> lst0 = new ArrayList<SmsSet>();
lst0.add(smsSet);
ArrayList<SmsSet> lst = sbb.c2_sortRecordList(lst0);
} finally {
sbb.c2_unregisterDueSlotWriting(dueSlot);
}
assertEquals(smsSet.getSmsCount(), 1);
Sms sms = smsSet.getSms(0);
assertEquals(sms.getDueSlot(), dueSlot);
this.checkTestSms(4, sms, id4, false);
sbb.c2_updateInSystem(sms, DBOperations.IN_SYSTEM_INPROCESS, false);
}
} finally {
this.sbb.obtainSynchroObject(lock);
}
}
Aggregations