PageRenderTime 57ms CodeModel.GetById 18ms app.highlight 34ms RepoModel.GetById 1ms app.codeStats 0ms

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