use of org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure 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.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure in project smscgateway by RestComm.
the class MessageDeliveryResultResponseMo method responseDeliveryFailure.
@Override
public void responseDeliveryFailure(DeliveryFailureReason reason, MAPErrorMessage errMessage) {
try {
MAPErrorMessage errorMessage;
if (errMessage != null && errMessage.isEmSMDeliveryFailure()) {
MAPErrorMessageSMDeliveryFailure smDeliveryFailure = errMessage.getEmSMDeliveryFailure();
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSMDeliveryFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), smDeliveryFailure.getSMEnumeratedDeliveryFailureCause(), null, null);
} else {
switch(reason) {
case destinationUnavalable:
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), NetworkResource.vlr, null, null);
break;
case invalidDestinationAddress:
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSMDeliveryFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), SMEnumeratedDeliveryFailureCause.subscriberNotSCSubscriber, null, null);
break;
case permanentNetworkError:
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), NetworkResource.vlr, null, null);
break;
case temporaryNetworkError:
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), NetworkResource.vlr, null, null);
break;
default:
errorMessage = this.provider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), NetworkResource.vlr, null, null);
break;
}
}
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
if (this.logger.isInfoEnabled()) {
this.logger.info("Sent ErrorComponent = " + errorMessage);
}
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
}
use of org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure in project smscgateway by RestComm.
the class MtCommonSbb 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
* @param removeSmsSet
* @param errMessage
* @param isImsiVlrReject
* @param processingType
*/
protected void onDeliveryError(SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason, boolean removeSmsSet, MAPErrorMessage errMessage, boolean isImsiVlrReject, ProcessingType processingType) {
try {
smscStatAggregator.updateMsgOutFailedAll();
// generating of a temporary failure CDR
if (smscPropertiesManagement.getGenerateTempFailureCdr())
this.generateTemporaryFailureCDR(CdrGenerator.CDR_TEMP_FAILED, reason);
StringBuilder sb = new StringBuilder();
sb.append("onDeliveryError: errorAction=");
sb.append(errorAction);
sb.append(", smStatus=");
sb.append(smStatus);
sb.append(", targetId=");
sb.append(smsSet.getTargetId());
sb.append(", smsSet=");
sb.append(smsSet);
sb.append(", reason=");
sb.append(reason);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
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>();
// generate text for Delivery receipts
// false
String dlrText = null;
if (errMessage != null) {
MAPErrorMessageSMDeliveryFailure smDeliveryFailure = errMessage.getEmSMDeliveryFailure();
if (smDeliveryFailure != null) {
SmsDeliverReportTpdu tpdu = null;
try {
tpdu = errMessage.getEmSMDeliveryFailure().getSmsDeliverReportTpdu();
} catch (MAPException e) {
// we ignore Exception here
}
if (tpdu != null) {
UserData userData = tpdu.getUserData();
if (userData != null) {
byte[] data = userData.getEncodedData();
if (data != null) {
String text = DatatypeConverter.printHexBinary(data);
String smDlrWithTpdu = SmscPropertiesManagement.getInstance().getSmDeliveryFailureDlrWithTpdu();
if (smDlrWithTpdu.equals("short")) {
if (text.length() > 20)
dlrText = text.substring(0, 20);
else
dlrText = text;
} else if (smDlrWithTpdu.equals("full")) {
dlrText = text;
}
}
}
}
}
}
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
synchronized (lock) {
try {
Date curDate = new Date();
smsSet.setStatus(smStatus);
// calculating of newDueDelay and NewDueTime
int newDueDelay = calculateNewDueDelay(smsSet, (errorAction == ErrorAction.subscriberBusy));
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);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured2, lstTempFailured2, errorAction, errMessage);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured2, null, null);
this.postProcessTempFailures(smsSet, lstTempFailured2, newDueDelay, newDueTime, true);
this.postProcessRerouted(lstRerouted, lstNewNetworkId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured2, (isImsiVlrReject ? CdrGenerator.CDR_FAILED_IMSI : CdrGenerator.CDR_FAILED), reason);
// sending of intermediate delivery receipts
this.generateIntermediateReceipts(smsSet, lstTempFailured2);
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured2, dlrText);
// sending of ReportSMDeliveryStatusRequest if needed
SMDeliveryOutcome smDeliveryOutcome = null;
switch(errorAction) {
case memoryCapacityExceededFlag:
smDeliveryOutcome = SMDeliveryOutcome.memoryCapacityExceeded;
break;
case mobileNotReachableFlag:
smDeliveryOutcome = SMDeliveryOutcome.absentSubscriber;
break;
case notReachableForGprs:
smDeliveryOutcome = SMDeliveryOutcome.absentSubscriber;
break;
}
if (smDeliveryOutcome != null && lstTempFailured2.size() > 0) {
Sms sms0 = smsSet.getSms(0);
String mtLocalSccpGt = null;
Integer mtRemoteSccpTt = null;
if (sms0 != null) {
mtLocalSccpGt = sms0.getMtLocalSccpGt();
mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
}
this.setupReportSMDeliveryStatusRequest(smsSet.getDestAddr(), smsSet.getDestAddrTon(), smsSet.getDestAddrNpi(), smDeliveryOutcome, smsSet.getTargetId(), smsSet.getNetworkId(), mtLocalSccpGt, mtRemoteSccpTt);
}
this.markDeliveringIsEnded(removeSmsSet);
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
logger.severe("Exception in MtCommonSbb.onDeliveryError(): " + e.getMessage(), e);
markDeliveringIsEnded(true);
}
}
Aggregations