Search in sources :

Example 71 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class CassandraToolForm method getData.

private void getData() {
    try {
        String tName = this.dbOperations.getTableName(new Date());
        String tbFam;
        int option = 0;
        if (this.rbLive.isSelected()) {
            tbFam = Schema.FAMILY_SLOT_MESSAGES_TABLE;
        } else if (this.rbArchive.isSelected()) {
            tbFam = Schema.FAMILY_MESSAGES;
        } else if (this.rbMsgId.isSelected()) {
            tbFam = Schema.FAMILY_MES_ID;
            option = 1;
        } else {
            tbFam = Schema.FAMILY_DLV_MES_ID;
            option = 2;
        }
        String s1 = "SELECT * FROM \"" + tbFam + tName + "\";";
        Session session = this.dbOperations.getSession();
        PreparedStatement ps = session.prepare(s1);
        BoundStatement boundStatement = new BoundStatement(ps);
        ResultSet res = session.execute(boundStatement);
        model.getDataVector().clear();
        model.rowsRemoved(new TableModelEvent(model));
        DateFormat df = new SimpleDateFormat("MM.dd HH:mm:ss");
        if (option == 0) {
            SortedMap<Long, ArrayList<SmsSet>> result = new TreeMap<Long, ArrayList<SmsSet>>();
            for (Row row : res) {
                SmsSet smsSet = this.dbOperations.createSms(row, null);
                if (smsSet != null) {
                    ArrayList<SmsSet> al = result.get(smsSet.getSms(0).getMessageId());
                    if (al == null) {
                        al = new ArrayList<SmsSet>();
                        result.put(smsSet.getSms(0).getMessageId(), al);
                    }
                    al.add(smsSet);
                }
            }
            for (ArrayList<SmsSet> al : result.values()) {
                for (SmsSet smsSet : al) {
                    ListSelectionModel l = tResult.getSelectionModel();
                    Vector newRow = new Vector();
                    newRow.add(smsSet.getTargetId());
                    newRow.add(smsSet.getSms(0).getDbId());
                    String reportDate = df.format(this.dbOperations.c2_getTimeForDueSlot(smsSet.getSms(0).getDueSlot()));
                    newRow.add(smsSet.getSms(0).getDueSlot() + " - " + reportDate);
                    newRow.add(smsSet.getSms(0).getMessageId());
                    newRow.add(smsSet.getInSystem());
                    newRow.add(smsSet.getSms(0).getDeliveryCount());
                    newRow.add(smsSet.getStatus());
                    Date dt = smsSet.getSms(0).getValidityPeriod();
                    if (dt != null)
                        reportDate = df.format(dt);
                    else
                        reportDate = "";
                    newRow.add(reportDate);
                    dt = smsSet.getSms(0).getScheduleDeliveryTime();
                    if (dt != null)
                        reportDate = df.format(dt);
                    else
                        reportDate = "";
                    newRow.add(reportDate);
                    newRow.add(smsSet.getSms(0).getShortMessageText());
                    model.getDataVector().add(0, newRow);
                    model.newRowsAdded(new TableModelEvent(model));
                }
            }
        } else if (option == 1) {
            for (Row row : res) {
                ListSelectionModel l = tResult.getSelectionModel();
                Vector newRow = new Vector();
                newRow.add(row.getString(Schema.COLUMN_ADDR_DST_DIGITS));
                newRow.add(row.getUUID(Schema.COLUMN_ID));
                newRow.add("");
                newRow.add(row.getLong(Schema.COLUMN_MESSAGE_ID));
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                model.getDataVector().add(0, newRow);
                model.newRowsAdded(new TableModelEvent(model));
            }
        } else {
            for (Row row : res) {
                ListSelectionModel l = tResult.getSelectionModel();
                Vector newRow = new Vector();
                newRow.add(row.getString(Schema.COLUMN_REMOTE_MESSAGE_ID));
                newRow.add("");
                newRow.add(row.getString(Schema.COLUMN_DEST_ID));
                newRow.add(row.getLong(Schema.COLUMN_MESSAGE_ID));
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                newRow.add("");
                model.getDataVector().add(0, newRow);
                model.newRowsAdded(new TableModelEvent(model));
            }
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(getJFrame(), "Can not get data from cassandra database:\n" + e.getMessage());
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) ArrayList(java.util.ArrayList) ListSelectionModel(javax.swing.ListSelectionModel) PreparedStatement(com.datastax.driver.core.PreparedStatement) TreeMap(java.util.TreeMap) Date(java.util.Date) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) BoundStatement(com.datastax.driver.core.BoundStatement) SimpleDateFormat(java.text.SimpleDateFormat) Vector(java.util.Vector) SmsSet(org.mobicents.smsc.library.SmsSet) Session(com.datastax.driver.core.Session)

Example 72 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbb method onDeliverSmLocal.

private void onDeliverSmLocal(final RxSmppServerSbbUsage anSbbUsage, final SmsSetEvent event) {
    try {
        if (this.logger.isFineEnabled()) {
            this.logger.fine("\nReceived Deliver SMS. event= " + event + "this=" + this);
        }
        SmsSet smsSet = event.getSmsSet();
        this.addInitialMessageSet(smsSet);
        try {
            this.sendDeliverSm(smsSet);
        } catch (SmscProcessingException e) {
            String s = "SmscProcessingException when sending initial sendDeliverSm()=" + e.getMessage() + ", smsSet=" + smsSet;
            logger.severe(s, e);
            this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, -1);
        }
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorDeliverSm(ONE);
        logger.severe("Exception in RxSmppServerSbb.onDeliverSm() when fetching records and issuing events: " + e1.getMessage(), e1);
        markDeliveringIsEnded(true);
    }
}
Also used : SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 73 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbb method handleResponse.

