use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class RxSipServerSbb method onGLOBAL_FAILURE.
public void onGLOBAL_FAILURE(javax.sip.ResponseEvent event, ActivityContextInterface aci) {
this.logger.severe("onGLOBAL_FAILURE " + event);
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("RxSipServerSbb.onGLOBAL_FAILURE(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
// TODO : Is GLOBAL FAILURE PERMANENT?
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.SC_SYSTEM_ERROR, "SIP Exception GLOBAL_FAILURE received. Reason : " + event.getResponse().getReasonPhrase() + " Status Code : " + event.getResponse().getStatusCode());
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class RxSipServerSbb method onSUCCESS.
public void onSUCCESS(javax.sip.ResponseEvent event, ActivityContextInterface aci) {
if (this.logger.isFineEnabled()) {
this.logger.fine("onSUCCESS " + event);
}
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("RxSipServerSbb.onSUCCESS(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
try {
smscStatAggregator.updateMsgOutSentAll();
smscStatAggregator.updateMsgOutSentSip();
// current message is sent pushing current message into an archive
Sms sms = this.getMessageInSendingPool(0);
if (sms == null) {
logger.severe("RxSipServerSbb.onSUCCESS(): CMP sms is missed. smsSet=" + smsSet);
markDeliveringIsEnded(true);
return;
}
// firstly sending of a positive response for transactional mode
sendTransactionalResponseSuccess(sms);
// mproc rules applying for delivery phase
this.applyMprocRulesOnSuccess(sms, ProcessingType.SIP);
// Processing succeeded
sms.getSmsSet().setStatus(ErrorCode.SUCCESS);
this.postProcessSucceeded(sms, null, null);
// success CDR generating
boolean isPartial = MessageUtil.isSmsNotLastSegment(sms);
this.generateCDR(sms, isPartial ? CdrGenerator.CDR_PARTIAL_SIP : CdrGenerator.CDR_SUCCESS_SIP, CdrGenerator.CDR_SUCCESS_NO_REASON, false, true, -1);
// adding a success receipt if it is needed
this.generateSuccessReceipt(smsSet, sms);
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
// marking the message in cache as delivered
this.commitSendingPoolMsgCount();
// now we are trying to sent other messages
if (this.getTotalUnsentMessageCount() > 0) {
try {
this.sendMessage(smsSet);
return;
} catch (SmscProcessingException e) {
String s = "SmscProcessingException when sending sendMessage()=" + e.getMessage() + ", Message=" + sms;
logger.severe(s, e);
markDeliveringIsEnded(true);
}
}
// no more messages to send - remove smsSet
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
}
} finally {
persistence.releaseSynchroObject(lock);
}
} catch (Throwable e1) {
String s = "Exception in RxSipServerSbb.onSUCCESS() when fetching records and issuing events: " + e1.getMessage();
logger.severe(s, e1);
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s);
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class TxSipServerSbb method createSmsEvent.
// *********
// Messages processing
protected Sms createSmsEvent(String fromUser, byte[] message, TargetAddress ta, PersistenceRAInterface store, byte[] udh, DataCodingSchemeImpl dataCodingScheme, Date validityPeriod, int regDeliveryInt, int networkId) throws SmscProcessingException {
Sms sms = new Sms();
sms.setDbId(UUID.randomUUID());
sms.setOriginationType(OriginationType.SIP);
sms.setRegisteredDelivery(regDeliveryInt);
// checking of source address
if (fromUser == null)
fromUser = "???";
boolean isDigital = true;
for (char ch : fromUser.toCharArray()) {
if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7' && ch != '8' && ch != '9' && ch != '*' && ch != '#' && ch != 'a' && ch != 'b' && ch != 'c') {
isDigital = false;
break;
}
}
if (isDigital) {
if (fromUser.length() > 20) {
fromUser = fromUser.substring(0, 20);
}
sms.setSourceAddr(fromUser);
sms.setSourceAddrTon(smscPropertiesManagement.getDefaultTon());
sms.setSourceAddrNpi(smscPropertiesManagement.getDefaultNpi());
} else {
if (fromUser.length() > 11) {
fromUser = fromUser.substring(0, 11);
}
sms.setSourceAddr(fromUser);
sms.setSourceAddrTon(SmppConstants.TON_ALPHANUMERIC);
sms.setSourceAddrNpi(smscPropertiesManagement.getDefaultNpi());
}
int messageingMode = (smscPropertiesManagement.getSipDefaultMessagingMode() & 0x03);
sms.setEsmClass(messageingMode);
sms.setOrigNetworkId(networkId);
// checking for a destination address
isDigital = true;
for (char ch : ta.getAddr().toCharArray()) {
if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7' && ch != '8' && ch != '9' && ch != '*' && ch != '#' && ch != 'a' && ch != 'b' && ch != 'c') {
isDigital = false;
break;
}
}
if (!isDigital) {
throw new SmscProcessingException("Destination address contains not only digits, *, #, a, b, or c characters: " + ta.getAddr(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, null);
}
if (ta.getAddr().length() > 20) {
throw new SmscProcessingException("Destination address has too long length: " + ta.getAddr(), SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, null);
}
if (ta.getAddr().length() == 0) {
throw new SmscProcessingException("Destination address has no digits", SmppConstants.STATUS_SUBMITFAIL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, null);
}
// processing of a message text
if (message == null)
message = new byte[0];
String msg = new String(message, utf8);
sms.setShortMessageText(msg);
if (udh != null) {
sms.setShortMessageBin(udh);
int esmClass = sms.getEsmClass();
// Add UDH
esmClass = esmClass | 0x40;
sms.setEsmClass(esmClass);
}
sms.setDataCoding(dataCodingScheme.getCode());
// checking max message length
int messageLen = MessageUtil.getMessageLengthInBytes(dataCodingScheme, msg, null);
int lenSolid = MessageUtil.getMaxSolidMessageBytesLength();
int lenSegmented = MessageUtil.getMaxSegmentedMessageBytesLength();
// splitting by SMSC is supported for all messages from SIP
if (messageLen > lenSegmented * 255) {
throw new SmscProcessingException("Message length in bytes is too big for segmented message: " + messageLen + ">" + lenSegmented, SmppConstants.STATUS_INVPARLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
}
sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
sms.setPriority(0);
MessageUtil.applyValidityPeriod(sms, validityPeriod, false, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
SmsSet smsSet;
smsSet = new SmsSet();
smsSet.setDestAddr(ta.getAddr());
smsSet.setDestAddrNpi(ta.getAddrNpi());
smsSet.setDestAddrTon(ta.getAddrTon());
smsSet.setNetworkId(networkId);
smsSet.addSms(sms);
sms.setSmsSet(smsSet);
long messageId = store.c2_getNextMessageId();
SmscStatProvider.getInstance().setCurrentMessageId(messageId);
sms.setMessageId(messageId);
return sms;
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class DeliveryCommonSbb method onTimerEvent.
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci, EventContext eventContext) {
SmsSet smsSet = getSmsSet();
if (smsSet != null) {
// deliver timer is triggered
String reason = "Delivery timeout error: sendingPoolMessageCount=" + this.getSendingPoolMessageCount() + ", smsSet=" + smsSet;
this.logger.severe(reason);
onDeliveryTimeout(smsSet, reason);
}
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class RxSmppServerSbbTest method testSubmitSm_test3_3.
@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test3_3() throws Exception {
if (!this.cassandraDbInited)
return;
ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
SmsDef sd1 = new SmsDef();
String s01 = "1234567890";
StringBuilder sb = new StringBuilder();
for (int i1 = 0; i1 < 20; i1++) {
sb.append(s01);
}
sd1.msg = sb.toString();
sd1.stored = true;
lst.add(sd1);
SmsDef sd2 = new SmsDef();
sd2.msg = "Msg 2";
sd2.stored = true;
lst.add(sd2);
SmsSet smsSet = prepareDatabase(lst);
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
EventContext eventContext = null;
ActivityContextInterface aci = new SmppTransactionProxy(esme);
this.sbb.onDeliverSm(event, aci, eventContext);
DeliverSmResp eventResp = new DeliverSmResp();
eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
eventResp = new DeliverSmResp();
eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
eventResp = new DeliverSmResp();
eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
}
Aggregations