use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class RxSipServerSbb method sendMessage.
// *********
// Main service methods
/**
* Sending of a SIP message after initial message or when all sent messages was sent
*
* @param smsSet
* @throws SmscProcessingException
*/
private void sendMessage(SmsSet smsSet) throws SmscProcessingException {
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySip();
Sms sms = this.obtainNextMessage(ProcessingType.SIP);
if (sms == null) {
this.markDeliveringIsEnded(true);
return;
}
try {
// TODO: let make here a special check if SIP is in a good state
// if not - skip sending and set temporary error
String fromAddressStr = sms.getSourceAddr();
String toAddressStr = smsSet.getDestAddr();
Sip sip = sipManagement.getSipByName(SipManagement.SIP_NAME);
ListeningPoint listeningPoint = sipRA.getListeningPoints()[0];
SipURI fromAddressUri = addressFactory.createSipURI(fromAddressStr, listeningPoint.getIPAddress() + ":" + listeningPoint.getPort());
javax.sip.address.Address fromAddress = addressFactory.createAddress(fromAddressUri);
FromHeader fromHeader = headerFactory.createFromHeader(fromAddress, null);
SipURI toAddressUri = addressFactory.createSipURI(toAddressStr, sip.getSipAddress());
javax.sip.address.Address toAddress = addressFactory.createAddress(toAddressUri);
ToHeader toHeader = headerFactory.createToHeader(toAddress, null);
List<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(1);
ViaHeader viaHeader = headerFactory.createViaHeader(listeningPoint.getIPAddress(), listeningPoint.getPort(), listeningPoint.getTransport(), null);
viaHeaders.add(viaHeader);
ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("text", "plain");
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(2L, Request.MESSAGE);
MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
CallIdHeader callId = this.sipRA.getNewCallId();
String msgStr = sms.getShortMessageText();
byte[] msgUdh = sms.getShortMessageBin();
byte[] msg;
msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
// create request
Request request = messageFactory.createRequest(toAddressUri, Request.MESSAGE, callId, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwardsHeader, contentTypeHeader, msg);
// Custom X Headers
// SMSC-ID
String originEsmeName = sms.getOrigEsmeName();
if (originEsmeName != null) {
Header smsIdHeader = headerFactory.createHeader(SipXHeaders.XSmscId, originEsmeName);
request.addHeader(smsIdHeader);
}
// data-coding
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(sms.getDataCoding());
Header smsIdHeader = headerFactory.createHeader(SipXHeaders.XSmsCoding, Integer.toString(dataCodingScheme.getCharacterSet().getCode()));
request.addHeader(smsIdHeader);
// TODO X header message class
// X header delivery time, use SUBMIT_DATE
Date submitDate = sms.getSubmitDate();
if (submitDate != null) {
String submitDateStr = MessageUtil.formatDate(submitDate);
Header submitDateHeader = headerFactory.createHeader(SipXHeaders.XDeliveryTime, submitDateStr);
request.addHeader(submitDateHeader);
}
// Validity Period
Date validityPeriod = sms.getValidityPeriod();
if (validityPeriod != null) {
String validityPeriodStr = MessageUtil.formatDate(validityPeriod);
Header validityHeader = headerFactory.createHeader(SipXHeaders.XSmsValidty, validityPeriodStr);
request.addHeader(validityHeader);
}
// X header UDH
if (msgUdh != null) {
String udhString = hexStringToByteArray(msgUdh);
Header udhHeader = headerFactory.createHeader(SipXHeaders.XSmsUdh, udhString);
request.addHeader(udhHeader);
}
// create client transaction and send request
ClientTransaction clientTransaction = sipRA.getNewClientTransaction(request);
ActivityContextInterface sipClientTxaci = this.sipACIFactory.getActivityContextInterface(clientTransaction);
sipClientTxaci.attach(this.sbbContext.getSbbLocalObject());
clientTransaction.sendRequest();
} catch (Exception e) {
throw new SmscProcessingException("RxSipServerSbb.sendMessage(): Exception while trying to send SIP Message =" + e.getMessage() + "Message: " + sms, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class RxSipServerSbb method onDeliveryError.
/**
* Processing a case when an error in message sending process. This stops of message sending, reschedule or drop messages
* and clear resources.
*
* @param smsSet
* @param errorAction
* @param smStatus
* @param reason
*/
private void onDeliveryError(SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason) {
try {
smscStatAggregator.updateMsgOutFailedAll();
// generating of a temporary failure CDR (one record for all unsent messages)
if (smscPropertiesManagement.getGenerateTempFailureCdr())
this.generateTemporaryFailureCDR(CdrGenerator.CDR_TEMP_FAILED_SIP, reason);
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured = new ArrayList<Sms>();
ArrayList<Sms> lstPermFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
synchronized (lock) {
try {
// ending of delivery process in this SBB
smsSet.setStatus(smStatus);
this.markDeliveringIsEnded(true);
// calculating of newDueDelay and NewDueTime
int newDueDelay = calculateNewDueDelay(smsSet, false);
Date newDueTime = calculateNewDueTime(smsSet, newDueDelay);
// creating of failure lists
this.createFailureLists(lstPermFailured, lstTempFailured, errorAction, newDueTime);
// mproc rules applying for delivery phase
this.applyMprocRulesOnFailure(lstPermFailured, lstTempFailured, lstPermFailured2, lstTempFailured2, lstRerouted, lstNewNetworkId, ProcessingType.SIP);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured2, lstTempFailured2, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured2, null, null);
this.postProcessTempFailures(smsSet, lstTempFailured2, newDueDelay, newDueTime, false);
this.postProcessRerouted(lstRerouted, lstNewNetworkId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured2, CdrGenerator.CDR_FAILED_SIP, reason);
// sending of intermediate delivery receipts
this.generateIntermediateReceipts(smsSet, lstTempFailured2);
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured2, null);
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
logger.severe("Exception in RxSipServerSbb.onDeliveryError(): " + e.getMessage(), e);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class RxSmppServerSbb method onDeliveryError.
/**
* Processing a case when an error in message sending process. This stops of message sending, reschedule or drop messages
* and clear resources.
*
* @param smsSet
* @param errorAction
* @param smStatus
* @param reason
*/
private void onDeliveryError(SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason, EventType eventType, int seqNumber) {
getDefaultSbbUsageParameterSet().incrementCounterErrorDelivery(ONE);
try {
smscStatAggregator.updateMsgOutFailedAll();
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
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();
}
// generating of a temporary failure CDR (one record for all unsent messages)
if (smscPropertiesManagement.getGenerateTempFailureCdr()) {
this.generateTemporaryFailureCDR(CdrGenerator.CDR_TEMP_FAILED_ESME, reason);
this.generateTemporaryFailureDetailedCDR(eventType, messageType, smStatus, remoteAddr, seqNumber);
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured = new ArrayList<Sms>();
ArrayList<Sms> lstPermFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstTempFailured2 = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
synchronized (lock) {
try {
setPendingChunks(null);
setSentChunks(null);
// ending of delivery process in this SBB
smsSet.setStatus(smStatus);
this.markDeliveringIsEnded(true);
// calculating of newDueDelay and NewDueTime
int newDueDelay = calculateNewDueDelay(smsSet, false);
Date newDueTime = calculateNewDueTime(smsSet, newDueDelay);
// creating of failure lists
this.createFailureLists(lstPermFailured, lstTempFailured, errorAction, newDueTime);
// mproc rules applying for delivery phase
this.applyMprocRulesOnFailure(lstPermFailured, lstTempFailured, lstPermFailured2, lstTempFailured2, lstRerouted, lstNewNetworkId, ProcessingType.SMPP);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured2, lstTempFailured2, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured2, null, null);
this.postProcessTempFailures(smsSet, lstTempFailured2, newDueDelay, newDueTime, false);
this.postProcessRerouted(lstRerouted, lstNewNetworkId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured2, CdrGenerator.CDR_FAILED_ESME, reason);
if (!smscPropertiesManagement.getGenerateTempFailureCdr()) {
generateDetailedCDRs(lstPermFailured2, EventType.OUT_SMPP_ERROR, smStatus, messageType, remoteAddr, seqNumber);
}
// sending of intermediate delivery receipts
this.generateIntermediateReceipts(smsSet, lstTempFailured2);
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured2, null);
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
getDefaultSbbUsageParameterSet().incrementCounterErrorDeliveryException(ONE);
logger.severe("Exception in RxSmppServerSbb.onDeliveryError(): " + e.getMessage(), e);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class RxSmppServerSbb method sendDeliverSm.
// *********
// Main service methods
/**
* Sending of a set of messages after initial message or when all sent messages was sent
*
* @param smsSet
* @throws SmscProcessingException
*/
private void sendDeliverSm(SmsSet smsSet) throws SmscProcessingException {
try {
int deliveryMsgCnt = this.obtainNextMessagesSendingPool(maxMessagesPerStep, ProcessingType.SMPP);
if (deliveryMsgCnt == 0) {
this.markDeliveringIsEnded(true);
return;
}
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
if (esme == null) {
String s = "RxSmppServerSbb.sendDeliverSm(): Received DELIVER_SM SmsEvent but no Esme found for destClusterName: " + smsSet.getDestClusterName() + ", smsSet=" + smsSet;
logger.warning(s);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, EventType.OUT_SMPP_ERROR, -1);
return;
}
smsSet.setDestSystemId(esme.getSystemId());
smsSet.setDestEsmeName(esme.getName());
List<ChunkData> pendingMessages = new ArrayList<ChunkData>();
boolean destAddressLimitationEnabled = esme.getDestAddrSendLimit() != 0;
for (int poolIndex = 0; poolIndex < deliveryMsgCnt; poolIndex++) {
smscStatAggregator.updateMsgOutTryAll();
smscStatAggregator.updateMsgOutTrySmpp();
Sms sms = this.getMessageInSendingPool(poolIndex);
if (sms == null) {
// this should not be
throw new SmscProcessingException("sendDeliverSm: getCurrentMessage() returns null sms for msgNum in SendingPool " + poolIndex, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000007);
}
sms.setTimestampA(System.currentTimeMillis());
// message splitting staff
boolean esmeAllowSplitting = esme.getSplitLongMessages();
int esmClass = sms.getEsmClass();
boolean udhPresent = (esmClass & SmppConstants.ESM_CLASS_UDHI_MASK) != 0;
Tlv sarMsgRefNum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
Tlv sarTotalSegments = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
Tlv sarSegmentSeqnum = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
boolean sarTlvPresent = sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null;
ArrayList<String> lstStrings = new ArrayList<String>();
ArrayList<byte[]> lstUdhs = new ArrayList<byte[]>();
lstStrings.add(sms.getShortMessageText());
lstUdhs.add(sms.getShortMessageBin());
if (esmeAllowSplitting && !udhPresent && !sarTlvPresent) {
DataCodingScheme dataCodingScheme = this.mapSmsTpduParameterFactory.createDataCodingScheme(sms.getDataCoding());
String[] segmentsStrings = MessageUtil.sliceMessage(sms.getShortMessageText(), dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift());
if (segmentsStrings != null && segmentsStrings.length > 1) {
// we need to split a message for segments
lstStrings.clear();
lstUdhs.clear();
int messageReferenceNumber = getNextMessageReferenceNumber();
esmClass |= SmppConstants.ESM_CLASS_UDHI_MASK;
int messageSegmentCount = segmentsStrings.length;
for (int ii1 = 0; ii1 < messageSegmentCount; ii1++) {
lstStrings.add(segmentsStrings[ii1]);
byte[] bf1 = new byte[7];
// total UDH length
bf1[0] = 6;
// UDH id
bf1[1] = UserDataHeader._InformationElementIdentifier_ConcatenatedShortMessages16bit;
// UDH length
bf1[2] = 4;
bf1[3] = (byte) (messageReferenceNumber & 0x00FF);
bf1[4] = (byte) ((messageReferenceNumber & 0xFF00) >> 8);
// segmCnt
bf1[5] = (byte) messageSegmentCount;
// segmNum
bf1[6] = (byte) (ii1 + 1);
lstUdhs.add(bf1);
}
}
}
int sequenceNumber = 0;
int[] sequenceNumberExt = null;
int segmCnt = lstStrings.size();
if (segmCnt > 1) {
sequenceNumberExt = new int[segmCnt - 1];
}
for (int segmentIndex = 0; segmentIndex < segmCnt; segmentIndex++) {
if (esme.getSmppSessionType() == Type.CLIENT) {
SubmitSm submitSm = new SubmitSm();
submitSm.setSourceAddress(new Address((byte) sms.getSourceAddrTon(), (byte) sms.getSourceAddrNpi(), sms.getSourceAddr()));
submitSm.setDestAddress(new Address((byte) sms.getSmsSet().getDestAddrTon(), (byte) sms.getSmsSet().getDestAddrNpi(), sms.getSmsSet().getDestAddr()));
submitSm.setEsmClass((byte) esmClass);
submitSm.setProtocolId((byte) sms.getProtocolId());
submitSm.setPriority((byte) sms.getPriority());
if (sms.getScheduleDeliveryTime() != null) {
submitSm.setScheduleDeliveryTime(MessageUtil.printSmppAbsoluteDate(sms.getScheduleDeliveryTime(), -(new Date()).getTimezoneOffset()));
}
if (sms.getValidityPeriod() != null) {
submitSm.setValidityPeriod(MessageUtil.printSmppAbsoluteDate(sms.getValidityPeriod(), -(new Date()).getTimezoneOffset()));
}
submitSm.setRegisteredDelivery((byte) sms.getRegisteredDelivery());
submitSm.setReplaceIfPresent((byte) sms.getReplaceIfPresent());
submitSm.setDataCoding((byte) sms.getDataCoding());
String msgStr = lstStrings.get(segmentIndex);
byte[] msgUdh = lstUdhs.get(segmentIndex);
if (msgStr != null || msgUdh != null) {
byte[] msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
if (msg.length <= 255) {
submitSm.setShortMessage(msg);
} else {
Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msg, null);
submitSm.addOptionalParameter(tlv);
}
}
for (Tlv tlv : sms.getTlvSet().getOptionalParameters()) {
submitSm.addOptionalParameter(tlv);
}
int currLocalSequenceNumber = getLastLocalSequenceNumber();
if (currLocalSequenceNumber == Integer.MAX_VALUE)
setLastLocalSequenceNumber(0);
else
setLastLocalSequenceNumber(currLocalSequenceNumber + 1);
ChunkData currData = new ChunkData(submitSm, currLocalSequenceNumber);
int sentSequenceNumber = currData.getLocalSequenceNumber();
if (destAddressLimitationEnabled) {
pendingMessages.add(currData);
} else {
SentItem sentItem = sendNextChunk(currData, smsSet, esme);
long t = System.currentTimeMillis();
sms.setTimestampB(t);
sentSequenceNumber = sentItem.getRemoteSequenceNumber();
sms.putMsgPartDeliveryTime(sentSequenceNumber, t);
}
if (logger.isInfoEnabled()) {
logger.info(String.format("Sent submitSm to ESME: %s, msgNumInSendingPool: %d, sms=%s", esme.getName(), poolIndex, sms.toString()));
}
if (segmentIndex == 0) {
sequenceNumber = sentSequenceNumber;
} else {
sequenceNumberExt[segmentIndex - 1] = sentSequenceNumber;
}
} else {
DeliverSm deliverSm = new DeliverSm();
deliverSm.setSourceAddress(new Address((byte) sms.getSourceAddrTon(), (byte) sms.getSourceAddrNpi(), sms.getSourceAddr()));
deliverSm.setDestAddress(new Address((byte) sms.getSmsSet().getDestAddrTon(), (byte) sms.getSmsSet().getDestAddrNpi(), sms.getSmsSet().getDestAddr()));
deliverSm.setEsmClass((byte) esmClass);
deliverSm.setProtocolId((byte) sms.getProtocolId());
deliverSm.setPriority((byte) sms.getPriority());
if (sms.getScheduleDeliveryTime() != null) {
deliverSm.setScheduleDeliveryTime(MessageUtil.printSmppAbsoluteDate(sms.getScheduleDeliveryTime(), -(new Date()).getTimezoneOffset()));
}
if (sms.getValidityPeriod() != null && esme.getSmppVersion() == SmppInterfaceVersionType.SMPP50) {
deliverSm.setValidityPeriod(MessageUtil.printSmppAbsoluteDate(sms.getValidityPeriod(), -(new Date()).getTimezoneOffset()));
}
deliverSm.setRegisteredDelivery((byte) sms.getRegisteredDelivery());
deliverSm.setReplaceIfPresent((byte) sms.getReplaceIfPresent());
deliverSm.setDataCoding((byte) sms.getDataCoding());
String msgStr = lstStrings.get(segmentIndex);
byte[] msgUdh = lstUdhs.get(segmentIndex);
if (msgStr != null || msgUdh != null) {
byte[] msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
if (msg.length <= 255) {
deliverSm.setShortMessage(msg);
} else {
Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msg, null);
deliverSm.addOptionalParameter(tlv);
}
}
for (Tlv tlv : sms.getTlvSet().getOptionalParameters()) {
deliverSm.addOptionalParameter(tlv);
}
// TODO : waiting for 2 secs for window to accept our
// request,
// is it good? Should time be more here?
int currLocalSequenceNumber = getLastLocalSequenceNumber();
if (currLocalSequenceNumber == Integer.MAX_VALUE)
setLastLocalSequenceNumber(0);
else
setLastLocalSequenceNumber(currLocalSequenceNumber + 1);
ChunkData currData = new ChunkData(deliverSm, currLocalSequenceNumber);
int sentSequenceNumber = currData.getLocalSequenceNumber();
if (destAddressLimitationEnabled) {
pendingMessages.add(currData);
} else {
SentItem sentItem = sendNextChunk(currData, smsSet, esme);
long t = System.currentTimeMillis();
sms.setTimestampB(t);
sentSequenceNumber = sentItem.getRemoteSequenceNumber();
sms.putMsgPartDeliveryTime(sentSequenceNumber, t);
}
if (logger.isInfoEnabled()) {
logger.info(String.format("Sent deliverSm to ESME: %s, msgNumInSendingPool: %d, sms=%s", esme.getName(), poolIndex, sms.toString()));
}
if (segmentIndex == 0) {
sequenceNumber = sentSequenceNumber;
} else {
sequenceNumberExt[segmentIndex - 1] = sentSequenceNumber;
}
}
}
this.registerMessageInSendingPool(poolIndex, sequenceNumber, sequenceNumberExt);
}
this.endRegisterMessageInSendingPool();
if (destAddressLimitationEnabled) {
ChunkDataList pendingChunks = retreivePendingChunks();
pendingChunks.getPendingList().addAll(pendingMessages);
SentItemsList sentChunks = retreiveSentChunks();
int pdusToSendSize = pendingChunks.getPendingList().size();
int allowedSendWindowSize = esme.getDestAddrSendLimit() - sentChunks.getSentList().size();
if (allowedSendWindowSize < pdusToSendSize)
pdusToSendSize = allowedSendWindowSize;
List<ChunkData> pdusToSend = new ArrayList<ChunkData>();
for (int i = 0; i < pdusToSendSize; i++) {
pdusToSend.add(pendingChunks.getPendingList().remove(0));
}
setPendingChunks(pendingChunks);
ArrayList<SentItem> sentResults = new ArrayList<SentItem>();
while (pdusToSend.size() > 0) {
SentItem result = sendNextChunk(pdusToSend.remove(0), smsSet, esme);
if (result != null)
sentResults.add(result);
}
if (!sentResults.isEmpty()) {
sentChunks.getSentList().addAll(sentResults);
setSentChunks(sentChunks);
}
}
} catch (Throwable e) {
throw new SmscProcessingException("RxSmppServerSbb.sendDeliverSm(): Exception while trying to send DELIVERY Report for received SmsEvent=" + e.getMessage() + "smsSet: " + smsSet, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000008);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MtTest3 method ReportTest.
@Test(groups = { "Mt" })
public void ReportTest() throws Exception {
MtSbbProxy3 proxy = new MtSbbProxy3();
Date submitDate = new Date(2015, 1, 2, 12, 30);
Date deliveryDate = new Date(2015, 1, 2, 12, 40);
Sms sms = new Sms();
sms.setSourceAddr("111199990000");
sms.setSourceAddrNpi(1);
sms.setSourceAddrTon(1);
sms.setShortMessageText("Hello 111");
sms.setSubmitDate(submitDate);
sms.setMoMessageRef(34);
SmsSet smsSet = new SmsSet();
smsSet.setDestAddr("888899990000");
smsSet.setDestAddrNpi(1);
smsSet.setDestAddrTon(1);
smsSet.setNetworkId(0);
smsSet.addSms(sms);
SmsDeliveryReportData smsDeliveryReportData = new SmsDeliveryReportData();
smsDeliveryReportData.setDeliveryDate(deliveryDate);
smsDeliveryReportData.setStatusReportQualifier(StatusReportQualifier.SmsSubmitResult);
smsDeliveryReportData.setStatusVal(64);
SmsSignalInfo smsSignalInfo = proxy.createSignalInfoStatusReport(sms, true, smsDeliveryReportData);
String s1 = smsSignalInfo.toString();
assertNotNull(smsSignalInfo);
SmsStatusReportTpdu si = (SmsStatusReportTpdu) smsSignalInfo.decodeTpdu(false);
assertEquals(si.getDischargeTime().getMinute(), 40);
assertEquals(si.getServiceCentreTimeStamp().getMinute(), 30);
assertFalse(si.getForwardedOrSpawned());
assertEquals(si.getMessageReference(), 34);
assertTrue(si.getMoreMessagesToSend());
// assertNull(si.getParameterIndicator());
assertEquals(si.getProtocolIdentifier().getCode(), 0);
assertEquals(si.getRecipientAddress().getAddressValue(), "888899990000");
assertEquals(si.getRecipientAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
assertEquals(si.getRecipientAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
assertEquals(si.getStatus().getCode(), Status.REMOTE_PROCEDURE_ERROR);
assertEquals(si.getStatusReportQualifier(), StatusReportQualifier.SmsSubmitResult);
}
Aggregations