/**
 * Processing of a positive delivery response to smpp destination.
 *
 * @param event
 * @throws Exception
 */
private void handleResponse(BaseSmResp event) throws Exception {
    long ts = System.currentTimeMillis();
    if (isDeliveringEnded()) {
        if (logger.isFineEnabled()) {
            this.logger.fine("SMPP Response received when DeliveringEnded state: status=" + event.getCommandStatus());
        }
    }
    if (isDeliveringEnded()) {
        logger.info("RxSmppServerSbb.handleResponse(): received submit/deliver_sm_response but delivery process is already ended, dropping of a response");
        return;
    }
    SmsSet smsSet = getSmsSet();
    if (smsSet == null) {
        logger.severe("RxSmppServerSbb.handleResponse(): CMP smsSet is missed");
        markDeliveringIsEnded(true);
        return;
    }
    int status = event.getCommandStatus();
    if (status == 0) {
        smscStatAggregator.updateMsgOutSentAll();
        smscStatAggregator.updateMsgOutSentSmpp();
        boolean destAddressLimitationEnabled = false;
        EsmeManagement esmeManagement = EsmeManagement.getInstance();
        Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
        if (esme != null) {
            destAddressLimitationEnabled = esme.getDestAddrSendLimit() != 0;
        }
        int realID = -1;
        Boolean sentListChanged = false;
        SentItemsList list = null;
        if (destAddressLimitationEnabled) {
            list = retreiveSentChunks();
            for (int i = 0; i < list.getSentList().size(); i++) {
                if (list.getSentList().get(i).getRemoteSequenceNumber() == event.getSequenceNumber()) {
                    realID = list.getSentList().get(i).getLocalSequenceNumber();
                    list.getSentList().remove(i);
                    sentListChanged = true;
                    break;
                }
            }
        } else {
            realID = event.getSequenceNumber();
        }
        ConfirmMessageInSendingPool confirmMessageInSendingPool = null;
        if (realID != -1)
            confirmMessageInSendingPool = confirmMessageInSendingPool(realID);
        if (realID == -1 || !confirmMessageInSendingPool.sequenceNumberFound) {
            this.logger.severe("RxSmppServerSbb.handleResponse(): no sms in MessageInSendingPool: UnconfirmedCnt=" + this.getUnconfirmedMessageCountInSendingPool() + ", sequenceNumber=" + event.getSequenceNumber() + ", realID=" + realID + ", confirmMessageInSendingPool=" + confirmMessageInSendingPool);
            this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, "Received undefined SequenceNumber: " + event.getSequenceNumber() + ", SmsSet=" + smsSet, EventType.OUT_SMPP_ERROR, realID);
            if (sentListChanged)
                setSentChunks(list);
            return;
        }
        Sms sms = confirmMessageInSendingPool.sms;
        if (sms != null) {
            sms.setTimestampC(System.currentTimeMillis());
        }
        if (destAddressLimitationEnabled) {
            ChunkDataList dataList = retreivePendingChunks();
            if (dataList != null && !dataList.getPendingList().isEmpty()) {
                // so checking if has window
                if (list.getSentList().size() < esme.getDestAddrSendLimit()) {
                    ChunkData current = dataList.getPendingList().remove(0);
                    setPendingChunks(dataList);
                    if (current != null) {
                        SentItem newItem = sendNextChunk(current, smsSet, esme);
                        SentItemsList sentChunks = retreiveSentChunks();
                        sentChunks.getSentList().add(newItem);
                        sentListChanged = true;
                    }
                }
            }
        }
        if (sentListChanged)
            setSentChunks(list);
        if (!confirmMessageInSendingPool.confirmed) {
            this.generateCDR(sms, CdrGenerator.CDR_PARTIAL_ESME, CdrGenerator.CDR_SUCCESS_NO_REASON, true, false, event.getSequenceNumber());
            String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
            this.generateDetailedCDR(sms, EventType.OUT_SMPP_SENT, sms.getSmsSet().getStatus(), messageType, status, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
            return;
        }
        // firstly we store remote messageId if sms has a request to delivery receipt
        String clusterName = smsSet.getDestClusterName();
        String dlvMessageId = event.getMessageId();
        sms.setDlvMessageId(dlvMessageId);
        // if (MessageUtil.isDeliveryReceiptRequest(sms)) {
        // SmsSetCache.getInstance().putDeliveredRemoteMsgIdValue(dlvMessageId, clusterName, sms.getMessageId(), 30);
        // }
        // current message is sent
        // firstly sending of a positive response for transactional mode
        sendTransactionalResponseSuccess(sms);
        // mproc rules applying for delivery phase
        this.applyMprocRulesOnSuccess(sms, ProcessingType.SMPP);
        // Processing succeeded
        sms.getSmsSet().setStatus(ErrorCode.SUCCESS);
        this.postProcessSucceeded(sms, dlvMessageId, clusterName);
        // success CDR generating
        boolean isPartial = MessageUtil.isSmsNotLastSegment(sms);
        this.generateCDR(sms, isPartial ? CdrGenerator.CDR_PARTIAL_ESME : CdrGenerator.CDR_SUCCESS_ESME, CdrGenerator.CDR_SUCCESS_NO_REASON, confirmMessageInSendingPool.splittedMessage, true, event.getSequenceNumber());
        String messageType = null;
        String remoteAddr = null;
        if (esme != null) {
            messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
            remoteAddr = esme.getRemoteAddressAndPort();
        }
        if (messageType == null) {
            if (event.getCommandId() == SmppConstants.CMD_ID_DELIVER_SM_RESP) {
                messageType = CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
            } else {
                messageType = CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM;
            }
        }
        this.generateDetailedCDR(sms, EventType.OUT_SMPP_SENT, sms.getSmsSet().getStatus(), messageType, status, remoteAddr, event.getSequenceNumber());
        // adding a success receipt if it is needed
        this.generateSuccessReceipt(smsSet, sms);
        if (this.getUnconfirmedMessageCountInSendingPool() == 0) {
            // all sent messages are confirmed - we are sending new message set
            TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
            try {
                synchronized (lock) {
                    // marking the message in cache as delivered
                    this.commitSendingPoolMsgCount();
                    ts = warnIfLong(logger, ts, "handleResponse/status=0/in-lock/commitSendingPoolMsgCount");
                    // now we are trying to sent other messages
                    if (this.getTotalUnsentMessageCount() > 0) {
                        try {
                            this.sendDeliverSm(smsSet);
                            ts = warnIfLong(logger, ts, "handleResponse/status=0/in-lock/sendDeliverSm");
                            return;
                        } catch (SmscProcessingException e) {
                            SbbStatsUtils.handleProcessingException(e, getDefaultSbbUsageParameterSet());
                            String s = "SmscProcessingException when sending next sendDeliverSm()=" + e.getMessage() + ", Message=" + sms;
                            logger.severe(s, e);
                            this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, event.getSequenceNumber());
                        }
                    }
                    // no more messages to send - remove smsSet
                    smsSet.setStatus(ErrorCode.SUCCESS);
                    this.markDeliveringIsEnded(true);
                }
            } finally {
                persistence.releaseSynchroObject(lock);
            }
        }
    } else {
        ErrorAction errorAction = ErrorAction.permanentFailure;
        smsSet.setSmppCommandStatus(status);
        if (status == SmppConstants.STATUS_THROTTLED || status == SmppConstants.STATUS_X_T_APPN || status == SmppConstants.STATUS_SYSERR || status == SmppConstants.STATUS_INVBNDSTS || status == SmppConstants.STATUS_MSGQFUL)
            errorAction = ErrorAction.temporaryFailure;
        logger.warning("RxSmppServerSbb.handleResponse(): error code response received: status=" + status + ", errorAction=" + errorAction + ", smsSet=" + smsSet);
        this.onDeliveryError(smsSet, errorAction, ErrorCode.SC_SYSTEM_ERROR, event.getName() + " has a bad status: " + status, EventType.OUT_SMPP_REJECTED, event.getSequenceNumber());
    }
}
Also used : EsmeManagement(org.restcomm.smpp.EsmeManagement) ChunkData(org.mobicents.smsc.slee.services.deliverysbb.ChunkData) Esme(org.restcomm.smpp.Esme) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) TargetAddress(org.mobicents.smsc.library.TargetAddress) ChunkDataList(org.mobicents.smsc.slee.services.deliverysbb.ChunkDataList) ConfirmMessageInSendingPool(org.mobicents.smsc.slee.services.deliverysbb.ConfirmMessageInSendingPool) SentItemsList(org.mobicents.smsc.slee.services.deliverysbb.SentItemsList) ErrorAction(org.mobicents.smsc.library.ErrorAction) Sms(org.mobicents.smsc.library.Sms) SentItem(org.mobicents.smsc.slee.services.deliverysbb.SentItem) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 74 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbb method onRecoverablePduExceptionParentLocal.

