/protocols/ss7/map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/sms/MAPDialogSmsImpl.java
Java | 596 lines | 426 code | 130 blank | 40 comment | 116 complexity | da316b7a875094380a51ca8b638cec51 MD5 | raw file
1/* 2 * JBoss, Home of Professional Open Source 3 * Copyright 2011, Red Hat, Inc. and individual contributors 4 * by the @authors tag. See the copyright.txt in the distribution for a 5 * full listing of individual contributors. 6 * 7 * This is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation; either version 2.1 of 10 * the License, or (at your option) any later version. 11 * 12 * This software is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this software; if not, write to the Free 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 21 */ 22 23package org.mobicents.protocols.ss7.map.service.sms; 24 25import org.mobicents.protocols.asn.AsnOutputStream; 26import org.mobicents.protocols.ss7.map.MAPDialogImpl; 27import org.mobicents.protocols.ss7.map.MAPProviderImpl; 28import org.mobicents.protocols.ss7.map.api.MAPApplicationContext; 29import org.mobicents.protocols.ss7.map.api.MAPApplicationContextName; 30import org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion; 31import org.mobicents.protocols.ss7.map.api.MAPException; 32import org.mobicents.protocols.ss7.map.api.MAPOperationCode; 33import org.mobicents.protocols.ss7.map.api.primitives.AddressString; 34import org.mobicents.protocols.ss7.map.api.primitives.IMSI; 35import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString; 36import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; 37import org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI; 38import org.mobicents.protocols.ss7.map.api.service.sms.MAPServiceSms; 39import org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms; 40import org.mobicents.protocols.ss7.map.api.service.sms.MWStatus; 41import org.mobicents.protocols.ss7.map.api.service.sms.SMDeliveryOutcome; 42import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA; 43import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_MTI; 44import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA; 45import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_SMEA; 46import org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo; 47import org.mobicents.protocols.ss7.tcap.api.TCAPException; 48import org.mobicents.protocols.ss7.tcap.api.tc.component.InvokeClass; 49import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog; 50import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke; 51import org.mobicents.protocols.ss7.tcap.asn.comp.ReturnResultLast; 52import org.mobicents.protocols.ss7.tcap.asn.comp.OperationCode; 53import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter; 54 55/** 56 * 57 * @author sergey vetyutnev 58 * 59 */ 60public class MAPDialogSmsImpl extends MAPDialogImpl implements MAPDialogSms { 61 62 protected MAPDialogSmsImpl(MAPApplicationContext appCntx, Dialog tcapDialog, MAPProviderImpl mapProviderImpl, MAPServiceSms mapService, 63 AddressString origReference, AddressString destReference) { 64 super(appCntx, tcapDialog, mapProviderImpl, mapService, origReference, destReference); 65 } 66 67 68 @Override 69 public Long addForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend) throws MAPException { 70 return addForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend); 71 } 72 73 @Override 74 public Long addForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend) 75 throws MAPException { 76 77 if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext && this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext) 78 || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) 79 throw new MAPException("Bad application context name for addForwardShortMessageRequest: must be shortMsgMORelayContext_V1 or V2 or shortMsgMTRelayContext_V1 or V2"); 80 81 if (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2) 82 moreMessagesToSend = false; 83 84 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 85 if (customInvokeTimeout == _Timer_Default) 86 invoke.setTimeout(_Timer_ml); 87 else 88 invoke.setTimeout(customInvokeTimeout); 89 90 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 91 oc.setLocalOperationCode((long)MAPOperationCode.mo_forwardSM); 92 invoke.setOperationCode(oc); 93 94 ForwardShortMessageRequestIndicationImpl req = new ForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend); 95 AsnOutputStream aos = new AsnOutputStream(); 96 req.encodeData(aos); 97 98 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 99 p.setTagClass(req.getTagClass()); 100 p.setPrimitive(req.getIsPrimitive()); 101 p.setTag(req.getTag()); 102 p.setData(aos.toByteArray()); 103 invoke.setParameter(p); 104 105 Long invokeId; 106 try { 107 invokeId = this.tcapDialog.getNewInvokeId(); 108 invoke.setInvokeId(invokeId); 109 } catch (TCAPException e) { 110 throw new MAPException(e.getMessage(), e); 111 } 112 113 this.sendInvokeComponent(invoke); 114 115 return invokeId; 116 } 117 118 @Override 119 public void addForwardShortMessageResponse(long invokeId) throws MAPException { 120 121 if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext && this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext) 122 || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) 123 throw new MAPException("Bad application context name for addForwardShortMessageResponse: must be shortMsgMORelayContext_V1 or V2 or shortMsgMTRelayContext_V1 or V2"); 124 125 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 126 127 resultLast.setInvokeId(invokeId); 128 129 // we need not Operation Code because no answer 130 131 this.sendReturnResultLastComponent(resultLast); 132 } 133 134 @Override 135 public Long addMoForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer, IMSI imsi) 136 throws MAPException { 137 return addMoForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, extensionContainer, imsi); 138 } 139 140 @Override 141 public Long addMoForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, 142 MAPExtensionContainer extensionContainer, IMSI imsi) throws MAPException { 143 144 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext 145 || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3) 146 throw new MAPException("Bad application context name for addMoForwardShortMessageRequest: must be shortMsgMORelayContext_V3"); 147 148 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 149 if (customInvokeTimeout == _Timer_Default) 150 invoke.setTimeout(_Timer_ml); 151 else 152 invoke.setTimeout(customInvokeTimeout); 153 154 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 155 oc.setLocalOperationCode((long)MAPOperationCode.mo_forwardSM); 156 invoke.setOperationCode(oc); 157 158 MoForwardShortMessageRequestIndicationImpl req = new MoForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, extensionContainer, imsi); 159 AsnOutputStream aos = new AsnOutputStream(); 160 req.encodeData(aos); 161 162 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 163 p.setTagClass(req.getTagClass()); 164 p.setPrimitive(req.getIsPrimitive()); 165 p.setTag(req.getTag()); 166 p.setData(aos.toByteArray()); 167 invoke.setParameter(p); 168 169 Long invokeId; 170 try { 171 invokeId = this.tcapDialog.getNewInvokeId(); 172 invoke.setInvokeId(invokeId); 173 } catch (TCAPException e) { 174 throw new MAPException(e.getMessage(), e); 175 } 176 177 this.sendInvokeComponent(invoke); 178 179 return invokeId; 180 } 181 182 @Override 183 public void addMoForwardShortMessageResponse(long invokeId, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer) throws MAPException { 184 185 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext 186 || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3) 187 throw new MAPException("Bad application context name for addMoForwardShortMessageResponse: must be shortMsgMORelayContext_V3"); 188 189 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 190 191 resultLast.setInvokeId(invokeId); 192 193 // Operation Code 194 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 195 oc.setLocalOperationCode((long) MAPOperationCode.mo_forwardSM); 196 resultLast.setOperationCode(oc); 197 198 if (sm_RP_UI != null || extensionContainer != null) { 199 200 MoForwardShortMessageResponseIndicationImpl req = new MoForwardShortMessageResponseIndicationImpl(sm_RP_UI, extensionContainer); 201 AsnOutputStream aos = new AsnOutputStream(); 202 req.encodeData(aos); 203 204 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 205 p.setTagClass(req.getTagClass()); 206 p.setPrimitive(req.getIsPrimitive()); 207 p.setTag(req.getTag()); 208 p.setData(aos.toByteArray()); 209 resultLast.setParameter(p); 210 } 211 212 this.sendReturnResultLastComponent(resultLast); 213 } 214 215 @Override 216 public Long addMtForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend, 217 MAPExtensionContainer extensionContainer) throws MAPException { 218 return this.addMtForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend, extensionContainer); 219 } 220 221 @Override 222 public Long addMtForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend, 223 MAPExtensionContainer extensionContainer) throws MAPException { 224 225 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext 226 || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3) 227 throw new MAPException("Bad application context name for addMtForwardShortMessageRequest: must be shortMsgMTRelayContext_V3"); 228 229 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 230 if (customInvokeTimeout == _Timer_Default) 231 invoke.setTimeout(_Timer_ml); 232 else 233 invoke.setTimeout(customInvokeTimeout); 234 235 try { 236 // Operation Code 237 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 238 oc.setLocalOperationCode((long)MAPOperationCode.mt_forwardSM); 239 invoke.setOperationCode(oc); 240 241 MtForwardShortMessageRequestIndicationImpl req = new MtForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend, 242 extensionContainer); 243 AsnOutputStream aos = new AsnOutputStream(); 244 req.encodeData(aos); 245 246 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 247 p.setTagClass(req.getTagClass()); 248 p.setPrimitive(req.getIsPrimitive()); 249 p.setTag(req.getTag()); 250 p.setData(aos.toByteArray()); 251 invoke.setParameter(p); 252 253 Long invokeId = this.tcapDialog.getNewInvokeId(); 254 invoke.setInvokeId(invokeId); 255 256 this.sendInvokeComponent(invoke); 257 258 return invokeId; 259 260 } catch (TCAPException e) { 261 throw new MAPException(e.getMessage(), e); 262 } 263 } 264 265 @Override 266 public void addMtForwardShortMessageResponse(long invokeId, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer) throws MAPException { 267 268 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext 269 || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3) 270 throw new MAPException("Bad application context name for addMtForwardShortMessageResponse: must be shortMsgMTRelayContext_V3"); 271 272 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 273 274 resultLast.setInvokeId(invokeId); 275 276 // Operation Code 277 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 278 oc.setLocalOperationCode((long) MAPOperationCode.mt_forwardSM); 279 resultLast.setOperationCode(oc); 280 281 if (sm_RP_UI != null || extensionContainer != null) { 282 283 MtForwardShortMessageResponseIndicationImpl resp = new MtForwardShortMessageResponseIndicationImpl(sm_RP_UI, extensionContainer); 284 AsnOutputStream aos = new AsnOutputStream(); 285 resp.encodeData(aos); 286 287 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 288 p.setTagClass(resp.getTagClass()); 289 p.setPrimitive(resp.getIsPrimitive()); 290 p.setTag(resp.getTag()); 291 p.setData(aos.toByteArray()); 292 resultLast.setParameter(p); 293 } 294 295 this.sendReturnResultLastComponent(resultLast); 296 } 297 298 @Override 299 public Long addSendRoutingInfoForSMRequest(ISDNAddressString msisdn, boolean sm_RP_PRI, AddressString serviceCentreAddress, 300 MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, SM_RP_MTI sM_RP_MTI, SM_RP_SMEA sM_RP_SMEA) throws MAPException { 301 return this.addSendRoutingInfoForSMRequest(_Timer_Default, msisdn, sm_RP_PRI, serviceCentreAddress, extensionContainer, gprsSupportIndicator, 302 sM_RP_MTI, sM_RP_SMEA); 303 } 304 305 @Override 306 public Long addSendRoutingInfoForSMRequest(int customInvokeTimeout, ISDNAddressString msisdn, boolean sm_RP_PRI, AddressString serviceCentreAddress, 307 MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, SM_RP_MTI sM_RP_MTI, SM_RP_SMEA sM_RP_SMEA) throws MAPException { 308 309 MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion(); 310 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext 311 || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3)) 312 throw new MAPException("Bad application context name for addSendRoutingInfoForSMRequest: must be shortMsgGatewayContext_V1, V2 or V3"); 313 314 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 315 if (customInvokeTimeout == _Timer_Default) 316 invoke.setTimeout(_Timer_m); 317 else 318 invoke.setTimeout(customInvokeTimeout); 319 320 // Operation Code 321 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 322 oc.setLocalOperationCode((long)MAPOperationCode.sendRoutingInfoForSM); 323 invoke.setOperationCode(oc); 324 325 try { 326 SendRoutingInfoForSMRequestIndicationImpl req = new SendRoutingInfoForSMRequestIndicationImpl(msisdn, sm_RP_PRI, serviceCentreAddress, 327 extensionContainer, gprsSupportIndicator, sM_RP_MTI, sM_RP_SMEA); 328 AsnOutputStream aos = new AsnOutputStream(); 329 req.encodeData(aos); 330 331 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 332 p.setTagClass(req.getTagClass()); 333 p.setPrimitive(req.getIsPrimitive()); 334 p.setTag(req.getTag()); 335 p.setData(aos.toByteArray()); 336 invoke.setParameter(p); 337 338 Long invokeId = this.tcapDialog.getNewInvokeId(); 339 invoke.setInvokeId(invokeId); 340 341 this.sendInvokeComponent(invoke); 342 343 return invokeId; 344 345 } catch (TCAPException e) { 346 throw new MAPException(e.getMessage(), e); 347 } 348 } 349 350 @Override 351 public void addSendRoutingInfoForSMResponse(long invokeId, IMSI imsi, LocationInfoWithLMSI locationInfoWithLMSI, MAPExtensionContainer extensionContainer) 352 throws MAPException { 353 354 MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion(); 355 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext 356 || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3)) 357 throw new MAPException("Bad application context name for addSendRoutingInfoForSMResponse: must be shortMsgGatewayContext_V1, V2 or V3"); 358 359 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 360 361 resultLast.setInvokeId(invokeId); 362 363 // Operation Code 364 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 365 oc.setLocalOperationCode((long) MAPOperationCode.sendRoutingInfoForSM); 366 resultLast.setOperationCode(oc); 367 368 SendRoutingInfoForSMResponseIndicationImpl resp = new SendRoutingInfoForSMResponseIndicationImpl(imsi, locationInfoWithLMSI, extensionContainer); 369 AsnOutputStream aos = new AsnOutputStream(); 370 resp.encodeData(aos); 371 372 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 373 p.setTagClass(resp.getTagClass()); 374 p.setPrimitive(resp.getIsPrimitive()); 375 p.setTag(resp.getTag()); 376 p.setData(aos.toByteArray()); 377 resultLast.setParameter(p); 378 379 this.sendReturnResultLastComponent(resultLast); 380 } 381 382 @Override 383 public Long addReportSMDeliveryStatusRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress, SMDeliveryOutcome sMDeliveryOutcome, 384 Integer absentSubscriberDiagnosticSM, MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, boolean deliveryOutcomeIndicator, 385 SMDeliveryOutcome additionalSMDeliveryOutcome, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException { 386 return this.addReportSMDeliveryStatusRequest(_Timer_Default, msisdn, serviceCentreAddress, sMDeliveryOutcome, absentSubscriberDiagnosticSM, 387 extensionContainer, gprsSupportIndicator, deliveryOutcomeIndicator, additionalSMDeliveryOutcome, additionalAbsentSubscriberDiagnosticSM); 388 } 389 390 @Override 391 public Long addReportSMDeliveryStatusRequest(int customInvokeTimeout, ISDNAddressString msisdn, AddressString serviceCentreAddress, 392 SMDeliveryOutcome sMDeliveryOutcome, Integer absentSubscriberDiagnosticSM, MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, 393 boolean deliveryOutcomeIndicator, SMDeliveryOutcome additionalSMDeliveryOutcome, Integer additionalAbsentSubscriberDiagnosticSM) 394 throws MAPException { 395 396 MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion(); 397 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext 398 || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3)) 399 throw new MAPException("Bad application context name for addReportSMDeliveryStatusRequest: must be shortMsgGatewayContext_V1, V2 or V3"); 400 401 if (msisdn == null || serviceCentreAddress == null || sMDeliveryOutcome == null) 402 throw new MAPException("msisdn, serviceCentreAddress and sMDeliveryOutcome must not be null"); 403 404 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 405 if (customInvokeTimeout == _Timer_Default) 406 invoke.setTimeout(_Timer_s); 407 else 408 invoke.setTimeout(customInvokeTimeout); 409 410 try { 411 // Operation Code 412 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 413 oc.setLocalOperationCode((long)MAPOperationCode.reportSM_DeliveryStatus); 414 invoke.setOperationCode(oc); 415 416 ReportSMDeliveryStatusRequestIndicationImpl req = new ReportSMDeliveryStatusRequestIndicationImpl(this.getApplicationContext() 417 .getApplicationContextVersion().getVersion(), msisdn, serviceCentreAddress, sMDeliveryOutcome, absentSubscriberDiagnosticSM, 418 extensionContainer, gprsSupportIndicator, deliveryOutcomeIndicator, additionalSMDeliveryOutcome, additionalAbsentSubscriberDiagnosticSM); 419 AsnOutputStream aos = new AsnOutputStream(); 420 req.encodeData(aos); 421 422 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 423 p.setTagClass(req.getTagClass()); 424 p.setPrimitive(req.getIsPrimitive()); 425 p.setTag(req.getTag()); 426 p.setData(aos.toByteArray()); 427 invoke.setParameter(p); 428 429 Long invokeId = this.tcapDialog.getNewInvokeId(); 430 invoke.setInvokeId(invokeId); 431 432 this.sendInvokeComponent(invoke); 433 434 return invokeId; 435 436 } catch (TCAPException e) { 437 throw new MAPException(e.getMessage(), e); 438 } 439 } 440 441 @Override 442 public void addReportSMDeliveryStatusResponse(long invokeId, ISDNAddressString storedMSISDN, MAPExtensionContainer extensionContainer) throws MAPException { 443 444 MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion(); 445 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext 446 || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3)) 447 throw new MAPException("Bad application context name for addReportSMDeliveryStatusResponse: must be shortMsgGatewayContext_V1, V2 or V3"); 448 449 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 450 451 resultLast.setInvokeId(invokeId); 452 453 // Operation Code 454 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 455 oc.setLocalOperationCode((long) MAPOperationCode.reportSM_DeliveryStatus); 456 resultLast.setOperationCode(oc); 457 458 if (storedMSISDN != null || extensionContainer != null) { 459 460 ReportSMDeliveryStatusResponseIndicationImpl resp = new ReportSMDeliveryStatusResponseIndicationImpl(storedMSISDN, extensionContainer); 461 AsnOutputStream aos = new AsnOutputStream(); 462 resp.encodeData(aos); 463 464 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 465 p.setTagClass(resp.getTagClass()); 466 p.setPrimitive(resp.getIsPrimitive()); 467 p.setTag(resp.getTag()); 468 p.setData(aos.toByteArray()); 469 resultLast.setParameter(p); 470 } 471 472 this.sendReturnResultLastComponent(resultLast); 473 } 474 475 @Override 476 public Long addInformServiceCentreRequest(ISDNAddressString storedMSISDN, MWStatus mwStatus, MAPExtensionContainer extensionContainer, 477 Integer absentSubscriberDiagnosticSM, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException { 478 return this.addInformServiceCentreRequest(_Timer_Default, storedMSISDN, mwStatus, extensionContainer, absentSubscriberDiagnosticSM, 479 additionalAbsentSubscriberDiagnosticSM); 480 } 481 482 @Override 483 public Long addInformServiceCentreRequest(int customInvokeTimeout, ISDNAddressString storedMSISDN, MWStatus mwStatus, 484 MAPExtensionContainer extensionContainer, Integer absentSubscriberDiagnosticSM, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException { 485 486 MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion(); 487 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext 488 || (vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3)) 489 throw new MAPException("Bad application context name for addInformServiceCentreRequest: must be shortMsgGatewayContext_V2 or V3"); 490 491 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(InvokeClass.Class4); 492 if (customInvokeTimeout == _Timer_Default) 493 invoke.setTimeout(_Timer_s); 494 else 495 invoke.setTimeout(customInvokeTimeout); 496 497 try { 498 // Operation Code 499 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 500 oc.setLocalOperationCode((long)MAPOperationCode.informServiceCentre); 501 invoke.setOperationCode(oc); 502 503 InformServiceCentreRequestIndicationImpl req = new InformServiceCentreRequestIndicationImpl(storedMSISDN, mwStatus, extensionContainer, 504 absentSubscriberDiagnosticSM, additionalAbsentSubscriberDiagnosticSM); 505 AsnOutputStream aos = new AsnOutputStream(); 506 req.encodeData(aos); 507 508 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 509 p.setTagClass(req.getTagClass()); 510 p.setPrimitive(req.getIsPrimitive()); 511 p.setTag(req.getTag()); 512 p.setData(aos.toByteArray()); 513 invoke.setParameter(p); 514 515 Long invokeId = this.tcapDialog.getNewInvokeId(); 516 invoke.setInvokeId(invokeId); 517 518 this.sendInvokeComponent(invoke); 519 520 return invokeId; 521 522 } catch (TCAPException e) { 523 throw new MAPException(e.getMessage(), e); 524 } 525 } 526 527 @Override 528 public Long addAlertServiceCentreRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress) throws MAPException { 529 return this.addAlertServiceCentreRequest(_Timer_Default, msisdn, serviceCentreAddress); 530 } 531 532 @Override 533 public Long addAlertServiceCentreRequest(int customInvokeTimeout, ISDNAddressString msisdn, AddressString serviceCentreAddress) throws MAPException { 534 535 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgAlertContext 536 || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) 537 throw new MAPException("Bad application context name for addAlertServiceCentreRequest: must be shortMsgAlertContext_V1 or V2"); 538 539 Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(); 540 if (customInvokeTimeout == _Timer_Default) 541 invoke.setTimeout(_Timer_s); 542 else 543 invoke.setTimeout(customInvokeTimeout); 544 545 try { 546 // Operation Code 547 OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 548 if (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1) 549 oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentreWithoutResult); 550 else 551 oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentre); 552 invoke.setOperationCode(oc); 553 554 AlertServiceCentreRequestIndicationImpl req = new AlertServiceCentreRequestIndicationImpl(msisdn, serviceCentreAddress); 555 AsnOutputStream aos = new AsnOutputStream(); 556 req.encodeData(aos); 557 558 Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter(); 559 p.setTagClass(req.getTagClass()); 560 p.setPrimitive(req.getIsPrimitive()); 561 p.setTag(req.getTag()); 562 p.setData(aos.toByteArray()); 563 invoke.setParameter(p); 564 565 Long invokeId = this.tcapDialog.getNewInvokeId(); 566 invoke.setInvokeId(invokeId); 567 568 this.sendInvokeComponent(invoke); 569 570 return invokeId; 571 572 } catch (TCAPException e) { 573 throw new MAPException(e.getMessage(), e); 574 } 575 } 576 577 @Override 578 public void addAlertServiceCentreResponse(long invokeId) throws MAPException { 579 580 if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgAlertContext 581 || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)) 582 throw new MAPException("Bad application context name for addAlertServiceCentreResponse: must be shortMsgAlertContext_V2"); 583 584 ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest(); 585 586 resultLast.setInvokeId(invokeId); 587 588 // we need not Operation Code because no answer 589// OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode(); 590// oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentre); 591// resultLast.setOperationCode(oc); 592 593 this.sendReturnResultLastComponent(resultLast); 594 } 595} 596