Search in sources :

Example 6 with MAPDialogSms

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);
    }
}
Also used : LocationInfoWithLMSI(org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPException(org.mobicents.protocols.ss7.map.api.MAPException)

Example 7 with MAPDialogSms

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);
    }
}
Also used : MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString)

Example 8 with MAPDialogSms

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);
    }
}
Also used : MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ActivityContextInterface(javax.slee.ActivityContextInterface) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) Sms(org.mobicents.smsc.library.Sms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPErrorCode(org.mobicents.protocols.ss7.map.api.errors.MAPErrorCode) ErrorCode(org.mobicents.smsc.library.ErrorCode)

Example 9 with MAPDialogSms

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;
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString)

Example 10 with 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);
        }
    }
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) GlobalTitle(org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Aggregations

MAPDialogSms (org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms)25 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)17 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)16 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)14 SccpAddress (org.mobicents.protocols.ss7.sccp.parameter.SccpAddress)8 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)6 ActivityContextInterface (javax.slee.ActivityContextInterface)4 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)4 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)3 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)3 SmsTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu)3 GlobalTitle (org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle)3 Sms (org.mobicents.smsc.library.Sms)3 SmsSet (org.mobicents.smsc.library.SmsSet)3 MAPApplicationContext (org.mobicents.protocols.ss7.map.api.MAPApplicationContext)2 MAPErrorMessageSubscriberBusyForMtSms (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms)2 LocationInfoWithLMSI (org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI)2 SM_RP_OA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA)2 SmsSubmitTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2