use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.
the class MAPListener method onMtForwardShortMessageRequest.
@Override
public void onMtForwardShortMessageRequest(MtForwardShortMessageRequest event) {
if (logger.isInfoEnabled()) {
logger.info("Rx : onMtForwardShortMessageIndication=" + event);
}
// Lets first close the Dialog
MAPDialogSms mapDialogSms = event.getMAPDialog();
// boolean sendError = true;
try {
if (this.currentMapMessageCount % 7 == 0) {
// if (sendError) {
// Send back AbsentSubscriber for every 7th MtSMS
MAPErrorMessage mapErrorMessage = mAPErrorMessageFactory.createMAPErrorMessageAbsentSubscriberSM(AbsentSubscriberDiagnosticSM.IMSIDetached, null, null);
mapDialogSms.sendErrorComponent(event.getInvokeId(), mapErrorMessage);
// mapDialogSms.close(false);
} else {
mapDialogSms.addMtForwardShortMessageResponse(event.getInvokeId(), null, null);
// mapDialogSms.close(false);
}
} catch (MAPException e) {
logger.error("Error while sending MAPErrorMessageAbsentSubscriberSM ", e);
}
mapDialogSms.setUserObject(true);
}
use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.
the class HrSriClientSbb method sendSRI.
private void sendSRI(String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext, CorrelationIdValue correlationIdValue) {
// Send out SRI
MAPDialogSms mapDialogSms = null;
try {
// 1. Create Dialog first and add the SRI request to it
mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, correlationIdValue.getNetworkId());
// 2. Create the ACI and attach this SBB
ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
sriDialogACI.attach(this.sbbContext.getSbbLocalObject());
// 3. Finally send the request
mapDialogSms.send();
} catch (MAPException e) {
if (mapDialogSms != null) {
mapDialogSms.release();
}
String reason = "Home routing: HrSriClientSbb: MAPException when sending SRI from sendSRI(): " + e.toString();
this.logger.severe(reason, e);
this.returnSriFailure(correlationIdValue, null, reason);
}
}
use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.
the class AlertSbb method onAlertServiceCentreRequest.
public void onAlertServiceCentreRequest(AlertServiceCentreRequest evt, ActivityContextInterface aci) {
if (this.logger.isFineEnabled()) {
this.logger.fine("\nReceived onAlertServiceCentreRequest= " + evt);
}
try {
MAPDialogSms mapDialogSms = evt.getMAPDialog();
MAPApplicationContext mapApplicationContext = mapDialogSms.getApplicationContext();
if (mapApplicationContext.getApplicationContextVersion() == MAPApplicationContextVersion.version2) {
// Send back response only for V2
mapDialogSms.addAlertServiceCentreResponse(evt.getInvokeId());
if (this.logger.isFineEnabled()) {
this.logger.fine("\nSending AlertServiceCentreResponse");
}
mapDialogSms.close(false);
} else {
mapDialogSms.release();
}
this.setupAlert(evt.getMsisdn(), evt.getServiceCentreAddress(), mapDialogSms.getNetworkId());
} catch (MAPException e) {
logger.severe("Exception while trying to send back AlertServiceCentreResponse", e);
}
}
use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.
the class MtSbb method onErrorComponent.
// *********
// MAP Component events
@Override
public void onErrorComponent(ErrorComponent event, ActivityContextInterface aci) {
try {
super.onErrorComponent(event, aci);
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onErrorComponent(): CMP smsSet is missed");
return;
}
MAPErrorMessage mapErrorMessage = event.getMAPErrorMessage();
if (mapErrorMessage.isEmSubscriberBusyForMtSms()) {
MAPErrorMessageSubscriberBusyForMtSms subscriberBusyForMtSms = mapErrorMessage.getEmSubscriberBusyForMtSms();
this.onDeliveryError(smsSet, ErrorAction.subscriberBusy, ErrorCode.USER_BUSY, "Error subscriberBusyForMtSms after MtForwardSM Request: " + subscriberBusyForMtSms.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else if (mapErrorMessage.isEmAbsentSubscriber()) {
MAPErrorMessageAbsentSubscriber absentSubscriber = mapErrorMessage.getEmAbsentSubscriber();
this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "Error absentSubscriber after MtForwardSM Request: " + absentSubscriber.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else if (mapErrorMessage.isEmAbsentSubscriberSM()) {
MAPErrorMessageAbsentSubscriberSM absentSubscriber = mapErrorMessage.getEmAbsentSubscriberSM();
this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "Error absentSubscriberSM after MtForwardSM Request: " + absentSubscriber.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else if (mapErrorMessage.isEmSMDeliveryFailure()) {
MAPErrorMessageSMDeliveryFailure smDeliveryFailure = mapErrorMessage.getEmSMDeliveryFailure();
SmsDeliverReportTpdu tpdu = null;
try {
tpdu = smDeliveryFailure.getSmsDeliverReportTpdu();
} catch (MAPException e) {
// we skip any possible Exception here
}
ErrorAction errAction;
// checking firstly a case of FailureCause existence in tpdu
if (tpdu != null && tpdu.getFailureCause() != null) {
int tpduCauseCode = tpdu.getFailureCause().getCode();
PermanentTemporaryFailure tpFailureCauseStatus = SmscPropertiesManagement.getInstance().getSmDeliveryFailureTpCause(tpduCauseCode);
if (tpFailureCauseStatus == PermanentTemporaryFailure.temporary) {
errAction = ErrorAction.temporaryFailure;
} else {
errAction = ErrorAction.permanentFailure;
}
this.onDeliveryError(smsSet, errAction, ErrorCode.SENDING_SM_FAILED, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else {
// no FailureCause existence in tpdu - then checking DeliveryFailureCause code
PermanentTemporaryFailure smDlrStatus = SmscPropertiesManagement.getInstance().getSmDeliveryFailure(smDeliveryFailure.getSMEnumeratedDeliveryFailureCause().getCode());
if (smDeliveryFailure.getSMEnumeratedDeliveryFailureCause() == SMEnumeratedDeliveryFailureCause.memoryCapacityExceeded) {
if (smDlrStatus == PermanentTemporaryFailure.permanent)
errAction = ErrorAction.permanentFailure;
else
errAction = ErrorAction.memoryCapacityExceededFlag;
this.onDeliveryError(smsSet, errAction, ErrorCode.MESSAGE_QUEUE_FULL, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else {
if (smDlrStatus == PermanentTemporaryFailure.temporary)
errAction = ErrorAction.temporaryFailure;
else
errAction = ErrorAction.permanentFailure;
this.onDeliveryError(smsSet, errAction, ErrorCode.SENDING_SM_FAILED, "Error smDeliveryFailure after MtForwardSM Request: " + smDeliveryFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
}
}
} else if (mapErrorMessage.isEmSystemFailure()) {
// TODO: may be it is not a permanent case ???
MAPErrorMessageSystemFailure systemFailure = mapErrorMessage.getEmSystemFailure();
this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SYSTEM_FAILURE, "Error systemFailure after MtForwardSM Request: " + systemFailure.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else if (mapErrorMessage.isEmFacilityNotSup()) {
MAPErrorMessageFacilityNotSup facilityNotSup = mapErrorMessage.getEmFacilityNotSup();
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.FACILITY_NOT_SUPPORTED, "Error facilityNotSup after MtForwardSM Request: " + facilityNotSup.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
} else if (mapErrorMessage.isEmExtensionContainer()) {
MAPErrorMessageExtensionContainer extensionContainer = mapErrorMessage.getEmExtensionContainer();
switch((int) (long) extensionContainer.getErrorCode()) {
case MAPErrorCode.dataMissing:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.DATA_MISSING, "Error dataMissing after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
case MAPErrorCode.unexpectedDataValue:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNEXPECTED_DATA, "Error unexpectedDataValue after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
// break;
case MAPErrorCode.unidentifiedSubscriber:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNDEFINED_SUBSCRIBER, "Error unidentifiedSubscriber after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
case MAPErrorCode.illegalSubscriber:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.ILLEGAL_SUBSCRIBER, "Error illegalSubscriber after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
case MAPErrorCode.illegalEquipment:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.ILLEGAL_EQUIPMENT, "Error illegalEquipment after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
default:
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.SYSTEM_FAILURE, "Error after MtForwardSM Request: " + extensionContainer.toString(), true, mapErrorMessage, false, ProcessingType.SS7_MT);
break;
}
} else {
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.SYSTEM_FAILURE, "Error after MtForwardSM Request: " + mapErrorMessage, true, mapErrorMessage, false, ProcessingType.SS7_MT);
}
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onErrorComponent() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.
the class MtSbb method sendMtSms.
private void sendMtSms(MAPApplicationContext mapApplicationContext, MessageProcessingState messageProcessingState, MAPDialogSms mapDialogSms, int networkId) throws SmscProcessingException {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
throw new SmscProcessingException("CMP smsSet is missed", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
Sms sms = this.getMessageInSendingPool(0);
if (sms == null) {
throw new SmscProcessingException("sms is missed in CMP", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
boolean moreMessagesToSend = false;
try {
if (this.getTotalUnsentMessageCount() > 1) {
moreMessagesToSend = true;
}
} catch (Throwable e) {
}
try {
boolean newDialog = false;
if (mapDialogSms == null) {
newDialog = true;
String mtLocalSccpGt = sms.getMtLocalSccpGt();
SccpAddress originSccpAddress;
if (mtLocalSccpGt != null) {
originSccpAddress = this.getServiceCenterSccpAddress(mtLocalSccpGt, networkId);
} else {
originSccpAddress = this.getServiceCenterSccpAddress(networkId);
}
mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, this.getNetworkNode(), null);
mapDialogSms.setNetworkId(networkId);
ActivityContextInterface mtFOSmsDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
mtFOSmsDialogACI.attach(this.sbbContext.getSbbLocalObject());
}
// setting TON / NPI to unknown for unsupported source TON / NPI
int sourceAddrTon = sms.getSourceAddrTon();
if (sourceAddrTon < 0 || sourceAddrTon > 6)
sourceAddrTon = 0;
int sourceAddrNpi = sms.getSourceAddrNpi();
if (sourceAddrTon == SmppConstants.TON_ALPHANUMERIC) {
sourceAddrNpi = SmppConstants.NPI_UNKNOWN;
} else {
if (sourceAddrNpi >= 0 && sourceAddrNpi <= 1 || sourceAddrNpi >= 3 && sourceAddrNpi <= 9 || sourceAddrNpi >= 10 && sourceAddrNpi <= 1 || sourceAddrNpi == 18) {
} else {
sourceAddrNpi = SmppConstants.NPI_UNKNOWN;
}
}
SM_RP_DA sm_RP_DA = this.getSmRpDa();
SM_RP_OA sm_RP_OA = this.getSmRpOa();
SmsSignalInfo smsSignalInfo;
if (messageProcessingState == MessageProcessingState.firstMessageSending) {
int dcs = sms.getDataCoding();
Tlv dest_addr_subunit = sms.getTlvSet().getOptionalParameter(SmppConstants.TAG_DEST_ADDR_SUBUNIT);
if (dest_addr_subunit != null) {
try {
int mclass = dest_addr_subunit.getValueAsByte();
if (mclass >= 1 && mclass <= 4) {
dcs |= (0x10 + (mclass - 1));
}
} catch (TlvConvertException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
DataCodingScheme dataCodingScheme = this.mapSmsTpduParameterFactory.createDataCodingScheme(dcs);
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);
SmsSignalInfo[] segments;
SmsDeliveryReportData smsDeliveryReportData = SmsDeliveryReportData.decodeFromString(sms.getShortMessageText());
if (smsDeliveryReportData != null) {
// this is SMS-STATUS-REPORT
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfoStatusReport(sms, moreMessagesToSend, smsDeliveryReportData);
} else if ((sms.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0) {
// message already contains UDH - we can not slice it
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfo(sms, sms.getShortMessageText(), sms.getShortMessageBin(), moreMessagesToSend, 0, 1, 1, dataCodingScheme, 0, 0, sourceAddrTon, sourceAddrNpi);
} else if (sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null) {
// we have tlv's that define message count/number/reference
int messageSegmentCount = sarTotalSegments.getValueAsUnsignedByte();
int messageSegmentNumber = sarSegmentSeqnum.getValueAsUnsignedByte();
int messageReferenceNumber = sarMsgRefNum.getValueAsUnsignedShort();
segments = new SmsSignalInfo[1];
segments[0] = this.createSignalInfo(sms, sms.getShortMessageText(), null, moreMessagesToSend, messageReferenceNumber, messageSegmentCount, messageSegmentNumber, dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift(), sourceAddrTon, sourceAddrNpi);
} else {
// possible a big message and segmentation
String[] segmentsByte;
segmentsByte = MessageUtil.sliceMessage(sms.getShortMessageText(), dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift());
segments = new SmsSignalInfo[segmentsByte.length];
// TODO messageReferenceNumber should be generated
// int messageReferenceNumber = (int) (this.getCurrentMsgNumValue() + 1);
int messageReferenceNumber = (int) (this.getCurrentMsgNumValue());
for (int i1 = 0; i1 < segmentsByte.length; i1++) {
segments[i1] = this.createSignalInfo(sms, segmentsByte[i1], null, (i1 < segmentsByte.length - 1 ? true : moreMessagesToSend), messageReferenceNumber, segmentsByte.length, i1 + 1, dataCodingScheme, sms.getNationalLanguageLockingShift(), sms.getNationalLanguageSingleShift(), sourceAddrTon, sourceAddrNpi);
}
}
this.setSegments(segments);
smsSignalInfo = segments[0];
this.setMessageSegmentNumber(0);
if (segments.length > 1)
moreMessagesToSend = true;
} else {
int messageSegmentNumber = this.getMessageSegmentNumber();
SmsSignalInfo[] segments = this.getSegments();
smsSignalInfo = segments[messageSegmentNumber];
if (messageSegmentNumber < segments.length - 1)
moreMessagesToSend = true;
}
long invokeId = 0;
switch(mapDialogSms.getApplicationContext().getApplicationContextVersion()) {
case version3:
invokeId = mapDialogSms.addMtForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, smsSignalInfo, moreMessagesToSend, null);
if (this.logger.isInfoEnabled()) {
this.logger.info("\nSending: MtForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + smsSignalInfo + ", moreMessagesToSend=" + moreMessagesToSend);
}
break;
case version2:
case version1:
invokeId = mapDialogSms.addForwardShortMessageRequest(sm_RP_DA, sm_RP_OA, smsSignalInfo, moreMessagesToSend);
if (this.logger.isInfoEnabled()) {
this.logger.info("\nSending: ForwardShortMessageRequest: sm_RP_DA=" + sm_RP_DA + ", sm_RP_OA=" + sm_RP_OA + ", si=" + smsSignalInfo + ", moreMessagesToSend=" + moreMessagesToSend);
}
break;
default:
break;
}
int messageUserDataLengthOnSend = mapDialogSms.getMessageUserDataLengthOnSend();
int maxUserDataLength = mapDialogSms.getMaxUserDataLength();
if (mapDialogSms.getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1 && newDialog && messageUserDataLengthOnSend >= maxUserDataLength - SmscPropertiesManagement.getInstance().getMaxMessageLengthReducer()) {
mapDialogSms.cancelInvocation(invokeId);
this.setTcEmptySent(1);
} else {
this.setTcEmptySent(0);
}
mapDialogSms.send();
sms.putMsgPartDeliveryTime(getMessageSegmentNumber(), System.currentTimeMillis());
} catch (MAPException e) {
if (mapDialogSms != null)
mapDialogSms.release();
throw new SmscProcessingException("MAPException when sending MtForwardSM. \nSms=" + sms, -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
} catch (TlvConvertException e) {
if (mapDialogSms != null)
mapDialogSms.release();
throw new SmscProcessingException("TlvConvertException when sending MtForwardSM", -1, -1, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
}
}
Aggregations