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

http://mobicents.googlecode.com/ · Java · 625 lines · 470 code · 117 blank · 38 comment · 155 complexity · 7b5da4f5a470a2d610fa9d9112d3c57b 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.apache.log4j.Logger;
  24. import org.mobicents.protocols.asn.Tag;
  25. import org.mobicents.protocols.ss7.map.MAPDialogImpl;
  26. import org.mobicents.protocols.ss7.map.MAPProviderImpl;
  27. import org.mobicents.protocols.ss7.map.MAPServiceBaseImpl;
  28. import org.mobicents.protocols.ss7.map.api.MAPApplicationContext;
  29. import org.mobicents.protocols.ss7.map.api.MAPApplicationContextName;
  30. import org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion;
  31. import org.mobicents.protocols.ss7.map.api.MAPDialog;
  32. import org.mobicents.protocols.ss7.map.api.MAPException;
  33. import org.mobicents.protocols.ss7.map.api.MAPOperationCode;
  34. import org.mobicents.protocols.ss7.map.api.MAPParsingComponentException;
  35. import org.mobicents.protocols.ss7.map.api.MAPParsingComponentExceptionReason;
  36. import org.mobicents.protocols.ss7.map.api.MAPServiceListener;
  37. import org.mobicents.protocols.ss7.map.api.dialog.ServingCheckData;
  38. import org.mobicents.protocols.ss7.map.api.dialog.ServingCheckResult;
  39. import org.mobicents.protocols.ss7.map.api.primitives.AddressString;
  40. import org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms;
  41. import org.mobicents.protocols.ss7.map.api.service.sms.MAPServiceSms;
  42. import org.mobicents.protocols.ss7.map.api.service.sms.MAPServiceSmsListener;
  43. import org.mobicents.protocols.ss7.map.dialog.ServingCheckDataImpl;
  44. import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
  45. import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog;
  46. import org.mobicents.protocols.ss7.tcap.asn.comp.ComponentType;
  47. import org.mobicents.protocols.ss7.tcap.asn.comp.Invoke;
  48. import org.mobicents.protocols.ss7.tcap.asn.comp.OperationCode;
  49. import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter;
  50. import org.mobicents.protocols.ss7.tcap.asn.ApplicationContextName;
  51. import org.mobicents.protocols.ss7.tcap.asn.TcapFactory;
  52. import org.mobicents.protocols.asn.AsnInputStream;
  53. /**
  54. *
  55. * @author sergey vetyutnev
  56. *
  57. */
  58. public class MAPServiceSmsImpl extends MAPServiceBaseImpl implements MAPServiceSms {
  59. protected Logger loger = Logger.getLogger(MAPServiceSmsImpl.class);
  60. public MAPServiceSmsImpl(MAPProviderImpl mapProviderImpl) {
  61. super(mapProviderImpl);
  62. }
  63. /*
  64. * Creating a new outgoing MAP SMS dialog and adding it to the
  65. * MAPProvider.dialog collection
  66. *
  67. */
  68. @Override
  69. public MAPDialogSms createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
  70. AddressString destReference) throws MAPException {
  71. // We cannot create a dialog if the service is not activated
  72. if (!this.isActivated())
  73. throw new MAPException(
  74. "Cannot create MAPDialogSms because MAPServiceSms is not activated");
  75. Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress);
  76. MAPDialogSmsImpl dialog = new MAPDialogSmsImpl(appCntx, tcapDialog, this.mapProviderImpl,
  77. this, origReference, destReference);
  78. this.putMAPDialogIntoCollection(dialog);
  79. return dialog;
  80. }
  81. @Override
  82. protected MAPDialogImpl createNewDialogIncoming(MAPApplicationContext appCntx, Dialog tcapDialog) {
  83. return new MAPDialogSmsImpl(appCntx, tcapDialog, this.mapProviderImpl, this, null, null);
  84. }
  85. @Override
  86. public void addMAPServiceListener(MAPServiceSmsListener mapServiceListener) {
  87. super.addMAPServiceListener(mapServiceListener);
  88. }
  89. @Override
  90. public void removeMAPServiceListener(MAPServiceSmsListener mapServiceListener) {
  91. super.removeMAPServiceListener(mapServiceListener);
  92. }
  93. @Override
  94. public ServingCheckData isServingService(MAPApplicationContext dialogApplicationContext) {
  95. MAPApplicationContextName ctx = dialogApplicationContext.getApplicationContextName();
  96. int vers = dialogApplicationContext.getApplicationContextVersion().getVersion();
  97. switch (ctx) {
  98. case shortMsgAlertContext:
  99. if (vers >= 1 && vers <= 2) {
  100. return new ServingCheckDataImpl(ServingCheckResult.AC_Serving);
  101. } else if (vers > 2) {
  102. long[] altOid = dialogApplicationContext.getOID();
  103. altOid[7] = 2;
  104. ApplicationContextName alt = TcapFactory.createApplicationContextName(altOid);
  105. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect, alt);
  106. } else {
  107. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect);
  108. }
  109. case shortMsgMORelayContext:
  110. case shortMsgGatewayContext:
  111. if (vers >= 1 && vers <= 3) {
  112. return new ServingCheckDataImpl(ServingCheckResult.AC_Serving);
  113. } else if (vers > 3) {
  114. long[] altOid = dialogApplicationContext.getOID();
  115. altOid[7] = 2;
  116. ApplicationContextName alt = TcapFactory.createApplicationContextName(altOid);
  117. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect, alt);
  118. } else {
  119. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect);
  120. }
  121. case shortMsgMTRelayContext:
  122. if (vers >= 2 && vers <= 3) {
  123. return new ServingCheckDataImpl(ServingCheckResult.AC_Serving);
  124. } else if (vers > 3) {
  125. long[] altOid = dialogApplicationContext.getOID();
  126. altOid[7] = 2;
  127. ApplicationContextName alt = TcapFactory.createApplicationContextName(altOid);
  128. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect, alt);
  129. } else {
  130. return new ServingCheckDataImpl(ServingCheckResult.AC_VersionIncorrect);
  131. }
  132. }
  133. return new ServingCheckDataImpl(ServingCheckResult.AC_NotServing);
  134. }
  135. @Override
  136. public MAPApplicationContext getMAPv1ApplicationContext(int operationCode, Invoke invoke) {
  137. switch (operationCode) {
  138. case MAPOperationCode.mo_forwardSM:
  139. return MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgMORelayContext, MAPApplicationContextVersion.version1);
  140. case MAPOperationCode.alertServiceCentreWithoutResult:
  141. return MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgAlertContext, MAPApplicationContextVersion.version1);
  142. case MAPOperationCode.sendRoutingInfoForSM:
  143. return MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgGatewayContext, MAPApplicationContextVersion.version1);
  144. case MAPOperationCode.reportSM_DeliveryStatus:
  145. return MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgGatewayContext, MAPApplicationContextVersion.version1);
  146. }
  147. return null;
  148. }
  149. @Override
  150. public void processComponent(ComponentType compType, OperationCode oc, Parameter parameter, MAPDialog mapDialog, Long invokeId, Long linkedId)
  151. throws MAPParsingComponentException {
  152. // if an application-context-name different from version 1 is
  153. // received in a syntactically correct TC-
  154. // BEGIN indication primitive but is not acceptable from a load
  155. // control point of view, the MAP PM
  156. // shall ignore this dialogue request. The MAP-user is not informed.
  157. if (compType == ComponentType.Invoke && this.mapProviderImpl.isCongested()) {
  158. // we agree all sms services when congestion
  159. }
  160. MAPDialogSmsImpl mapDialogSmsImpl = (MAPDialogSmsImpl) mapDialog;
  161. Long ocValue = oc.getLocalOperationCode();
  162. if (ocValue == null)
  163. new MAPParsingComponentException("", MAPParsingComponentExceptionReason.UnrecognizedOperation);
  164. MAPApplicationContextName acn = mapDialog.getApplicationContext().getApplicationContextName();
  165. int vers = mapDialog.getApplicationContext().getApplicationContextVersion().getVersion();
  166. int ocValueInt = (int) (long)ocValue;
  167. switch (ocValueInt) {
  168. case MAPOperationCode.mo_forwardSM:
  169. if (acn == MAPApplicationContextName.shortMsgMORelayContext || acn == MAPApplicationContextName.shortMsgMTRelayContext && vers == 2) {
  170. if (vers >= 3) {
  171. if (compType == ComponentType.Invoke)
  172. this.moForwardShortMessageRequest(parameter, mapDialogSmsImpl, invokeId);
  173. else
  174. this.moForwardShortMessageResponse(parameter, mapDialogSmsImpl, invokeId);
  175. } else {
  176. if (compType == ComponentType.Invoke)
  177. this.forwardShortMessageRequest(parameter, mapDialogSmsImpl, invokeId);
  178. else
  179. this.forwardShortMessageResponse(parameter, mapDialogSmsImpl, invokeId);
  180. }
  181. }
  182. break;
  183. case MAPOperationCode.mt_forwardSM:
  184. if (acn == MAPApplicationContextName.shortMsgMTRelayContext && vers >= 3) {
  185. if (compType == ComponentType.Invoke)
  186. this.mtForwardShortMessageRequest(parameter, mapDialogSmsImpl, invokeId);
  187. else
  188. this.mtForwardShortMessageResponse(parameter, mapDialogSmsImpl, invokeId);
  189. }
  190. break;
  191. case MAPOperationCode.sendRoutingInfoForSM:
  192. if (acn == MAPApplicationContextName.shortMsgGatewayContext ) {
  193. if (compType == ComponentType.Invoke)
  194. this.sendRoutingInfoForSMRequest(parameter, mapDialogSmsImpl, invokeId);
  195. else
  196. this.sendRoutingInfoForSMResponse(parameter, mapDialogSmsImpl, invokeId);
  197. }
  198. break;
  199. case MAPOperationCode.reportSM_DeliveryStatus:
  200. if (acn == MAPApplicationContextName.shortMsgGatewayContext) {
  201. if (compType == ComponentType.Invoke)
  202. this.reportSMDeliveryStatusRequest(parameter, mapDialogSmsImpl, invokeId);
  203. else
  204. this.reportSMDeliveryStatusResponse(parameter, mapDialogSmsImpl, invokeId);
  205. }
  206. break;
  207. case MAPOperationCode.informServiceCentre:
  208. if (acn == MAPApplicationContextName.shortMsgGatewayContext && vers >= 2) {
  209. if (compType == ComponentType.Invoke)
  210. this.informServiceCentreRequest(parameter, mapDialogSmsImpl, invokeId);
  211. }
  212. break;
  213. case MAPOperationCode.alertServiceCentre:
  214. if (acn == MAPApplicationContextName.shortMsgAlertContext && vers >= 2) {
  215. if (compType == ComponentType.Invoke)
  216. this.alertServiceCentreRequest(parameter, mapDialogSmsImpl, invokeId, ocValueInt);
  217. else
  218. this.alertServiceCentreResponse(parameter, mapDialogSmsImpl, invokeId);
  219. }
  220. break;
  221. case MAPOperationCode.alertServiceCentreWithoutResult:
  222. if (acn == MAPApplicationContextName.shortMsgAlertContext && vers == 1) {
  223. if (compType == ComponentType.Invoke)
  224. this.alertServiceCentreRequest(parameter, mapDialogSmsImpl, invokeId, ocValueInt);
  225. }
  226. break;
  227. default:
  228. new MAPParsingComponentException("", MAPParsingComponentExceptionReason.UnrecognizedOperation);
  229. }
  230. }
  231. private void forwardShortMessageRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  232. if (parameter == null)
  233. throw new MAPParsingComponentException("Error while decoding forwardShortMessageRequest: Parameter is mandatory but not found",
  234. MAPParsingComponentExceptionReason.MistypedParameter);
  235. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  236. throw new MAPParsingComponentException(
  237. "Error while decoding moForwardShortMessageRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  238. MAPParsingComponentExceptionReason.MistypedParameter);
  239. byte[] buf = parameter.getData();
  240. AsnInputStream ais = new AsnInputStream(buf);
  241. ForwardShortMessageRequestIndicationImpl ind = new ForwardShortMessageRequestIndicationImpl();
  242. ind.decodeData(ais, buf.length);
  243. ind.setInvokeId(invokeId);
  244. ind.setMAPDialog(mapDialogImpl);
  245. for (MAPServiceListener serLis : this.serviceListeners) {
  246. try {
  247. serLis.onMAPMessage(ind);
  248. ((MAPServiceSmsListener) serLis).onForwardShortMessageIndication(ind);
  249. } catch (Exception e) {
  250. loger.error("Error processing forwardShortMessageRequest: " + e.getMessage(), e);
  251. }
  252. }
  253. }
  254. private void forwardShortMessageResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  255. ForwardShortMessageResponseIndicationImpl ind = new ForwardShortMessageResponseIndicationImpl();
  256. ind.setInvokeId(invokeId);
  257. ind.setMAPDialog(mapDialogImpl);
  258. for (MAPServiceListener serLis : this.serviceListeners) {
  259. try {
  260. serLis.onMAPMessage(ind);
  261. ((MAPServiceSmsListener) serLis).onForwardShortMessageRespIndication(ind);
  262. } catch (Exception e) {
  263. loger.error("Error processing forwardShortMessageResponse: " + e.getMessage(), e);
  264. }
  265. }
  266. }
  267. private void moForwardShortMessageRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  268. if (parameter == null)
  269. throw new MAPParsingComponentException("Error while decoding moForwardShortMessageRequest: Parameter is mandatory but not found",
  270. MAPParsingComponentExceptionReason.MistypedParameter);
  271. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  272. throw new MAPParsingComponentException(
  273. "Error while decoding moForwardShortMessageRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  274. MAPParsingComponentExceptionReason.MistypedParameter);
  275. byte[] buf = parameter.getData();
  276. AsnInputStream ais = new AsnInputStream(buf);
  277. MoForwardShortMessageRequestIndicationImpl ind = new MoForwardShortMessageRequestIndicationImpl();
  278. ind.decodeData(ais, buf.length);
  279. ind.setInvokeId(invokeId);
  280. ind.setMAPDialog(mapDialogImpl);
  281. for (MAPServiceListener serLis : this.serviceListeners) {
  282. try {
  283. serLis.onMAPMessage(ind);
  284. ((MAPServiceSmsListener) serLis).onMoForwardShortMessageIndication(ind);
  285. } catch (Exception e) {
  286. loger.error("Error processing onMoForwardShortMessageIndication: " + e.getMessage(), e);
  287. }
  288. }
  289. }
  290. private void moForwardShortMessageResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  291. MoForwardShortMessageResponseIndicationImpl ind = new MoForwardShortMessageResponseIndicationImpl();
  292. if (parameter != null) {
  293. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  294. throw new MAPParsingComponentException(
  295. "Error while decoding moForwardShortMessageResponse: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  296. MAPParsingComponentExceptionReason.MistypedParameter);
  297. byte[] buf = parameter.getData();
  298. AsnInputStream ais = new AsnInputStream(buf);
  299. ind.decodeData(ais, buf.length);
  300. }
  301. ind.setInvokeId(invokeId);
  302. ind.setMAPDialog(mapDialogImpl);
  303. for (MAPServiceListener serLis : this.serviceListeners) {
  304. try {
  305. serLis.onMAPMessage(ind);
  306. ((MAPServiceSmsListener) serLis).onMoForwardShortMessageRespIndication(ind);
  307. } catch (Exception e) {
  308. loger.error("Error processing onMoForwardShortMessageRespIndication: " + e.getMessage(), e);
  309. }
  310. }
  311. }
  312. private void mtForwardShortMessageRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  313. if (parameter == null)
  314. throw new MAPParsingComponentException("Error while decoding mtForwardShortMessageRequest: Parameter is mandatory but not found",
  315. MAPParsingComponentExceptionReason.MistypedParameter);
  316. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  317. throw new MAPParsingComponentException(
  318. "Error while decoding mtForwardShortMessageRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  319. MAPParsingComponentExceptionReason.MistypedParameter);
  320. byte[] buf = parameter.getData();
  321. AsnInputStream ais = new AsnInputStream(buf);
  322. MtForwardShortMessageRequestIndicationImpl ind = new MtForwardShortMessageRequestIndicationImpl();
  323. ind.decodeData(ais, buf.length);
  324. ind.setInvokeId(invokeId);
  325. ind.setMAPDialog(mapDialogImpl);
  326. for (MAPServiceListener serLis : this.serviceListeners) {
  327. try {
  328. serLis.onMAPMessage(ind);
  329. ((MAPServiceSmsListener) serLis).onMtForwardShortMessageIndication(ind);
  330. } catch (Exception e) {
  331. loger.error("Error processing onMtForwardShortMessageIndication: " + e.getMessage(), e);
  332. }
  333. }
  334. }
  335. private void mtForwardShortMessageResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  336. MtForwardShortMessageResponseIndicationImpl ind = new MtForwardShortMessageResponseIndicationImpl();
  337. if (parameter != null) {
  338. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  339. throw new MAPParsingComponentException(
  340. "Error while decoding mtForwardShortMessageResponse: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  341. MAPParsingComponentExceptionReason.MistypedParameter);
  342. byte[] buf = parameter.getData();
  343. AsnInputStream ais = new AsnInputStream(buf);
  344. ind.decodeData(ais, buf.length);
  345. }
  346. ind.setInvokeId(invokeId);
  347. ind.setMAPDialog(mapDialogImpl);
  348. for (MAPServiceListener serLis : this.serviceListeners) {
  349. try {
  350. serLis.onMAPMessage(ind);
  351. ((MAPServiceSmsListener) serLis).onMtForwardShortMessageRespIndication(ind);
  352. } catch (Exception e) {
  353. loger.error("Error processing onMtForwardShortMessageRespIndication: " + e.getMessage(), e);
  354. }
  355. }
  356. }
  357. private void sendRoutingInfoForSMRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  358. if (parameter == null)
  359. throw new MAPParsingComponentException("Error while decoding sendRoutingInfoForSMRequest: Parameter is mandatory but not found",
  360. MAPParsingComponentExceptionReason.MistypedParameter);
  361. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  362. throw new MAPParsingComponentException(
  363. "Error while decoding sendRoutingInfoForSMRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  364. MAPParsingComponentExceptionReason.MistypedParameter);
  365. byte[] buf = parameter.getData();
  366. AsnInputStream ais = new AsnInputStream(buf);
  367. SendRoutingInfoForSMRequestIndicationImpl ind = new SendRoutingInfoForSMRequestIndicationImpl();
  368. ind.decodeData(ais, buf.length);
  369. ind.setInvokeId(invokeId);
  370. ind.setMAPDialog(mapDialogImpl);
  371. for (MAPServiceListener serLis : this.serviceListeners) {
  372. try {
  373. serLis.onMAPMessage(ind);
  374. ((MAPServiceSmsListener) serLis).onSendRoutingInfoForSMIndication(ind);
  375. } catch (Exception e) {
  376. loger.error("Error processing onSendRoutingInfoForSMIndication: " + e.getMessage(), e);
  377. }
  378. }
  379. }
  380. private void sendRoutingInfoForSMResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  381. SendRoutingInfoForSMResponseIndicationImpl ind = new SendRoutingInfoForSMResponseIndicationImpl();
  382. if (parameter == null)
  383. throw new MAPParsingComponentException("Error while decoding sendRoutingInfoForSMResponse: Parameter is mandatory but not found",
  384. MAPParsingComponentExceptionReason.MistypedParameter);
  385. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  386. throw new MAPParsingComponentException(
  387. "Error while decoding sendRoutingInfoForSMResponse: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  388. MAPParsingComponentExceptionReason.MistypedParameter);
  389. byte[] buf = parameter.getData();
  390. AsnInputStream ais = new AsnInputStream(buf);
  391. ind.decodeData(ais, buf.length);
  392. ind.setInvokeId(invokeId);
  393. ind.setMAPDialog(mapDialogImpl);
  394. for (MAPServiceListener serLis : this.serviceListeners) {
  395. try {
  396. serLis.onMAPMessage(ind);
  397. ((MAPServiceSmsListener) serLis).onSendRoutingInfoForSMRespIndication(ind);
  398. } catch (Exception e) {
  399. loger.error("Error processing onSendRoutingInfoForSMRespIndication: " + e.getMessage(), e);
  400. }
  401. }
  402. }
  403. private void reportSMDeliveryStatusRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  404. if (parameter == null)
  405. throw new MAPParsingComponentException("Error while decoding sendRoutingInfoForSMRequest: Parameter is mandatory but not found",
  406. MAPParsingComponentExceptionReason.MistypedParameter);
  407. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  408. throw new MAPParsingComponentException(
  409. "Error while decoding sendRoutingInfoForSMRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  410. MAPParsingComponentExceptionReason.MistypedParameter);
  411. byte[] buf = parameter.getData();
  412. AsnInputStream ais = new AsnInputStream(buf);
  413. ReportSMDeliveryStatusRequestIndicationImpl ind = new ReportSMDeliveryStatusRequestIndicationImpl(mapDialogImpl.getApplicationContext()
  414. .getApplicationContextVersion().getVersion());
  415. ind.decodeData(ais, buf.length);
  416. ind.setInvokeId(invokeId);
  417. ind.setMAPDialog(mapDialogImpl);
  418. for (MAPServiceListener serLis : this.serviceListeners) {
  419. try {
  420. serLis.onMAPMessage(ind);
  421. ((MAPServiceSmsListener) serLis).onReportSMDeliveryStatusIndication(ind);
  422. } catch (Exception e) {
  423. loger.error("Error processing onReportSMDeliveryStatusIndication: " + e.getMessage(), e);
  424. }
  425. }
  426. }
  427. private void reportSMDeliveryStatusResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  428. ReportSMDeliveryStatusResponseIndicationImpl ind = new ReportSMDeliveryStatusResponseIndicationImpl();
  429. if (parameter != null) {
  430. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  431. throw new MAPParsingComponentException(
  432. "Error while decoding reportSMDeliveryStatusResponse: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  433. MAPParsingComponentExceptionReason.MistypedParameter);
  434. byte[] buf = parameter.getData();
  435. AsnInputStream ais = new AsnInputStream(buf);
  436. ind.decodeData(ais, buf.length);
  437. }
  438. ind.setInvokeId(invokeId);
  439. ind.setMAPDialog(mapDialogImpl);
  440. for (MAPServiceListener serLis : this.serviceListeners) {
  441. try {
  442. serLis.onMAPMessage(ind);
  443. ((MAPServiceSmsListener) serLis).onReportSMDeliveryStatusRespIndication(ind);
  444. } catch (Exception e) {
  445. loger.error("Error processing onReportSMDeliveryStatusRespIndication: " + e.getMessage(), e);
  446. }
  447. }
  448. }
  449. private void informServiceCentreRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  450. if (parameter == null)
  451. throw new MAPParsingComponentException("Error while decoding informServiceCentreRequest: Parameter is mandatory but not found",
  452. MAPParsingComponentExceptionReason.MistypedParameter);
  453. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  454. throw new MAPParsingComponentException(
  455. "Error while decoding informServiceCentreRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  456. MAPParsingComponentExceptionReason.MistypedParameter);
  457. InformServiceCentreRequestIndicationImpl ind = new InformServiceCentreRequestIndicationImpl();
  458. byte[] buf = parameter.getData();
  459. AsnInputStream ais = new AsnInputStream(buf);
  460. ind.decodeData(ais, buf.length);
  461. ind.setInvokeId(invokeId);
  462. ind.setMAPDialog(mapDialogImpl);
  463. for (MAPServiceListener serLis : this.serviceListeners) {
  464. try {
  465. serLis.onMAPMessage(ind);
  466. ((MAPServiceSmsListener) serLis).onInformServiceCentreIndication(ind);
  467. } catch (Exception e) {
  468. loger.error("Error processing onInformServiceCentreIndication: " + e.getMessage(), e);
  469. }
  470. }
  471. }
  472. private void alertServiceCentreRequest(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId, int operationCode) throws MAPParsingComponentException {
  473. if (parameter == null)
  474. throw new MAPParsingComponentException("Error while decoding alertServiceCentreRequest: Parameter is mandatory but not found",
  475. MAPParsingComponentExceptionReason.MistypedParameter);
  476. if (parameter.getTag() != Tag.SEQUENCE || parameter.getTagClass() != Tag.CLASS_UNIVERSAL || parameter.isPrimitive())
  477. throw new MAPParsingComponentException(
  478. "Error while decoding alertServiceCentreRequest: Bad tag or tagClass or parameter is primitive, received tag=" + parameter.getTag(),
  479. MAPParsingComponentExceptionReason.MistypedParameter);
  480. AlertServiceCentreRequestIndicationImpl ind = new AlertServiceCentreRequestIndicationImpl(operationCode);
  481. byte[] buf = parameter.getData();
  482. AsnInputStream ais = new AsnInputStream(buf);
  483. ind.decodeData(ais, buf.length);
  484. ind.setInvokeId(invokeId);
  485. ind.setMAPDialog(mapDialogImpl);
  486. for (MAPServiceListener serLis : this.serviceListeners) {
  487. try {
  488. serLis.onMAPMessage(ind);
  489. ((MAPServiceSmsListener) serLis).onAlertServiceCentreIndication(ind);
  490. } catch (Exception e) {
  491. loger.error("Error processing onAlertServiceCentreIndication: " + e.getMessage(), e);
  492. }
  493. }
  494. }
  495. private void alertServiceCentreResponse(Parameter parameter, MAPDialogSmsImpl mapDialogImpl, Long invokeId) throws MAPParsingComponentException {
  496. AlertServiceCentreResponseIndicationImpl ind = new AlertServiceCentreResponseIndicationImpl();
  497. ind.setInvokeId(invokeId);
  498. ind.setMAPDialog(mapDialogImpl);
  499. for (MAPServiceListener serLis : this.serviceListeners) {
  500. try {
  501. serLis.onMAPMessage(ind);
  502. ((MAPServiceSmsListener) serLis).onAlertServiceCentreRespIndication(ind);
  503. } catch (Exception e) {
  504. loger.error("Error processing onAlertServiceCentreRespIndication: " + e.getMessage(), e);
  505. }
  506. }
  507. }
  508. }