private void onRecoverablePduExceptionParentLocal(final RxSmppServerSbbUsage anSbbUsage, final RecoverablePduException event) {
    try {
        if (isDeliveringEnded()) {
            logger.info("RxSmppServerSbb.onRecoverablePduException(): received RecoverablePduException but delivery process is already ended, dropping of an event");
            return;
        }
        SmsSet smsSet = getSmsSet();
        if (smsSet == null) {
            logger.severe("RxSmppServerSbb.onRecoverablePduException(): In onDeliverSmResp CMP smsSet is missed");
            markDeliveringIsEnded(true);
            return;
        }
        logger.severe(String.format("\nonRecoverablePduException : targetId=" + smsSet.getTargetId() + ", RecoverablePduException=" + event));
        this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, "RecoverablePduException: ", EventType.OUT_SMPP_ERROR, event.getPartialPdu().getSequenceNumber());
    } catch (Throwable e1) {
        anSbbUsage.incrementCounterErrorRecoverablePduExceptionParent(ONE);
        logger.severe("Exception in RxSmppServerSbb.onRecoverablePduException() when fetching records and issuing events: " + e1.getMessage(), e1);
        markDeliveringIsEnded(true);
    }
}
Also used : SmsSet(org.mobicents.smsc.library.SmsSet)

