Search in sources :

Example 66 with SmsSet

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;
}
Also used : XMLStreamException(javolution.xml.stream.XMLStreamException) ByteArrayInputStream(java.io.ByteArrayInputStream) Sms(org.mobicents.smsc.library.Sms) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) XMLObjectReader(javolution.xml.XMLObjectReader) TlvSet(org.restcomm.smpp.parameter.TlvSet) ByteBuffer(java.nio.ByteBuffer) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 67 with SmsSet

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);
}
Also used : Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 68 with 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);
    }
}
Also used : ArrayList(java.util.ArrayList) Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 69 with SmsSet

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;
// }
}
Also used : SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 70 with SmsSet

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);
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmsSet(org.mobicents.smsc.library.SmsSet)

Aggregations

SmsSet (org.mobicents.smsc.library.SmsSet)116 Sms (org.mobicents.smsc.library.Sms)61 Test (org.testng.annotations.Test)45 ArrayList (java.util.ArrayList)36 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)35 Date (java.util.Date)32 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)28 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)28 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)28 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)26 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)25 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)25 UUID (java.util.UUID)23 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)21 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)19 MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)18 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)17 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)17