use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class NN_DBOper method createSms.
protected Sms createSms(final Row row, SmsSet smsSet) throws PersistenceException {
if (row == null)
return null;
Sms sms = new Sms();
sms.setDbId(row.getUUID(Schema.COLUMN_ID));
String srcAddr = null;
int srcAddrTon = -1;
int srcAddrNpi = -1;
srcAddr = row.getString(Schema.COLUMN_ADDR_SRC_DIGITS);
srcAddrTon = row.getInt(Schema.COLUMN_ADDR_SRC_TON);
srcAddrNpi = row.getInt(Schema.COLUMN_ADDR_SRC_NPI);
sms.setMessageId(row.getLong(Schema.COLUMN_MESSAGE_ID));
sms.setMoMessageRef(row.getInt(Schema.COLUMN_MO_MESSAGE_REF));
sms.setOrigEsmeName(row.getString(Schema.COLUMN_ORIG_ESME_NAME));
sms.setOrigSystemId(row.getString(Schema.COLUMN_ORIG_SYSTEM_ID));
sms.setSubmitDate(DBOperations.getRowDate(row, Schema.COLUMN_SUBMIT_DATE));
sms.setSourceAddr(row.getString(Schema.COLUMN_ADDR_SRC_DIGITS));
sms.setSourceAddrTon(row.getInt(Schema.COLUMN_ADDR_SRC_TON));
sms.setSourceAddrNpi(row.getInt(Schema.COLUMN_ADDR_SRC_NPI));
sms.setServiceType(row.getString(Schema.COLUMN_SERVICE_TYPE));
sms.setEsmClass(row.getInt(Schema.COLUMN_ESM_CLASS));
sms.setProtocolId(row.getInt(Schema.COLUMN_PROTOCOL_ID));
sms.setPriority(row.getInt(Schema.COLUMN_PRIORITY));
sms.setRegisteredDelivery(row.getInt(Schema.COLUMN_REGISTERED_DELIVERY));
sms.setReplaceIfPresent(row.getInt(Schema.COLUMN_REPLACE));
sms.setDataCoding(row.getInt(Schema.COLUMN_DATA_CODING));
sms.setDefaultMsgId(row.getInt(Schema.COLUMN_DEFAULT_MSG_ID));
ByteBuffer bb = row.getBytes(Schema.COLUMN_MESSAGE);
byte[] buf = new byte[bb.limit() - bb.position()];
bb.get(buf);
sms.setShortMessage(buf);
sms.setScheduleDeliveryTime(DBOperations.getRowDate(row, Schema.COLUMN_SCHEDULE_DELIVERY_TIME));
sms.setValidityPeriod(DBOperations.getRowDate(row, Schema.COLUMN_VALIDITY_PERIOD));
sms.setDeliveryCount(row.getInt(Schema.COLUMN_DELIVERY_COUNT));
String s = row.getString(Schema.COLUMN_OPTIONAL_PARAMETERS);
if (s != null) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
XMLObjectReader reader = XMLObjectReader.newInstance(bais);
TlvSet copy = reader.read(TLV_SET, TlvSet.class);
sms.getTlvSet().clearAllOptionalParameter();
sms.getTlvSet().addAllOptionalParameter(copy.getOptionalParameters());
} catch (XMLStreamException e) {
String msg = "XMLStreamException when deserializing optional parameters for '" + sms.getDbId() + "'!";
throw new PersistenceException(msg, e);
}
}
if (smsSet == null) {
smsSet = new SmsSet();
String destAddr = null;
int destAddrTon = -1;
int destAddrNpi = -1;
destAddr = row.getString(Schema.COLUMN_ADDR_DST_DIGITS);
destAddrTon = row.getInt(Schema.COLUMN_ADDR_DST_TON);
destAddrNpi = row.getInt(Schema.COLUMN_ADDR_DST_NPI);
if (destAddr == null || destAddrTon == -1 || destAddrNpi == -1) {
throw new PersistenceException("destAddr or destAddrTon or destAddrNpi is absent for ID='" + sms.getDbId() + "'");
}
smsSet.setDestAddr(destAddr);
smsSet.setDestAddrTon(destAddrTon);
smsSet.setDestAddrNpi(destAddrNpi);
smsSet.updateDueDelay(row.getInt(Schema.COLUMN_DUE_DELAY));
}
smsSet.addSms(sms);
return sms;
}
use of org.mobicents.smsc.library.SmsSet 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.SmsSet 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);
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class SchedulerResourceAdaptor method fetchSchedulable.
protected OneWaySmsSetCollection fetchSchedulable(int maxRecordCount) throws PersistenceException {
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
// if (smscPropertiesManagement.getDatabaseType() == DatabaseType.Cassandra_1) {
// List<SmsSet> res0 = dbOperations_C1.fetchSchedulableSmsSets(maxRecordCount, this.tracer);
// OneWaySmsSetCollection res = new OneWaySmsSetCollection();
// res.setListSmsSet(res0);
// return res;
// } else {
long processedDueSlot = dbOperations_C2.c2_getCurrentDueSlot();
long possibleDueSlot = dbOperations_C2.c2_getIntimeDueSlot();
if (processedDueSlot >= possibleDueSlot) {
return new OneWaySmsSetCollection();
}
processedDueSlot++;
if (!dbOperations_C2.c2_checkDueSlotNotWriting(processedDueSlot)) {
return new OneWaySmsSetCollection();
}
ArrayList<SmsSet> lstS = dbOperations_C2.c2_getRecordList(processedDueSlot);
ArrayList<SmsSet> lst = dbOperations_C2.c2_sortRecordList(lstS);
OneWaySmsSetCollection res = new OneWaySmsSetCollection();
res.setListSmsSet(lst);
dbOperations_C2.c2_setCurrentDueSlot(processedDueSlot);
return res;
// }
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class CassandraTest method readDueSlotMessage.
public SmsSet readDueSlotMessage(long dueSlot, int opt) throws Exception {
// reading dueSlot
TargetAddress lock = this.sbb.obtainSynchroObject(ta2);
try {
synchronized (lock) {
sbb.c2_registerDueSlotWriting(dueSlot);
ArrayList<SmsSet> lst0, lst;
try {
lst0 = sbb.c2_getRecordList(dueSlot);
lst = sbb.c2_sortRecordList(lst0);
} finally {
sbb.c2_unregisterDueSlotWriting(dueSlot);
}
assertEquals(lst.size(), 1);
SmsSet smsSet = lst.get(0);
if (opt == 1) {
assertEquals(smsSet.getSmsCount(), 3);
Sms sms1 = smsSet.getSms(0);
Sms sms2 = smsSet.getSms(1);
Sms sms3 = smsSet.getSms(2);
assertEquals(sms1.getDueSlot(), dueSlot);
assertEquals(sms2.getDueSlot(), dueSlot);
assertEquals(sms3.getDueSlot(), dueSlot);
this.checkTestSms(1, sms1, id1, false);
this.checkTestSms(2, sms2, id2, false);
this.checkTestSms(3, sms3, id3, false);
assertEquals(smsSet.getCorrelationId(), "CI=100001000022222");
} else {
assertEquals(smsSet.getSmsCount(), 4);
Sms sms1 = smsSet.getSms(0);
Sms sms2 = smsSet.getSms(1);
Sms sms3 = smsSet.getSms(2);
assertEquals(sms1.getDueSlot(), dueSlot - 1);
assertEquals(sms2.getDueSlot(), dueSlot - 1);
assertEquals(sms3.getDueSlot(), dueSlot - 1);
this.checkTestSms(1, sms1, id1, false);
this.checkTestSms(2, sms2, id2, false);
this.checkTestSms(3, sms3, id3, false);
Sms sms5 = smsSet.getSms(3);
assertEquals(sms5.getDueSlot(), dueSlot);
this.checkTestSms(5, sms5, id5, false);
}
return smsSet;
}
} finally {
this.sbb.obtainSynchroObject(lock);
}
}
Aggregations