/protocols/ss7/map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/sms/MAPDialogSmsImpl.java

http://mobicents.googlecode.com/ · 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. package org.mobicents.protocols.ss7.map.service.sms;
  23. import org.mobicents.protocols.asn.AsnOutputStream;
  24. import org.mobicents.protocols.ss7.map.MAPDialogImpl;
  25. import org.mobicents.protocols.ss7.map.MAPProviderImpl;
  26. import org.mobicents.protocols.ss7.map.api.MAPApplicationContext;
  27. import org.mobicents.protocols.ss7.map.api.MAPApplicationContextName;
  28. import org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion;
  29. import org.mobicents.protocols.ss7.map.api.MAPException;
  30. import org.mobicents.protocols.ss7.map.api.MAPOperationCode;
  31. import org.mobicents.protocols.ss7.map.api.primitives.AddressString;
  32. import org.mobicents.protocols.ss7.map.api.primitives.IMSI;
  33. import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
  34. import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer;
  35. import org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI;
  36. import org.mobicents.protocols.ss7.map.api.service.sms.MAPServiceSms;
  37. import org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms;
  38. import org.mobicents.protocols.ss7.map.api.service.sms.MWStatus;
  39. import org.mobicents.protocols.ss7.map.api.service.sms.SMDeliveryOutcome;
  40. import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA;
  41. import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_MTI;
  42. import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA;
  43. import org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_SMEA;
  44. import org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo;
  45. import org.mobicents.protocols.ss7.tcap.api.TCAPException;
  46. import org.mobicents.protocols.ss7.tcap.api.tc.component.InvokeClass;
  47. import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog;
  48. import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke;
  49. import org.mobicents.protocols.ss7.tcap.asn.comp.ReturnResultLast;
  50. import org.mobicents.protocols.ss7.tcap.asn.comp.OperationCode;
  51. import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter;
  52. /**
  53. *
  54. * @author sergey vetyutnev
  55. *
  56. */
  57. public class MAPDialogSmsImpl extends MAPDialogImpl implements MAPDialogSms {
  58. protected MAPDialogSmsImpl(MAPApplicationContext appCntx, Dialog tcapDialog, MAPProviderImpl mapProviderImpl, MAPServiceSms mapService,
  59. AddressString origReference, AddressString destReference) {
  60. super(appCntx, tcapDialog, mapProviderImpl, mapService, origReference, destReference);
  61. }
  62. @Override
  63. public Long addForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend) throws MAPException {
  64. return addForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend);
  65. }
  66. @Override
  67. public Long addForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend)
  68. throws MAPException {
  69. if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext && this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext)
  70. || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2))
  71. throw new MAPException("Bad application context name for addForwardShortMessageRequest: must be shortMsgMORelayContext_V1 or V2 or shortMsgMTRelayContext_V1 or V2");
  72. if (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2)
  73. moreMessagesToSend = false;
  74. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  75. if (customInvokeTimeout == _Timer_Default)
  76. invoke.setTimeout(_Timer_ml);
  77. else
  78. invoke.setTimeout(customInvokeTimeout);
  79. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  80. oc.setLocalOperationCode((long)MAPOperationCode.mo_forwardSM);
  81. invoke.setOperationCode(oc);
  82. ForwardShortMessageRequestIndicationImpl req = new ForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend);
  83. AsnOutputStream aos = new AsnOutputStream();
  84. req.encodeData(aos);
  85. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  86. p.setTagClass(req.getTagClass());
  87. p.setPrimitive(req.getIsPrimitive());
  88. p.setTag(req.getTag());
  89. p.setData(aos.toByteArray());
  90. invoke.setParameter(p);
  91. Long invokeId;
  92. try {
  93. invokeId = this.tcapDialog.getNewInvokeId();
  94. invoke.setInvokeId(invokeId);
  95. } catch (TCAPException e) {
  96. throw new MAPException(e.getMessage(), e);
  97. }
  98. this.sendInvokeComponent(invoke);
  99. return invokeId;
  100. }
  101. @Override
  102. public void addForwardShortMessageResponse(long invokeId) throws MAPException {
  103. if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext && this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext)
  104. || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2))
  105. throw new MAPException("Bad application context name for addForwardShortMessageResponse: must be shortMsgMORelayContext_V1 or V2 or shortMsgMTRelayContext_V1 or V2");
  106. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  107. resultLast.setInvokeId(invokeId);
  108. // we need not Operation Code because no answer
  109. this.sendReturnResultLastComponent(resultLast);
  110. }
  111. @Override
  112. public Long addMoForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer, IMSI imsi)
  113. throws MAPException {
  114. return addMoForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, extensionContainer, imsi);
  115. }
  116. @Override
  117. public Long addMoForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI,
  118. MAPExtensionContainer extensionContainer, IMSI imsi) throws MAPException {
  119. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext
  120. || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3)
  121. throw new MAPException("Bad application context name for addMoForwardShortMessageRequest: must be shortMsgMORelayContext_V3");
  122. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  123. if (customInvokeTimeout == _Timer_Default)
  124. invoke.setTimeout(_Timer_ml);
  125. else
  126. invoke.setTimeout(customInvokeTimeout);
  127. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  128. oc.setLocalOperationCode((long)MAPOperationCode.mo_forwardSM);
  129. invoke.setOperationCode(oc);
  130. MoForwardShortMessageRequestIndicationImpl req = new MoForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, extensionContainer, imsi);
  131. AsnOutputStream aos = new AsnOutputStream();
  132. req.encodeData(aos);
  133. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  134. p.setTagClass(req.getTagClass());
  135. p.setPrimitive(req.getIsPrimitive());
  136. p.setTag(req.getTag());
  137. p.setData(aos.toByteArray());
  138. invoke.setParameter(p);
  139. Long invokeId;
  140. try {
  141. invokeId = this.tcapDialog.getNewInvokeId();
  142. invoke.setInvokeId(invokeId);
  143. } catch (TCAPException e) {
  144. throw new MAPException(e.getMessage(), e);
  145. }
  146. this.sendInvokeComponent(invoke);
  147. return invokeId;
  148. }
  149. @Override
  150. public void addMoForwardShortMessageResponse(long invokeId, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer) throws MAPException {
  151. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMORelayContext
  152. || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3)
  153. throw new MAPException("Bad application context name for addMoForwardShortMessageResponse: must be shortMsgMORelayContext_V3");
  154. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  155. resultLast.setInvokeId(invokeId);
  156. // Operation Code
  157. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  158. oc.setLocalOperationCode((long) MAPOperationCode.mo_forwardSM);
  159. resultLast.setOperationCode(oc);
  160. if (sm_RP_UI != null || extensionContainer != null) {
  161. MoForwardShortMessageResponseIndicationImpl req = new MoForwardShortMessageResponseIndicationImpl(sm_RP_UI, extensionContainer);
  162. AsnOutputStream aos = new AsnOutputStream();
  163. req.encodeData(aos);
  164. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  165. p.setTagClass(req.getTagClass());
  166. p.setPrimitive(req.getIsPrimitive());
  167. p.setTag(req.getTag());
  168. p.setData(aos.toByteArray());
  169. resultLast.setParameter(p);
  170. }
  171. this.sendReturnResultLastComponent(resultLast);
  172. }
  173. @Override
  174. public Long addMtForwardShortMessageRequest(SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend,
  175. MAPExtensionContainer extensionContainer) throws MAPException {
  176. return this.addMtForwardShortMessageRequest(_Timer_Default, sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend, extensionContainer);
  177. }
  178. @Override
  179. public Long addMtForwardShortMessageRequest(int customInvokeTimeout, SM_RP_DA sm_RP_DA, SM_RP_OA sm_RP_OA, SmsSignalInfo sm_RP_UI, boolean moreMessagesToSend,
  180. MAPExtensionContainer extensionContainer) throws MAPException {
  181. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext
  182. || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3)
  183. throw new MAPException("Bad application context name for addMtForwardShortMessageRequest: must be shortMsgMTRelayContext_V3");
  184. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  185. if (customInvokeTimeout == _Timer_Default)
  186. invoke.setTimeout(_Timer_ml);
  187. else
  188. invoke.setTimeout(customInvokeTimeout);
  189. try {
  190. // Operation Code
  191. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  192. oc.setLocalOperationCode((long)MAPOperationCode.mt_forwardSM);
  193. invoke.setOperationCode(oc);
  194. MtForwardShortMessageRequestIndicationImpl req = new MtForwardShortMessageRequestIndicationImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, moreMessagesToSend,
  195. extensionContainer);
  196. AsnOutputStream aos = new AsnOutputStream();
  197. req.encodeData(aos);
  198. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  199. p.setTagClass(req.getTagClass());
  200. p.setPrimitive(req.getIsPrimitive());
  201. p.setTag(req.getTag());
  202. p.setData(aos.toByteArray());
  203. invoke.setParameter(p);
  204. Long invokeId = this.tcapDialog.getNewInvokeId();
  205. invoke.setInvokeId(invokeId);
  206. this.sendInvokeComponent(invoke);
  207. return invokeId;
  208. } catch (TCAPException e) {
  209. throw new MAPException(e.getMessage(), e);
  210. }
  211. }
  212. @Override
  213. public void addMtForwardShortMessageResponse(long invokeId, SmsSignalInfo sm_RP_UI, MAPExtensionContainer extensionContainer) throws MAPException {
  214. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgMTRelayContext
  215. || this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3)
  216. throw new MAPException("Bad application context name for addMtForwardShortMessageResponse: must be shortMsgMTRelayContext_V3");
  217. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  218. resultLast.setInvokeId(invokeId);
  219. // Operation Code
  220. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  221. oc.setLocalOperationCode((long) MAPOperationCode.mt_forwardSM);
  222. resultLast.setOperationCode(oc);
  223. if (sm_RP_UI != null || extensionContainer != null) {
  224. MtForwardShortMessageResponseIndicationImpl resp = new MtForwardShortMessageResponseIndicationImpl(sm_RP_UI, extensionContainer);
  225. AsnOutputStream aos = new AsnOutputStream();
  226. resp.encodeData(aos);
  227. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  228. p.setTagClass(resp.getTagClass());
  229. p.setPrimitive(resp.getIsPrimitive());
  230. p.setTag(resp.getTag());
  231. p.setData(aos.toByteArray());
  232. resultLast.setParameter(p);
  233. }
  234. this.sendReturnResultLastComponent(resultLast);
  235. }
  236. @Override
  237. public Long addSendRoutingInfoForSMRequest(ISDNAddressString msisdn, boolean sm_RP_PRI, AddressString serviceCentreAddress,
  238. MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, SM_RP_MTI sM_RP_MTI, SM_RP_SMEA sM_RP_SMEA) throws MAPException {
  239. return this.addSendRoutingInfoForSMRequest(_Timer_Default, msisdn, sm_RP_PRI, serviceCentreAddress, extensionContainer, gprsSupportIndicator,
  240. sM_RP_MTI, sM_RP_SMEA);
  241. }
  242. @Override
  243. public Long addSendRoutingInfoForSMRequest(int customInvokeTimeout, ISDNAddressString msisdn, boolean sm_RP_PRI, AddressString serviceCentreAddress,
  244. MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, SM_RP_MTI sM_RP_MTI, SM_RP_SMEA sM_RP_SMEA) throws MAPException {
  245. MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion();
  246. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext
  247. || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3))
  248. throw new MAPException("Bad application context name for addSendRoutingInfoForSMRequest: must be shortMsgGatewayContext_V1, V2 or V3");
  249. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  250. if (customInvokeTimeout == _Timer_Default)
  251. invoke.setTimeout(_Timer_m);
  252. else
  253. invoke.setTimeout(customInvokeTimeout);
  254. // Operation Code
  255. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  256. oc.setLocalOperationCode((long)MAPOperationCode.sendRoutingInfoForSM);
  257. invoke.setOperationCode(oc);
  258. try {
  259. SendRoutingInfoForSMRequestIndicationImpl req = new SendRoutingInfoForSMRequestIndicationImpl(msisdn, sm_RP_PRI, serviceCentreAddress,
  260. extensionContainer, gprsSupportIndicator, sM_RP_MTI, sM_RP_SMEA);
  261. AsnOutputStream aos = new AsnOutputStream();
  262. req.encodeData(aos);
  263. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  264. p.setTagClass(req.getTagClass());
  265. p.setPrimitive(req.getIsPrimitive());
  266. p.setTag(req.getTag());
  267. p.setData(aos.toByteArray());
  268. invoke.setParameter(p);
  269. Long invokeId = this.tcapDialog.getNewInvokeId();
  270. invoke.setInvokeId(invokeId);
  271. this.sendInvokeComponent(invoke);
  272. return invokeId;
  273. } catch (TCAPException e) {
  274. throw new MAPException(e.getMessage(), e);
  275. }
  276. }
  277. @Override
  278. public void addSendRoutingInfoForSMResponse(long invokeId, IMSI imsi, LocationInfoWithLMSI locationInfoWithLMSI, MAPExtensionContainer extensionContainer)
  279. throws MAPException {
  280. MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion();
  281. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext
  282. || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3))
  283. throw new MAPException("Bad application context name for addSendRoutingInfoForSMResponse: must be shortMsgGatewayContext_V1, V2 or V3");
  284. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  285. resultLast.setInvokeId(invokeId);
  286. // Operation Code
  287. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  288. oc.setLocalOperationCode((long) MAPOperationCode.sendRoutingInfoForSM);
  289. resultLast.setOperationCode(oc);
  290. SendRoutingInfoForSMResponseIndicationImpl resp = new SendRoutingInfoForSMResponseIndicationImpl(imsi, locationInfoWithLMSI, extensionContainer);
  291. AsnOutputStream aos = new AsnOutputStream();
  292. resp.encodeData(aos);
  293. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  294. p.setTagClass(resp.getTagClass());
  295. p.setPrimitive(resp.getIsPrimitive());
  296. p.setTag(resp.getTag());
  297. p.setData(aos.toByteArray());
  298. resultLast.setParameter(p);
  299. this.sendReturnResultLastComponent(resultLast);
  300. }
  301. @Override
  302. public Long addReportSMDeliveryStatusRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress, SMDeliveryOutcome sMDeliveryOutcome,
  303. Integer absentSubscriberDiagnosticSM, MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, boolean deliveryOutcomeIndicator,
  304. SMDeliveryOutcome additionalSMDeliveryOutcome, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException {
  305. return this.addReportSMDeliveryStatusRequest(_Timer_Default, msisdn, serviceCentreAddress, sMDeliveryOutcome, absentSubscriberDiagnosticSM,
  306. extensionContainer, gprsSupportIndicator, deliveryOutcomeIndicator, additionalSMDeliveryOutcome, additionalAbsentSubscriberDiagnosticSM);
  307. }
  308. @Override
  309. public Long addReportSMDeliveryStatusRequest(int customInvokeTimeout, ISDNAddressString msisdn, AddressString serviceCentreAddress,
  310. SMDeliveryOutcome sMDeliveryOutcome, Integer absentSubscriberDiagnosticSM, MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator,
  311. boolean deliveryOutcomeIndicator, SMDeliveryOutcome additionalSMDeliveryOutcome, Integer additionalAbsentSubscriberDiagnosticSM)
  312. throws MAPException {
  313. MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion();
  314. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext
  315. || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3))
  316. throw new MAPException("Bad application context name for addReportSMDeliveryStatusRequest: must be shortMsgGatewayContext_V1, V2 or V3");
  317. if (msisdn == null || serviceCentreAddress == null || sMDeliveryOutcome == null)
  318. throw new MAPException("msisdn, serviceCentreAddress and sMDeliveryOutcome must not be null");
  319. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  320. if (customInvokeTimeout == _Timer_Default)
  321. invoke.setTimeout(_Timer_s);
  322. else
  323. invoke.setTimeout(customInvokeTimeout);
  324. try {
  325. // Operation Code
  326. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  327. oc.setLocalOperationCode((long)MAPOperationCode.reportSM_DeliveryStatus);
  328. invoke.setOperationCode(oc);
  329. ReportSMDeliveryStatusRequestIndicationImpl req = new ReportSMDeliveryStatusRequestIndicationImpl(this.getApplicationContext()
  330. .getApplicationContextVersion().getVersion(), msisdn, serviceCentreAddress, sMDeliveryOutcome, absentSubscriberDiagnosticSM,
  331. extensionContainer, gprsSupportIndicator, deliveryOutcomeIndicator, additionalSMDeliveryOutcome, additionalAbsentSubscriberDiagnosticSM);
  332. AsnOutputStream aos = new AsnOutputStream();
  333. req.encodeData(aos);
  334. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  335. p.setTagClass(req.getTagClass());
  336. p.setPrimitive(req.getIsPrimitive());
  337. p.setTag(req.getTag());
  338. p.setData(aos.toByteArray());
  339. invoke.setParameter(p);
  340. Long invokeId = this.tcapDialog.getNewInvokeId();
  341. invoke.setInvokeId(invokeId);
  342. this.sendInvokeComponent(invoke);
  343. return invokeId;
  344. } catch (TCAPException e) {
  345. throw new MAPException(e.getMessage(), e);
  346. }
  347. }
  348. @Override
  349. public void addReportSMDeliveryStatusResponse(long invokeId, ISDNAddressString storedMSISDN, MAPExtensionContainer extensionContainer) throws MAPException {
  350. MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion();
  351. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext
  352. || (vers != MAPApplicationContextVersion.version1 && vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3))
  353. throw new MAPException("Bad application context name for addReportSMDeliveryStatusResponse: must be shortMsgGatewayContext_V1, V2 or V3");
  354. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  355. resultLast.setInvokeId(invokeId);
  356. // Operation Code
  357. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  358. oc.setLocalOperationCode((long) MAPOperationCode.reportSM_DeliveryStatus);
  359. resultLast.setOperationCode(oc);
  360. if (storedMSISDN != null || extensionContainer != null) {
  361. ReportSMDeliveryStatusResponseIndicationImpl resp = new ReportSMDeliveryStatusResponseIndicationImpl(storedMSISDN, extensionContainer);
  362. AsnOutputStream aos = new AsnOutputStream();
  363. resp.encodeData(aos);
  364. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  365. p.setTagClass(resp.getTagClass());
  366. p.setPrimitive(resp.getIsPrimitive());
  367. p.setTag(resp.getTag());
  368. p.setData(aos.toByteArray());
  369. resultLast.setParameter(p);
  370. }
  371. this.sendReturnResultLastComponent(resultLast);
  372. }
  373. @Override
  374. public Long addInformServiceCentreRequest(ISDNAddressString storedMSISDN, MWStatus mwStatus, MAPExtensionContainer extensionContainer,
  375. Integer absentSubscriberDiagnosticSM, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException {
  376. return this.addInformServiceCentreRequest(_Timer_Default, storedMSISDN, mwStatus, extensionContainer, absentSubscriberDiagnosticSM,
  377. additionalAbsentSubscriberDiagnosticSM);
  378. }
  379. @Override
  380. public Long addInformServiceCentreRequest(int customInvokeTimeout, ISDNAddressString storedMSISDN, MWStatus mwStatus,
  381. MAPExtensionContainer extensionContainer, Integer absentSubscriberDiagnosticSM, Integer additionalAbsentSubscriberDiagnosticSM) throws MAPException {
  382. MAPApplicationContextVersion vers = this.appCntx.getApplicationContextVersion();
  383. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgGatewayContext
  384. || (vers != MAPApplicationContextVersion.version2 && vers != MAPApplicationContextVersion.version3))
  385. throw new MAPException("Bad application context name for addInformServiceCentreRequest: must be shortMsgGatewayContext_V2 or V3");
  386. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest(InvokeClass.Class4);
  387. if (customInvokeTimeout == _Timer_Default)
  388. invoke.setTimeout(_Timer_s);
  389. else
  390. invoke.setTimeout(customInvokeTimeout);
  391. try {
  392. // Operation Code
  393. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  394. oc.setLocalOperationCode((long)MAPOperationCode.informServiceCentre);
  395. invoke.setOperationCode(oc);
  396. InformServiceCentreRequestIndicationImpl req = new InformServiceCentreRequestIndicationImpl(storedMSISDN, mwStatus, extensionContainer,
  397. absentSubscriberDiagnosticSM, additionalAbsentSubscriberDiagnosticSM);
  398. AsnOutputStream aos = new AsnOutputStream();
  399. req.encodeData(aos);
  400. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  401. p.setTagClass(req.getTagClass());
  402. p.setPrimitive(req.getIsPrimitive());
  403. p.setTag(req.getTag());
  404. p.setData(aos.toByteArray());
  405. invoke.setParameter(p);
  406. Long invokeId = this.tcapDialog.getNewInvokeId();
  407. invoke.setInvokeId(invokeId);
  408. this.sendInvokeComponent(invoke);
  409. return invokeId;
  410. } catch (TCAPException e) {
  411. throw new MAPException(e.getMessage(), e);
  412. }
  413. }
  414. @Override
  415. public Long addAlertServiceCentreRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress) throws MAPException {
  416. return this.addAlertServiceCentreRequest(_Timer_Default, msisdn, serviceCentreAddress);
  417. }
  418. @Override
  419. public Long addAlertServiceCentreRequest(int customInvokeTimeout, ISDNAddressString msisdn, AddressString serviceCentreAddress) throws MAPException {
  420. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgAlertContext
  421. || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version1 && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2))
  422. throw new MAPException("Bad application context name for addAlertServiceCentreRequest: must be shortMsgAlertContext_V1 or V2");
  423. Invoke invoke = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCInvokeRequest();
  424. if (customInvokeTimeout == _Timer_Default)
  425. invoke.setTimeout(_Timer_s);
  426. else
  427. invoke.setTimeout(customInvokeTimeout);
  428. try {
  429. // Operation Code
  430. OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  431. if (this.appCntx.getApplicationContextVersion() == MAPApplicationContextVersion.version1)
  432. oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentreWithoutResult);
  433. else
  434. oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentre);
  435. invoke.setOperationCode(oc);
  436. AlertServiceCentreRequestIndicationImpl req = new AlertServiceCentreRequestIndicationImpl(msisdn, serviceCentreAddress);
  437. AsnOutputStream aos = new AsnOutputStream();
  438. req.encodeData(aos);
  439. Parameter p = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createParameter();
  440. p.setTagClass(req.getTagClass());
  441. p.setPrimitive(req.getIsPrimitive());
  442. p.setTag(req.getTag());
  443. p.setData(aos.toByteArray());
  444. invoke.setParameter(p);
  445. Long invokeId = this.tcapDialog.getNewInvokeId();
  446. invoke.setInvokeId(invokeId);
  447. this.sendInvokeComponent(invoke);
  448. return invokeId;
  449. } catch (TCAPException e) {
  450. throw new MAPException(e.getMessage(), e);
  451. }
  452. }
  453. @Override
  454. public void addAlertServiceCentreResponse(long invokeId) throws MAPException {
  455. if (this.appCntx.getApplicationContextName() != MAPApplicationContextName.shortMsgAlertContext
  456. || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2))
  457. throw new MAPException("Bad application context name for addAlertServiceCentreResponse: must be shortMsgAlertContext_V2");
  458. ReturnResultLast resultLast = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createTCResultLastRequest();
  459. resultLast.setInvokeId(invokeId);
  460. // we need not Operation Code because no answer
  461. // OperationCode oc = this.mapProviderImpl.getTCAPProvider().getComponentPrimitiveFactory().createOperationCode();
  462. // oc.setLocalOperationCode((long) MAPOperationCode.alertServiceCentre);
  463. // resultLast.setOperationCode(oc);
  464. this.sendReturnResultLastComponent(resultLast);
  465. }
  466. }