Example 75 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class MtTest method SuccessDelivery3Test.

/**
 * MAP V1, 1 message, long message with 2 segments, GSM7
 * no TC-BEGIN message because of MAP V1
 * SRI response with MwdSet, but no ReportSMDeliveryStatusRequest because of MAP V1
 */
@Test(groups = { "Mt" })
public void SuccessDelivery3Test() throws Exception {
    if (!this.cassandraDbInited)
        return;
    MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
    SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    MProcManagement.getInstance("Test");
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    lst.add(sd1);
    StringBuilder sb = new StringBuilder();
    for (int i1 = 0; i1 < 18; i1++) {
        // msg len = 180
        sb.append("0123456789");
    }
    String totalMsg = sb.toString();
    int segmlen = MessageUtil.getMaxSegmentedMessageBytesLength(new DataCodingSchemeImpl(0));
    String msga1 = totalMsg.substring(0, segmlen);
    String msga2 = totalMsg.substring(segmlen);
    sd1.msg = totalMsg;
    SmsSet smsSet = prepareDatabase(lst);
    Sms sms1 = smsSet.getSms(0);
    UUID smsId = sms1.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertNull(serviceMt.getLastMAPDialogSms());
    // SRI "MAP only V1 supported" response
    DialogReject evt11 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
    this.sriSbb.onDialogReject(evt11, null);
    dlg = serviceSri.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version1);
    assertNull(serviceMt.getLastMAPDialogSms());
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
    MAPTestEvent evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    SendRoutingInfoForSMRequest sriReq = (SendRoutingInfoForSMRequest) evt.event;
    assertEquals(sriReq.getMsisdn().getAddress(), msdnDig);
    assertEquals(sriReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    // SRI response
    IMSI imsi = new IMSIImpl(imsiDig);
    ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    LocationInfoWithLMSI locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    SendRoutingInfoForSMResponse evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, true);
    evt1.setMAPDialog(dlg);
    this.sriSbb.onSendRoutingInfoForSMResponse(evt1, null);
    this.sriSbb.onDialogDelimiter(null, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    lstEvt = dlg.getEventList();
    // Empty TC-BEGIN for MAP V3
    assertEquals(lstEvt.size(), 3);
    // SRI "MAP only V1 supported" response
    DialogReject evt12 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
    this.mtSbb.onDialogReject(evt12, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version1);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    ForwardShortMessageRequestImpl mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
    assertTrue(mtFsmReq.getMoreMessagesToSend());
    SM_RP_DA sm_RP_DA = mtFsmReq.getSM_RP_DA();
    IMSI daImsi = sm_RP_DA.getIMSI();
    assertEquals(daImsi.getData(), imsiDig);
    SM_RP_OA sm_RP_OA = mtFsmReq.getSM_RP_OA();
    AddressString scas = sm_RP_OA.getServiceCentreAddressOA();
    assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
    SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
    SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 0);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertTrue(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    UserData ud = tpdu.getUserData();
    ud.decode();
    UserDataHeader udh = ud.getDecodedUserDataHeader();
    ConcatenatedShortMessagesIdentifier csm = udh.getConcatenatedShortMessagesIdentifier();
    assertEquals(csm.getReference(), 1);
    assertEquals(csm.getMesageSegmentCount(), 2);
    assertEquals(csm.getMesageSegmentNumber(), 1);
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msga1);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // Mt response 1
    ForwardShortMessageResponseImpl evt2 = new ForwardShortMessageResponseImpl();
    evt2.setMAPDialog(dlg);
    DialogAccept daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onForwardShortMessageResponse(evt2, null);
    DialogClose dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version1);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
    assertFalse(mtFsmReq.getMoreMessagesToSend());
    sm_RP_DA = mtFsmReq.getSM_RP_DA();
    daImsi = sm_RP_DA.getIMSI();
    assertEquals(daImsi.getData(), imsiDig);
    sm_RP_OA = mtFsmReq.getSM_RP_OA();
    scas = sm_RP_OA.getServiceCentreAddressOA();
    assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
    ssi = mtFsmReq.getSM_RP_UI();
    tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 0);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertFalse(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    ud = tpdu.getUserData();
    ud.decode();
    udh = ud.getDecodedUserDataHeader();
    csm = udh.getConcatenatedShortMessagesIdentifier();
    assertEquals(csm.getReference(), 1);
    assertEquals(csm.getMesageSegmentCount(), 2);
    assertEquals(csm.getMesageSegmentNumber(), 2);
    String msg2 = ud.getDecodedMessage();
    assertEquals(msg2, msga2);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // Mt response 2
    evt2 = new ForwardShortMessageResponseImpl();
    evt2.setMAPDialog(dlg);
    daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onForwardShortMessageResponse(evt2, null);
    dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    dlg = serviceRsds.getLastMAPDialogSms();
    assertNull(dlg);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
}
Also used : SmsDeliverTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) SendRoutingInfoForSMRequest(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) LocationInfoWithLMSI(org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) DialogReject(org.mobicents.slee.resource.map.events.DialogReject) IMSIImpl(org.mobicents.protocols.ss7.map.primitives.IMSIImpl) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) ArrayList(java.util.ArrayList) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SM_RP_OA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) DataCodingSchemeImpl(org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) SendRoutingInfoForSMResponse(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) DialogAccept(org.mobicents.slee.resource.map.events.DialogAccept) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI) UUID(java.util.UUID) UserDataHeader(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader) MtForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) ForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) ConcatenatedShortMessagesIdentifier(org.mobicents.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier) ForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageResponseImpl) MtForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageResponseImpl) LocationInfoWithLMSIImpl(org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) DialogClose(org.mobicents.slee.resource.map.events.DialogClose) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA) Test(org.testng.annotations.Test)

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