use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.
the class HrSriServerSbb method onSriSuccess.
/**
* HrSriResultInterface
*/
@Override
public void onSriSuccess(CorrelationIdValue correlationIdValue, boolean sriBypass) {
MAPDialogSms dlg = this.getActivity();
if (dlg == null) {
this.logger.severe("Home routing: can not get MAPDialog for sending SRI positive Response");
return;
}
if (!sriBypass) {
smscStatAggregator.updateMsgInHrSriPosReq();
StringBuilder sb = new StringBuilder();
sb.append("Home routing: positive SRI response from HLR: transaction: ");
sb.append(correlationIdValue);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
}
// storing correlationId into a cache
try {
SmsSetCache.getInstance().putCorrelationIdCacheElement(correlationIdValue, smscPropertiesManagement.getCorrelationIdLiveTime());
} catch (Exception e1) {
if (dlg != null) {
dlg.release();
}
String reason = "Home routing: Exception when ImsiCacheElement : " + e1.toString();
this.logger.severe(reason, e1);
return;
}
// sending positive SRI response
try {
String smscAddressForCountryCode = this.getSmscAddressForCountryCode();
ISDNAddressString networkNodeNumber;
if (smscAddressForCountryCode != null) {
networkNodeNumber = this.mapParameterFactory.createISDNAddressString(AddressNature.international_number, NumberingPlan.ISDN, smscAddressForCountryCode);
} else {
networkNodeNumber = getNetworkNodeNumber(correlationIdValue.getNetworkId());
}
LocationInfoWithLMSI li = this.mapParameterFactory.createLocationInfoWithLMSI(networkNodeNumber, null, null, false, null);
this.doSendResponse(correlationIdValue, dlg, correlationIdValue.getCorrelationID(), li);
} catch (MAPException e) {
if (dlg != null) {
dlg.release();
}
String reason = "Home routing: MAPException when sending SRI positive Response : " + e.toString();
this.logger.severe(reason, e);
}
}
use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.
the class HrSriServerSbb method onSriFailure.
@Override
public void onSriFailure(CorrelationIdValue correlationIdValue, MAPErrorMessage errorResponse, String cause) {
MAPDialogSms dlg = this.getActivity();
if (dlg == null) {
this.logger.severe("Home routing: can not get MAPDialog for sending SRI negative Response");
return;
}
smscStatAggregator.updateMsgInHrSriNegReq();
StringBuilder sb = new StringBuilder();
sb.append("Home routing: negative SRI response from HLR: transaction: ");
sb.append(correlationIdValue);
sb.append(",\n cause=");
sb.append(cause);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
// sending negative SRI response
try {
// processing of error response
if (errorResponse == null) {
// no errorResponse obtained - we need to create SysteFailure
errorResponse = this.mapErrorMessageFactory.createMAPErrorMessageSystemFailure(dlg.getApplicationContext().getApplicationContextVersion().getVersion(), NetworkResource.hlr, null, null);
} else {
// we have errorResponse from HLR
// TODO: we need to update values depending on MAP protocol version
// not all versions support all messages
}
long invokeId = this.getInvokeId();
dlg.sendErrorComponent(invokeId, errorResponse);
dlg.close(false);
} catch (MAPException e) {
if (dlg != null) {
dlg.release();
}
String reason = "Home routing: MAPException when sending SRI negative Response: " + e.toString();
this.logger.severe(reason, e);
}
}
use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.
the class SriSbb method sendSRI.
// *********
// Main service methods
private void sendSRI(SmsSet smsSet, String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext) {
// Send out SRI
MAPDialogSms mapDialogSms = null;
try {
Sms sms0 = smsSet.getSms(0);
String mtLocalSccpGt = null;
Integer mtRemoteSccpTt = null;
if (sms0 != null) {
mtLocalSccpGt = sms0.getMtLocalSccpGt();
mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
}
// 1. Create Dialog first and add the SRI request to it
mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, smsSet.getNetworkId(), mtLocalSccpGt, mtRemoteSccpTt);
// 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 = "MAPException when sending SRI from sendSRI(): " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_SRI);
}
}
use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.
the class SriSbb method setupRoutingInfoForSMRequestIndication.
private MAPDialogSms setupRoutingInfoForSMRequestIndication(String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext, int networkId, String newMtLocalSccpGt, Integer newMtRemoteSccpTt) throws MAPException {
// this.mapParameterFactory.creat
String hlrAddress = destinationAddress;
String hrHlrNumber = smscPropertiesManagement.getHrHlrNumber(networkId);
if (hrHlrNumber != null && hrHlrNumber.length() > 0) {
hlrAddress = hrHlrNumber;
}
SccpAddress destinationAddr = this.convertAddressFieldToSCCPAddress(hlrAddress, ton, npi, newMtRemoteSccpTt);
SccpAddress originSccpAddress;
if (newMtLocalSccpGt != null) {
originSccpAddress = this.getServiceCenterSccpAddress(newMtLocalSccpGt, networkId);
} else {
originSccpAddress = this.getServiceCenterSccpAddress(networkId);
}
MAPDialogSms mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, destinationAddr, null);
mapDialogSms.setNetworkId(networkId);
ISDNAddressString isdn = this.getCalledPartyISDNAddressString(destinationAddress, ton, npi);
AddressString serviceCenterAddress = this.getServiceCenterAddressString(networkId);
boolean sm_RP_PRI = true;
mapDialogSms.addSendRoutingInfoForSMRequest(isdn, sm_RP_PRI, serviceCenterAddress, null, false, null, null, null);
if (this.logger.isInfoEnabled())
this.logger.info("\nSending: SendRoutingInfoForSMRequest: isdn=" + isdn + ", serviceCenterAddress=" + serviceCenterAddress + ", sm_RP_PRI=" + sm_RP_PRI);
return mapDialogSms;
}
use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.
the class MoSbb method onMtForwardShortMessageRequest.
/**
* @param evt
* @param aci
*/
public void onMtForwardShortMessageRequest(MtForwardShortMessageRequest evt, ActivityContextInterface aci) {
if (this.logger.isFineEnabled()) {
this.logger.fine("\nReceived MT_FORWARD_SHORT_MESSAGE_REQUEST = " + evt);
}
this.setProcessingState(MoProcessingState.OtherDataRecieved);
MAPDialogSms dialog = evt.getMAPDialog();
if (smscPropertiesManagement.getHrCharging() == MoChargingType.reject) {
try {
MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
if (this.logger.isInfoEnabled()) {
this.logger.info("\nSent ErrorComponent = " + errorMessage);
}
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_HR, errorMessage.toString(), true);
}
dialog.close(false);
return;
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
}
Sms sms = null;
try {
String originatorSccpAddress = null;
SccpAddress sccpAddress = dialog.getRemoteAddress();
if (sccpAddress != null) {
GlobalTitle gt = sccpAddress.getGlobalTitle();
if (gt != null)
originatorSccpAddress = gt.getDigits();
}
sms = this.processMtMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, false, evt.getMAPDialog(), evt, evt.getInvokeId());
if (sms != null) {
this.processSms(sms, persistence, smscPropertiesManagement.getHrCharging(), false, dialog, evt, evt.getInvokeId());
}
} catch (SmscProcessingException e1) {
this.logger.severe(e1.getMessage(), e1);
try {
MAPErrorMessage errorMessage;
switch(e1.getMapErrorCode()) {
case MAPErrorCode.unexpectedDataValue:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.unexpectedDataValue, null);
break;
case MAPErrorCode.systemFailure:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
break;
case MAPErrorCode.resourceLimitation:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.resourceLimitation, null);
break;
case MAPErrorCode.facilityNotSupported:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
break;
default:
errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
break;
}
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
if (this.logger.isInfoEnabled()) {
this.logger.info("\nSent ErrorComponent = " + errorMessage);
}
if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
if (sms != null) {
generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_HR, e1.getMessage(), false, true);
} else {
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_HR, errorMessage.toString(), true);
}
}
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
return;
} catch (Throwable e1) {
this.logger.severe("Exception while processing MO message: " + e1.getMessage(), e1);
try {
MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
dialog.close(false);
if (smscPropertiesManagement.isGenerateRejectionCdr()) {
generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_HR, errorMessage.toString(), true);
}
} catch (Throwable e) {
logger.severe("Error while sending Error message", e);
return;
}
return;
}
if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
try {
dialog.addMtForwardShortMessageResponse(evt.getInvokeId(), null, null);
if (this.logger.isFineEnabled()) {
this.logger.fine("\nSent MtForwardShortMessageResponse = " + evt);
}
dialog.close(false);
} catch (Throwable e) {
logger.severe("Error while sending MoForwardShortMessageResponse ", e);
}
}
}
Aggregations