use of com.cloudhopper.smpp.type.Address in project smscgateway by RestComm.
the class TxSmppServerSbbTest method fillSm.
private void fillSm(BaseSm event, Date curDate, boolean isSubmitMsg) {
Address destAddr = new Address();
destAddr.setAddress("5555");
destAddr.setTon(SmppConstants.TON_INTERNATIONAL);
destAddr.setNpi(SmppConstants.NPI_E164);
event.setDestAddress(destAddr);
Address srcAddr = new Address();
srcAddr.setAddress("4444");
srcAddr.setTon(SmppConstants.TON_INTERNATIONAL);
srcAddr.setNpi(SmppConstants.NPI_E164);
event.setSourceAddress(srcAddr);
event.setDataCoding((byte) 8);
event.setServiceType("CMT");
if (isSubmitMsg)
event.setEsmClass((byte) 67);
else
event.setEsmClass((byte) 3);
event.setRegisteredDelivery((byte) 1);
if (isSubmitMsg) {
event.setProtocolId((byte) 5);
event.setPriority((byte) 2);
event.setReplaceIfPresent((byte) 0);
event.setDefaultMsgId((byte) 200);
scheduleDeliveryTime = MessageUtil.addHours(curDate, 24);
event.setScheduleDeliveryTime(MessageUtil.printSmppAbsoluteDate(scheduleDeliveryTime, -(new Date()).getTimezoneOffset()));
event.setValidityPeriod(MessageUtil.printSmppRelativeDate(0, 0, 2, 0, 0, 0));
}
}
use of com.cloudhopper.smpp.type.Address in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testSubmitSm_createSmsEvent.
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_createSmsEvent() throws Exception {
if (!this.cassandraDbInited)
return;
this.smppSess = new SmppSessionsProxy();
this.sbb.setSmppServerSessions(smppSess);
TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Utf8);
SmscPropertiesManagement spm = SmscPropertiesManagement.getInstance("Test");
String sMsgA = "������Hel";
// only message part
Charset utf8 = Charset.forName("UTF-8");
ByteBuffer bb = utf8.encode(sMsgA);
byte[] aMsgA = new byte[bb.limit()];
bb.get(aMsgA);
Charset ucs2 = Charset.forName("UTF-16BE");
bb = ucs2.encode(sMsgA);
byte[] aMsgAA = new byte[bb.limit()];
bb.get(aMsgAA);
com.cloudhopper.smpp.pdu.SubmitSm event = new com.cloudhopper.smpp.pdu.SubmitSm();
Address addr = new Address();
addr.setNpi((byte) 1);
addr.setTon((byte) 1);
addr.setAddress("2222");
event.setSourceAddress(addr);
Address addr2 = new Address();
addr2.setNpi((byte) 1);
addr2.setTon((byte) 1);
addr2.setAddress("5555");
event.setDestAddress(addr2);
event.setDataCoding((byte) 8);
event.setShortMessage(aMsgA);
Esme origEsme = new Esme();
TargetAddress ta = ta1;
Sms sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), sMsgA);
// message part and UDH
byte[] udh = new byte[] { 0x05, 0x00, 0x03, 0x29, 0x02, 0x02 };
byte[] aMsgB = new byte[aMsgA.length + udh.length];
System.arraycopy(udh, 0, aMsgB, 0, udh.length);
System.arraycopy(aMsgA, 0, aMsgB, udh.length, aMsgA.length);
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 8);
event.setShortMessage(aMsgB);
event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), sMsgA);
assertEquals(sms.getShortMessageBin(), udh);
// binary GSM8
String s1 = "Optic xxx";
Charset iso = Charset.forName("ISO-8859-1");
byte[] aMsgC = s1.getBytes(iso);
byte[] aMsgCC = new byte[aMsgC.length + udh.length];
System.arraycopy(udh, 0, aMsgCC, 0, udh.length);
System.arraycopy(aMsgC, 0, aMsgCC, udh.length, aMsgC.length);
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 4);
event.setShortMessage(aMsgCC);
event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), s1);
assertEquals(sms.getShortMessageBin(), udh);
// GSM7
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 0);
event.setShortMessage(aMsgC);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), s1);
assertNull(sms.getShortMessageBin());
}
use of com.cloudhopper.smpp.type.Address in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testSubmitMulti.
@Test(groups = { "TxSmppServer" })
public void testSubmitMulti() throws Exception {
if (!this.cassandraDbInited)
return;
this.smppSess = new SmppSessionsProxy();
this.sbb.setSmppServerSessions(smppSess);
int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
long windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
long windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
Esme esme = new Esme("Esme_1", "Esme_systemId_1", "pwd", "host", 0, false, null, SmppInterfaceVersionType.SMPP34, -1, -1, null, SmppBindType.TRANSCEIVER, SmppSession.Type.CLIENT, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, "Esme_1", true, 30000, 0, 0, -1, -1, "^[0-9a-zA-Z]*", -1, -1, "^[0-9a-zA-Z]*", 0, false, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1);
ActivityContextInterface aci = new SmppTransactionProxy(esme);
SubmitMulti event = new SubmitMulti();
Date curDate = new Date();
this.fillSm(event, curDate, true);
event.setShortMessage(msgUcs2);
Address destAddr = new Address();
destAddr.setAddress("5555");
destAddr.setTon(SmppConstants.TON_INTERNATIONAL);
destAddr.setNpi(SmppConstants.NPI_E164);
event.addDestAddresses(destAddr);
Address destAddr2 = new Address();
destAddr2.setAddress("5556");
destAddr2.setTon(SmppConstants.TON_INTERNATIONAL);
destAddr2.setNpi(SmppConstants.NPI_E164);
event.addDestAddresses(destAddr2);
long dueSlot = this.pers.c2_getDueSlotForTime(scheduleDeliveryTime);
PreparedStatementCollection psc = this.pers.getStatementCollection(scheduleDeliveryTime);
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
this.sbb.onSubmitMulti(event, aci);
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
assertEquals(b1, 1);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
this.checkSmsSet(smsSet, curDate, true);
Sms sms = smsSet.getSms(0);
// msgUcs2
assertEquals(sms.getShortMessageText(), sMsg);
assertEquals(sms.getShortMessageBin(), udhCode);
assertEquals(this.smppSess.getReqList().size(), 0);
assertEquals(this.smppSess.getRespList().size(), 1);
SubmitMultiResp resp = (SubmitMultiResp) this.smppSess.getRespList().get(0);
assertEquals(resp.getCommandStatus(), 0);
assertEquals(resp.getOptionalParameterCount(), 0);
assertEquals(resp.getUnsucessfulSmes().size(), 0);
}
use of com.cloudhopper.smpp.type.Address 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 = "\nRxSmppServerSbb.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("\nSent 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("\nSent 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() + "\nsmsSet: " + smsSet, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_SEND_DELIVER_SM_000008);
}
}
use of com.cloudhopper.smpp.type.Address in project smscgateway by RestComm.
the class TxSmppServerSbb method onSubmitMultiLocal.
private void onSubmitMultiLocal(final TxSmppServerSbbUsage anSbbUsage, final com.cloudhopper.smpp.pdu.SubmitMulti event, final ActivityContextInterface aci) {
SmppTransaction smppServerTransaction = (SmppTransaction) aci.getActivity();
Esme esme = smppServerTransaction.getEsme();
String esmeName = esme.getName();
if (this.logger.isFineEnabled()) {
this.logger.fine("\nReceived SUBMIT_MULTI = " + event + " from Esme name=" + esmeName);
}
List<Address> addrList = event.getDestAddresses();
int msgCnt = 0;
if (addrList != null)
msgCnt = addrList.size();
CheckMessageLimitResult cres = esme.onMessageReceived(msgCnt);
if (cres.getResult() != CheckMessageLimitResult.Result.ok) {
if (cres.getResult() == CheckMessageLimitResult.Result.firstFault) {
this.updateOverrateCounters(cres);
this.logger.info(cres.getMessage());
}
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, cres.getMessage(), true);
}
SubmitMultiResp response = event.createResponse();
response.setCommandStatus(SmppConstants.STATUS_THROTTLED);
String s = cres.getMessage();
if (s.length() > 255)
s = s.substring(0, 255);
Tlv tlv;
try {
tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
response.addOptionalParameter(tlv);
} catch (TlvConvertException e) {
anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
}
// Lets send the Response with error here
long timestampB = 0L;
try {
this.smppServerSessions.sendResponsePdu(esme, event, response);
timestampB = System.currentTimeMillis();
} catch (Exception e) {
anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
}
try {
TargetAddress ta = createDestTargetAddress(event.getDestAddress(), esme.getNetworkId());
Sms sms = this.createSmsEvent(event, esme, ta, persistence);
sms.setTimestampB(timestampB);
generateFailureDetailedCdr(sms, EventType.IN_SMPP_REJECT_CONG, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_THROTTLED, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
} catch (SmscProcessingException e1) {
}
return;
}
SubmitMultiParseResult parseResult;
Sms singleSms = null;
try {
parseResult = this.createSmsEventMulti(event, esme, persistence, esme.getNetworkId());
for (Sms sms : parseResult.getParsedMessages()) {
singleSms = sms;
this.processSms(sms, persistence, esme, null, null, event, IncomingMessageType.submit_multi, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, event.getSequenceNumber());
}
} catch (SmscProcessingException e1) {
anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
SbbStatsUtils.handleProcessingException(e1, anSbbUsage);
if (!e1.isSkipErrorLogging()) {
if (e1.isIsWarning()) {
this.logger.warning(e1.getMessage());
} else {
this.logger.severe(e1.getMessage(), e1);
}
smscStatAggregator.updateMsgInFailedAll();
}
if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
if (singleSms != null) {
generateCDR(singleSms, CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), false, true);
} else {
generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
}
}
SubmitMultiResp response = event.createResponse();
response.setCommandStatus(e1.getSmppErrorCode());
String s = e1.getMessage();
if (s != null) {
if (s.length() > 255)
s = s.substring(0, 255);
Tlv tlv;
try {
tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
response.addOptionalParameter(tlv);
} catch (TlvConvertException e) {
this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
}
}
// Lets send the Response with error here
long timestampB = 0L;
try {
this.smppServerSessions.sendResponsePdu(esme, event, response);
timestampB = System.currentTimeMillis();
} catch (Exception e) {
anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
}
EventType eventType = null;
if (e1.getInternalErrorCode() == SmscProcessingException.INTERNAL_ERROR_STATE_OVERLOADED) {
eventType = EventType.IN_SMPP_REJECT_CONG;
} else {
eventType = EventType.IN_SMPP_REJECT_FORBIDDEN;
}
if (singleSms != null) {
singleSms.setTimestampB(timestampB);
generateRejectDetailedCdr(e1.getInternalErrorCode(), singleSms, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, e1.getSmppErrorCode(), esme.getRemoteAddressAndPort(), event.getSequenceNumber());
} else {
generateRejectDetailedCdr(e1.getInternalErrorCode(), event, esme, eventType, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, e1.getSmppErrorCode(), parseShortMessageText(event), timestampB);
}
return;
} catch (Throwable e1) {
anSbbUsage.incrementCounterErrorSubmitMultiSm(ONE);
String s = "Exception when processing SubmitMulti message: " + e1.getMessage();
this.logger.severe(s, e1);
smscStatAggregator.updateMsgInFailedAll();
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
generateCDR(parseShortMessageText(event), esme.getNetworkId(), esme.getSystemId(), event.getSourceAddress().getAddress(), event.getSourceAddress().getTon(), event.getSourceAddress().getNpi(), event.getDestAddress().getAddress(), event.getDestAddress().getTon(), event.getDestAddress().getNpi(), CdrGenerator.CDR_SUBMIT_FAILED_ESME, e1.getMessage(), true);
}
SubmitMultiResp response = event.createResponse();
response.setCommandStatus(SmppConstants.STATUS_SYSERR);
if (s.length() > 255)
s = s.substring(0, 255);
Tlv tlv;
try {
tlv = TlvUtil.createNullTerminatedStringTlv(SmppConstants.TAG_ADD_STATUS_INFO, s);
response.addOptionalParameter(tlv);
} catch (TlvConvertException e) {
this.logger.severe("TlvConvertException while storing TAG_ADD_STATUS_INFO Tlv parameter", e);
}
// Lets send the Response with error here
try {
this.smppServerSessions.sendResponsePdu(esme, event, response);
if (singleSms != null) {
singleSms.setTimestampB(System.currentTimeMillis());
generateFailureDetailedCdr(singleSms, EventType.IN_SMPP_ERROR, ErrorCode.REJECT_INCOMING, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_SYSERR, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
}
anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
} catch (Exception e) {
this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
}
return;
}
SubmitMultiResp response = event.createResponse();
Sms sms = null;
if (parseResult.getParsedMessages().size() > 0)
sms = parseResult.getParsedMessages().get(0);
if (sms != null)
response.setMessageId(sms.getMessageIdText());
for (UnsucessfulSME usme : parseResult.getBadAddresses()) {
try {
response.addUnsucessfulSME(usme);
} catch (SmppInvalidArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Lets send the Response with success here
try {
if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
this.smppServerSessions.sendResponsePdu(esme, event, response);
sms.setTimestampB(System.currentTimeMillis());
generateDetailedCDR(sms, EventType.IN_SMPP_RECEIVED, CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITMULTI, SmppConstants.STATUS_OK, esme.getRemoteAddressAndPort(), event.getSequenceNumber());
}
} catch (Throwable e) {
anSbbUsage.incrementCounterErrorSubmitMultiSmResponding(ONE);
this.logger.severe("Error while trying to send SubmitMultiResponse=" + response, e);
}
}
Aggregations