Created
November 14, 2015 01:10
-
-
Save ibstelix/b145526c0cc6e40c98a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a671bec5e0c43763f017d7765f86a3d51986a3da Mon Sep 17 00:00:00 2001 | |
From: ibstelix <[email protected]> | |
Date: Wed, 1 Jul 2015 20:25:37 +0000 | |
Subject: [PATCH] Add MCC,MNC,LAC in http result | |
--- | |
.../gmlc/slee/MobileCoreNetworkInterfaceSbb.java | 558 +++++++++++--------- | |
1 file changed, 323 insertions(+), 235 deletions(-) | |
diff --git a/core/slee/sbbs/src/main/java/org/mobicents/gmlc/slee/MobileCoreNetworkInterfaceSbb.java b/core/slee/sbbs/src/main/java/org/mobicents/gmlc/slee/MobileCoreNetworkInterfaceSbb.java | |
index 689ffaa..4e3b2fc 100644 | |
--- a/core/slee/sbbs/src/main/java/org/mobicents/gmlc/slee/MobileCoreNetworkInterfaceSbb.java | |
+++ b/core/slee/sbbs/src/main/java/org/mobicents/gmlc/slee/MobileCoreNetworkInterfaceSbb.java | |
@@ -71,29 +71,29 @@ import org.mobicents.slee.resource.map.MAPContextInterfaceFactory; | |
*/ | |
public abstract class MobileCoreNetworkInterfaceSbb implements Sbb { | |
- protected SbbContextExt sbbContext; | |
+ protected SbbContextExt sbbContext; | |
- private Tracer logger; | |
+ private Tracer logger; | |
- protected MAPContextInterfaceFactory mapAcif; | |
- protected MAPProvider mapProvider; | |
- protected MAPParameterFactory mapParameterFactory; | |
+ protected MAPContextInterfaceFactory mapAcif; | |
+ protected MAPProvider mapProvider; | |
+ protected MAPParameterFactory mapParameterFactory; | |
- protected static final ResourceAdaptorTypeID mapRATypeID = new ResourceAdaptorTypeID("MAPResourceAdaptorType", | |
- "org.mobicents", "2.0"); | |
- protected static final String mapRaLink = "MAPRA"; | |
+ protected static final ResourceAdaptorTypeID mapRATypeID = new ResourceAdaptorTypeID( | |
+ "MAPResourceAdaptorType", "org.mobicents", "2.0"); | |
+ protected static final String mapRaLink = "MAPRA"; | |
- private static final GmlcPropertiesManagement gmlcPropertiesManagement = GmlcPropertiesManagement.getInstance(); | |
+ private static final GmlcPropertiesManagement gmlcPropertiesManagement = GmlcPropertiesManagement | |
+ .getInstance(); | |
- private SccpAddress serviceCenterSCCPAddress = null; | |
- private MAPApplicationContext anyTimeEnquiryContext = null; | |
+ private SccpAddress serviceCenterSCCPAddress = null; | |
+ private MAPApplicationContext anyTimeEnquiryContext = null; | |
/** | |
* HTTP Request Types (GET or MLP) | |
*/ | |
private enum httpRequestTypes { | |
- HTTP_REQUEST_GET, | |
- HTTP_REQUEST_MLP | |
+ HTTP_REQUEST_GET, HTTP_REQUEST_MLP | |
} | |
/** | |
@@ -127,161 +127,210 @@ public abstract class MobileCoreNetworkInterfaceSbb implements Sbb { | |
private String fakeLocationY = "153 01 43.00E"; | |
private String fakeLocationRadius = "5000"; | |
- /** Creates a new instance of CallSbb */ | |
- public MobileCoreNetworkInterfaceSbb() { | |
- } | |
+ private int responseother; | |
- public void setSbbContext(SbbContext sbbContext) { | |
- this.sbbContext = (SbbContextExt) sbbContext; | |
- this.logger = sbbContext.getTracer(MobileCoreNetworkInterfaceSbb.class.getSimpleName()); | |
- try { | |
- this.mapAcif = (MAPContextInterfaceFactory) this.sbbContext.getActivityContextInterfaceFactory(mapRATypeID); | |
- this.mapProvider = (MAPProvider) this.sbbContext.getResourceAdaptorInterface(mapRATypeID, mapRaLink); | |
- this.mapParameterFactory = this.mapProvider.getMAPParameterFactory(); | |
- } catch (Exception ne) { | |
- logger.severe("Could not set SBB context:", ne); | |
- } | |
- } | |
+ private int responseLacId; | |
- public void unsetSbbContext() { | |
- this.sbbContext = null; | |
- this.logger = null; | |
- } | |
+ private int responseMcc; | |
- public void sbbCreate() throws CreateException { | |
- if (this.logger.isFineEnabled()) { | |
- this.logger.fine("Created KnowledgeBase"); | |
- } | |
- } | |
+ private int responseMnc; | |
- public void sbbPostCreate() throws CreateException { | |
+ /** Creates a new instance of CallSbb */ | |
+ public MobileCoreNetworkInterfaceSbb() { | |
+ } | |
- } | |
+ public void setSbbContext(SbbContext sbbContext) { | |
+ this.sbbContext = (SbbContextExt) sbbContext; | |
+ this.logger = sbbContext.getTracer(MobileCoreNetworkInterfaceSbb.class | |
+ .getSimpleName()); | |
+ try { | |
+ this.mapAcif = (MAPContextInterfaceFactory) this.sbbContext | |
+ .getActivityContextInterfaceFactory(mapRATypeID); | |
+ this.mapProvider = (MAPProvider) this.sbbContext | |
+ .getResourceAdaptorInterface(mapRATypeID, mapRaLink); | |
+ this.mapParameterFactory = this.mapProvider | |
+ .getMAPParameterFactory(); | |
+ } catch (Exception ne) { | |
+ logger.severe("Could not set SBB context:", ne); | |
+ } | |
+ } | |
- public void sbbActivate() { | |
- } | |
+ public void unsetSbbContext() { | |
+ this.sbbContext = null; | |
+ this.logger = null; | |
+ } | |
- public void sbbPassivate() { | |
- } | |
+ public void sbbCreate() throws CreateException { | |
+ if (this.logger.isFineEnabled()) { | |
+ this.logger.fine("Created KnowledgeBase"); | |
+ } | |
+ } | |
- public void sbbLoad() { | |
- } | |
+ public void sbbPostCreate() throws CreateException { | |
- public void sbbStore() { | |
- } | |
+ } | |
- public void sbbRemove() { | |
- } | |
+ public void sbbActivate() { | |
+ } | |
- public void sbbExceptionThrown(Exception exception, Object object, ActivityContextInterface activityContextInterface) { | |
- } | |
+ public void sbbPassivate() { | |
+ } | |
- public void sbbRolledBack(RolledBackContext rolledBackContext) { | |
- } | |
+ public void sbbLoad() { | |
+ } | |
- /** | |
- * DIALOG Events | |
- */ | |
+ public void sbbStore() { | |
+ } | |
- public void onDialogTimeout(org.mobicents.slee.resource.map.events.DialogTimeout evt, ActivityContextInterface aci) { | |
- if (logger.isWarningEnabled()) { | |
- this.logger.warning("Rx : onDialogTimeout" + evt); | |
- } | |
- } | |
+ public void sbbRemove() { | |
+ } | |
- public void onDialogDelimiter(org.mobicents.slee.resource.map.events.DialogDelimiter event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ public void sbbExceptionThrown(Exception exception, Object object, | |
+ ActivityContextInterface activityContextInterface) { | |
+ } | |
- } | |
+ public void sbbRolledBack(RolledBackContext rolledBackContext) { | |
+ } | |
- public void onDialogAccept(org.mobicents.slee.resource.map.events.DialogAccept event, ActivityContextInterface aci) { | |
+ /** | |
+ * DIALOG Events | |
+ */ | |
- } | |
+ public void onDialogTimeout( | |
+ org.mobicents.slee.resource.map.events.DialogTimeout evt, | |
+ ActivityContextInterface aci) { | |
+ if (logger.isWarningEnabled()) { | |
+ this.logger.warning("Rx : onDialogTimeout" + evt); | |
+ } | |
+ } | |
- public void onDialogReject(org.mobicents.slee.resource.map.events.DialogReject event, ActivityContextInterface aci) { | |
+ public void onDialogDelimiter( | |
+ org.mobicents.slee.resource.map.events.DialogDelimiter event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
- } | |
+ } | |
- public void onDialogUserAbort(org.mobicents.slee.resource.map.events.DialogUserAbort event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ public void onDialogAccept( | |
+ org.mobicents.slee.resource.map.events.DialogAccept event, | |
+ ActivityContextInterface aci) { | |
- } | |
+ } | |
- public void onDialogProviderAbort(org.mobicents.slee.resource.map.events.DialogProviderAbort event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ public void onDialogReject( | |
+ org.mobicents.slee.resource.map.events.DialogReject event, | |
+ ActivityContextInterface aci) { | |
- } | |
+ } | |
- public void onDialogClose(org.mobicents.slee.resource.map.events.DialogClose event, ActivityContextInterface aci) { | |
+ public void onDialogUserAbort( | |
+ org.mobicents.slee.resource.map.events.DialogUserAbort event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
- } | |
+ } | |
- public void onDialogNotice(org.mobicents.slee.resource.map.events.DialogNotice event, ActivityContextInterface aci) { | |
+ public void onDialogProviderAbort( | |
+ org.mobicents.slee.resource.map.events.DialogProviderAbort event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
- } | |
+ } | |
- public void onDialogRelease(org.mobicents.slee.resource.map.events.DialogRelease event, ActivityContextInterface aci) { | |
+ public void onDialogClose( | |
+ org.mobicents.slee.resource.map.events.DialogClose event, | |
+ ActivityContextInterface aci) { | |
- } | |
+ } | |
- /** | |
- * Component Events | |
- */ | |
- public void onInvokeTimeout(org.mobicents.slee.resource.map.events.InvokeTimeout event, ActivityContextInterface aci) { | |
+ public void onDialogNotice( | |
+ org.mobicents.slee.resource.map.events.DialogNotice event, | |
+ ActivityContextInterface aci) { | |
- } | |
+ } | |
- public void onErrorComponent(org.mobicents.slee.resource.map.events.ErrorComponent event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ public void onDialogRelease( | |
+ org.mobicents.slee.resource.map.events.DialogRelease event, | |
+ ActivityContextInterface aci) { | |
- } | |
+ } | |
- public void onRejectComponent(org.mobicents.slee.resource.map.events.RejectComponent event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ /** | |
+ * Component Events | |
+ */ | |
+ public void onInvokeTimeout( | |
+ org.mobicents.slee.resource.map.events.InvokeTimeout event, | |
+ ActivityContextInterface aci) { | |
+ | |
+ } | |
- } | |
+ public void onErrorComponent( | |
+ org.mobicents.slee.resource.map.events.ErrorComponent event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
- /** | |
- * ATI Events | |
- */ | |
- public void onAnyTimeInterrofationRequest( | |
- org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationRequest event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ } | |
- } | |
+ public void onRejectComponent( | |
+ org.mobicents.slee.resource.map.events.RejectComponent event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
- public void onAnyTimeInterrogationResponse( | |
- org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationResponse event, | |
- ActivityContextInterface aci/* , EventContext eventContext */) { | |
- try { | |
- MAPDialogMobility mapDialogMobility = event.getMAPDialog(); | |
- SubscriberInfo si = event.getSubscriberInfo(); | |
- CellGlobalIdOrServiceAreaIdOrLAI cellGlobalIdOrServiceAreaIdOrLAI = si.getLocationInformation() | |
- .getCellGlobalIdOrServiceAreaIdOrLAI(); | |
- this.responseCellId = cellGlobalIdOrServiceAreaIdOrLAI.getCellGlobalIdOrServiceAreaIdFixedLength().getCellIdOrServiceAreaCode(); | |
- SubscriberState ss = si.getSubscriberState(); | |
+ } | |
+ | |
+ /** | |
+ * ATI Events | |
+ */ | |
+ public void onAnyTimeInterrogationRequest( | |
+ org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationRequest event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ | |
+ } | |
+ | |
+ public void onAnyTimeInterrogationResponse( | |
+ org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationResponse event, | |
+ ActivityContextInterface aci/* , EventContext eventContext */) { | |
+ try { | |
+ MAPDialogMobility mapDialogMobility = event.getMAPDialog(); | |
+ SubscriberInfo si = event.getSubscriberInfo(); | |
+ CellGlobalIdOrServiceAreaIdOrLAI cellGlobalIdOrServiceAreaIdOrLAI = si | |
+ .getLocationInformation() | |
+ .getCellGlobalIdOrServiceAreaIdOrLAI(); | |
+ this.responseCellId = cellGlobalIdOrServiceAreaIdOrLAI | |
+ .getCellGlobalIdOrServiceAreaIdFixedLength() | |
+ .getCellIdOrServiceAreaCode(); | |
+ this.responseLacId = cellGlobalIdOrServiceAreaIdOrLAI | |
+ .getLAIFixedLength().getLac(); | |
+ this.responseMcc = cellGlobalIdOrServiceAreaIdOrLAI | |
+ .getLAIFixedLength().getMCC(); | |
+ this.responseMnc = cellGlobalIdOrServiceAreaIdOrLAI | |
+ .getLAIFixedLength().getMNC(); | |
+ SubscriberState ss = si.getSubscriberState(); | |
// Handle successfully having retried the device's cell-id | |
this.handleLocationResponse(MLPResponse.MLPResultType.OK, null); | |
- } catch (Exception e) { | |
- logger.severe(String.format("Error while trying to process AnyTimeInterrogationResponse=%s", event), e); | |
- this.handleLocationResponse(MLPResponse.MLPResultType.SYSTEM_FAILURE, "Internal failure occurred while processing network response"); | |
- } | |
- } | |
+ } catch (Exception e) { | |
+ logger.severe( | |
+ String.format( | |
+ "Error while trying to process AnyTimeInterrogationResponse=%s", | |
+ event), e); | |
+ this.handleLocationResponse( | |
+ MLPResponse.MLPResultType.SYSTEM_FAILURE, | |
+ "Internal failure occurred while processing network response"); | |
+ } | |
+ } | |
/** | |
* Handle HTTP POST request, used for processing MLP location request | |
+ * | |
* @param event | |
* @param aci | |
* @param eventContext | |
*/ | |
- public void onPost(net.java.slee.resource.http.events.HttpServletRequestEvent event, ActivityContextInterface aci, | |
- EventContext eventContext) { | |
+ public void onPost( | |
+ net.java.slee.resource.http.events.HttpServletRequestEvent event, | |
+ ActivityContextInterface aci, EventContext eventContext) { | |
this.setEventContext(eventContext); | |
this.httpRequestType = this.httpRequestType.HTTP_REQUEST_MLP; | |
- // Handle retrieving the request, parsing it, and generating the network location request | |
+ // Handle retrieving the request, parsing it, and generating the network | |
+ // location request | |
try { | |
// Get the XML request from the POST data | |
HttpServletRequest httpServletRequest = event.getRequest(); | |
@@ -295,51 +344,56 @@ public abstract class MobileCoreNetworkInterfaceSbb implements Sbb { | |
eventContext.suspendDelivery(); | |
this.getSingleMSISDNLocation(); | |
- // result will be sent via sendHTTPResult(), which will be called by onAnyTimeInterrogationResponse() or | |
+ // result will be sent via sendHTTPResult(), which will be called by | |
+ // onAnyTimeInterrogationResponse() or | |
// getSingleMSISDNLocation() | |
- } | |
- catch(MLPException e) { | |
- this.handleLocationResponse(e.getMlpClientErrorType(), e.getMlpClientErrorMessage()); | |
- } | |
- catch (IOException e) { | |
+ } catch (MLPException e) { | |
+ this.handleLocationResponse(e.getMlpClientErrorType(), | |
+ e.getMlpClientErrorMessage()); | |
+ } catch (IOException e) { | |
e.printStackTrace(); | |
- this.handleLocationResponse(MLPResponse.MLPResultType.FORMAT_ERROR, "Failed to read from server input stream"); | |
+ this.handleLocationResponse(MLPResponse.MLPResultType.FORMAT_ERROR, | |
+ "Failed to read from server input stream"); | |
} | |
} | |
/** | |
- * Handle HTTP GET request for a single MSISDN location | |
- * Mostly just used for testing at the moment | |
+ * Handle HTTP GET request for a single MSISDN location Mostly just used for | |
+ * testing at the moment | |
+ * | |
* @param event | |
* @param aci | |
* @param eventContext | |
*/ | |
- public void onGet(net.java.slee.resource.http.events.HttpServletRequestEvent event, ActivityContextInterface aci, | |
- EventContext eventContext) { | |
- this.setEventContext(eventContext); | |
+ public void onGet( | |
+ net.java.slee.resource.http.events.HttpServletRequestEvent event, | |
+ ActivityContextInterface aci, EventContext eventContext) { | |
+ this.setEventContext(eventContext); | |
this.httpRequestType = this.httpRequestType.HTTP_REQUEST_GET; | |
- HttpServletRequest httpServletRequest = event.getRequest(); | |
- this.requestingMSISDN = httpServletRequest.getParameter("msisdn"); | |
+ HttpServletRequest httpServletRequest = event.getRequest(); | |
+ this.requestingMSISDN = httpServletRequest.getParameter("msisdn"); | |
if (this.requestingMSISDN != null) { | |
eventContext.suspendDelivery(); | |
getSingleMSISDNLocation(); | |
} else { | |
this.logger.info("MSISDN is null, sending back -1 for cellid"); | |
- this.handleLocationResponse(MLPResponse.MLPResultType.UNKNOWN_SUBSCRIBER, "Invalid MSISDN specified"); | |
+ this.handleLocationResponse( | |
+ MLPResponse.MLPResultType.UNKNOWN_SUBSCRIBER, | |
+ "Invalid MSISDN specified"); | |
} | |
- } | |
+ } | |
- /** | |
- * CMP | |
- */ | |
- public abstract void setEventContext(EventContext cntx); | |
+ /** | |
+ * CMP | |
+ */ | |
+ public abstract void setEventContext(EventContext cntx); | |
- public abstract EventContext getEventContext(); | |
+ public abstract EventContext getEventContext(); | |
- /** | |
- * Private helper methods | |
- */ | |
+ /** | |
+ * Private helper methods | |
+ */ | |
/** | |
* Retrieve the location for the specified MSISDN via ATI request to the HLR | |
@@ -347,136 +401,170 @@ public abstract class MobileCoreNetworkInterfaceSbb implements Sbb { | |
private void getSingleMSISDNLocation() { | |
if (!useFakeLocation) { | |
try { | |
- this.logger.severe("===== NOT USING FAKE LOCATION ====" ); | |
- MAPDialogMobility mapDialogMobility = this.mapProvider.getMAPServiceMobility().createNewDialog( | |
- this.getSRIMAPApplicationContext(), this.getServiceCenterSccpAddress(), null, | |
- convertAddressFieldToSCCPAddress(this.requestingMSISDN), null); | |
- | |
- ISDNAddressString isdnAdd = new ISDNAddressStringImpl(AddressNature.international_number, | |
- org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, this.requestingMSISDN); | |
+ this.logger.severe("===== NOT USING FAKE LOCATION ===="); | |
+ MAPDialogMobility mapDialogMobility = this.mapProvider | |
+ .getMAPServiceMobility() | |
+ .createNewDialog( | |
+ this.getSRIMAPApplicationContext(), | |
+ this.getServiceCenterSccpAddress(), | |
+ null, | |
+ convertAddressFieldToSCCPAddress(this.requestingMSISDN), | |
+ null); | |
+ | |
+ ISDNAddressString isdnAdd = new ISDNAddressStringImpl( | |
+ AddressNature.international_number, | |
+ org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, | |
+ this.requestingMSISDN); | |
SubscriberIdentity subsId = new SubscriberIdentityImpl(isdnAdd); | |
- RequestedInfo requestedInfo = new RequestedInfoImpl(true, true, null, false, null, false, false, false); | |
- ISDNAddressString gscmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, | |
+ RequestedInfo requestedInfo = new RequestedInfoImpl(true, true, | |
+ null, false, null, false, false, false); | |
+ ISDNAddressString gscmSCFAddress = new ISDNAddressStringImpl( | |
+ AddressNature.international_number, | |
org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, | |
gmlcPropertiesManagement.getGmlcGt()); | |
- mapDialogMobility.addAnyTimeInterrogationRequest(subsId, requestedInfo, gscmSCFAddress, null); | |
+ mapDialogMobility.addAnyTimeInterrogationRequest(subsId, | |
+ requestedInfo, gscmSCFAddress, null); | |
- ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogMobility); | |
+ ActivityContextInterface sriDialogACI = this.mapAcif | |
+ .getActivityContextInterface(mapDialogMobility); | |
sriDialogACI.attach(this.sbbContext.getSbbLocalObject()); | |
mapDialogMobility.send(); | |
} catch (MAPException e) { | |
- this.logger.severe("MAPException while trying to send ATI request for MSISDN=" + this.requestingMSISDN, e); | |
- this.handleLocationResponse(MLPResponse.MLPResultType.SYSTEM_FAILURE, "Failed to send request to network for position"); | |
+ this.logger.severe( | |
+ "MAPException while trying to send ATI request for MSISDN=" | |
+ + this.requestingMSISDN, e); | |
+ this.handleLocationResponse( | |
+ MLPResponse.MLPResultType.SYSTEM_FAILURE, | |
+ "Failed to send request to network for position"); | |
} catch (Exception e) { | |
- this.logger.severe("Exception while trying to send ATI request for MSISDN=" + this.requestingMSISDN, e); | |
- this.handleLocationResponse(MLPResponse.MLPResultType.SYSTEM_FAILURE, "Failed to send request to network for position"); | |
+ this.logger.severe( | |
+ "Exception while trying to send ATI request for MSISDN=" | |
+ + this.requestingMSISDN, e); | |
+ this.handleLocationResponse( | |
+ MLPResponse.MLPResultType.SYSTEM_FAILURE, | |
+ "Failed to send request to network for position"); | |
} | |
- } | |
- else { | |
+ } else { | |
// Handle fake success | |
- this.logger.severe("===== USING FAKE LOCATION ====" ); | |
+ this.logger.severe("===== USING FAKE LOCATION ===="); | |
if (this.fakeLocationType == MLPResponse.MLPResultType.OK) { | |
this.responseCellId = this.fakeCellId; | |
this.handleLocationResponse(this.fakeLocationType, null); | |
- } | |
- else { | |
+ } else { | |
this.responseCellId = -1; | |
- this.handleLocationResponse(this.fakeLocationType, this.fakeLocationAdditionalInfoErrorString); | |
+ this.handleLocationResponse(this.fakeLocationType, | |
+ this.fakeLocationAdditionalInfoErrorString); | |
} | |
} | |
} | |
- protected SccpAddress getServiceCenterSccpAddress() { | |
- if (this.serviceCenterSCCPAddress == null) { | |
- GT0100 gt = new GT0100(0, NumberingPlan.ISDN_TELEPHONY, NatureOfAddress.INTERNATIONAL, | |
- gmlcPropertiesManagement.getGmlcGt()); | |
- this.serviceCenterSCCPAddress = new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt, | |
- gmlcPropertiesManagement.getGmlcSsn()); | |
- } | |
- return this.serviceCenterSCCPAddress; | |
- } | |
- | |
- private MAPApplicationContext getSRIMAPApplicationContext() { | |
- if (this.anyTimeEnquiryContext == null) { | |
- this.anyTimeEnquiryContext = MAPApplicationContext.getInstance( | |
- MAPApplicationContextName.anyTimeEnquiryContext, MAPApplicationContextVersion.version3); | |
- } | |
- return this.anyTimeEnquiryContext; | |
- } | |
- | |
- private SccpAddress convertAddressFieldToSCCPAddress(String address) { | |
- GT0100 gt = new GT0100(0, NumberingPlan.ISDN_TELEPHONY, NatureOfAddress.INTERNATIONAL, address); | |
- return new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt, | |
- gmlcPropertiesManagement.getHlrSsn()); | |
- } | |
+ protected SccpAddress getServiceCenterSccpAddress() { | |
+ if (this.serviceCenterSCCPAddress == null) { | |
+ GT0100 gt = new GT0100(0, NumberingPlan.ISDN_TELEPHONY, | |
+ NatureOfAddress.INTERNATIONAL, | |
+ gmlcPropertiesManagement.getGmlcGt()); | |
+ this.serviceCenterSCCPAddress = new SccpAddress( | |
+ RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, 0, gt, | |
+ gmlcPropertiesManagement.getGmlcSsn()); | |
+ } | |
+ return this.serviceCenterSCCPAddress; | |
+ } | |
+ | |
+ private MAPApplicationContext getSRIMAPApplicationContext() { | |
+ if (this.anyTimeEnquiryContext == null) { | |
+ this.anyTimeEnquiryContext = MAPApplicationContext.getInstance( | |
+ MAPApplicationContextName.anyTimeEnquiryContext, | |
+ MAPApplicationContextVersion.version3); | |
+ } | |
+ return this.anyTimeEnquiryContext; | |
+ } | |
+ | |
+ private SccpAddress convertAddressFieldToSCCPAddress(String address) { | |
+ GT0100 gt = new GT0100(0, NumberingPlan.ISDN_TELEPHONY, | |
+ NatureOfAddress.INTERNATIONAL, address); | |
+ return new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, | |
+ 0, gt, gmlcPropertiesManagement.getHlrSsn()); | |
+ } | |
/** | |
- * Handle generating the appropriate HTTP response | |
- * We're making use of the MLPResponse class for both GET/POST requests for convenience and | |
- * because eventually the GET method will likely be removed | |
- * @param mlpResultType OK or error type to return to client | |
- * @param mlpClientErrorMessage Error message to send to client | |
+ * Handle generating the appropriate HTTP response We're making use of the | |
+ * MLPResponse class for both GET/POST requests for convenience and because | |
+ * eventually the GET method will likely be removed | |
+ * | |
+ * @param mlpResultType | |
+ * OK or error type to return to client | |
+ * @param mlpClientErrorMessage | |
+ * Error message to send to client | |
*/ | |
- private void handleLocationResponse(MLPResponse.MLPResultType mlpResultType, String mlpClientErrorMessage) { | |
- switch(this.httpRequestType) | |
- { | |
- case HTTP_REQUEST_GET: | |
- if (mlpResultType == MLPResponse.MLPResultType.OK) { | |
- this.sendHTTPResult("cellid=" + this.responseCellId, true); | |
- } | |
- else { | |
- this.sendHTTPResult(mlpClientErrorMessage, false); | |
- } | |
- break; | |
- | |
- case HTTP_REQUEST_MLP: | |
- String svcResultXml; | |
- MLPResponse mlpResponse = new MLPResponse(this.logger); | |
- | |
- if (mlpResultType == MLPResponse.MLPResultType.OK) { | |
- svcResultXml = mlpResponse.getSinglePositionSuccessXML(this.fakeLocationX, this.fakeLocationY, this.fakeLocationRadius, this.requestingMSISDN); | |
- } | |
- else if (MLPResponse.isSystemError(mlpResultType)) { | |
- svcResultXml = mlpResponse.getSystemErrorResponseXML(mlpResultType, mlpClientErrorMessage); | |
- } | |
- else { | |
- svcResultXml = mlpResponse.getPositionErrorResponseXML(this.requestingMSISDN, mlpResultType, mlpClientErrorMessage); | |
- } | |
- | |
- this.logger.info("Generated response XML: "+svcResultXml); | |
- this.sendHTTPResult(svcResultXml, true); | |
- break; | |
+ private void handleLocationResponse( | |
+ MLPResponse.MLPResultType mlpResultType, | |
+ String mlpClientErrorMessage) { | |
+ switch (this.httpRequestType) { | |
+ case HTTP_REQUEST_GET: | |
+ if (mlpResultType == MLPResponse.MLPResultType.OK) { | |
+ this.sendHTTPResult("MCC=" + this.responseMcc + "&Mnc=" | |
+ + this.responseMnc + "&LacId=" + this.responseLacId | |
+ + "&cellid=" + this.responseCellId, true); | |
+ } else { | |
+ this.sendHTTPResult(mlpClientErrorMessage, false); | |
+ } | |
+ break; | |
+ | |
+ case HTTP_REQUEST_MLP: | |
+ String svcResultXml; | |
+ MLPResponse mlpResponse = new MLPResponse(this.logger); | |
+ | |
+ if (mlpResultType == MLPResponse.MLPResultType.OK) { | |
+ svcResultXml = mlpResponse.getSinglePositionSuccessXML( | |
+ this.fakeLocationX, this.fakeLocationY, | |
+ this.fakeLocationRadius, this.requestingMSISDN); | |
+ } else if (MLPResponse.isSystemError(mlpResultType)) { | |
+ svcResultXml = mlpResponse.getSystemErrorResponseXML( | |
+ mlpResultType, mlpClientErrorMessage); | |
+ } else { | |
+ svcResultXml = mlpResponse.getPositionErrorResponseXML( | |
+ this.requestingMSISDN, mlpResultType, | |
+ mlpClientErrorMessage); | |
+ } | |
+ | |
+ this.logger.info("Generated response XML: " + svcResultXml); | |
+ this.sendHTTPResult(svcResultXml, true); | |
+ break; | |
} | |
} | |
/** | |
* Return the specified response data to the HTTP client | |
- * @param responseData Response data to send to client | |
- * @param resumeEventDelivery If true, ctx.resumeDelivery() will be called | |
+ * | |
+ * @param responseData | |
+ * Response data to send to client | |
+ * @param resumeEventDelivery | |
+ * If true, ctx.resumeDelivery() will be called | |
*/ | |
- private void sendHTTPResult(String responseData, boolean resumeEventDelivery) { | |
- try { | |
- EventContext ctx = this.getEventContext(); | |
- HttpServletRequestEvent event = (HttpServletRequestEvent) ctx.getEvent(); | |
+ private void sendHTTPResult(String responseData, boolean resumeEventDelivery) { | |
+ try { | |
+ EventContext ctx = this.getEventContext(); | |
+ HttpServletRequestEvent event = (HttpServletRequestEvent) ctx | |
+ .getEvent(); | |
- HttpServletResponse response = event.getResponse(); | |
+ HttpServletResponse response = event.getResponse(); | |
PrintWriter w = null; | |
w = response.getWriter(); | |
w.print(responseData); | |
- w.flush(); | |
- response.flushBuffer(); | |
+ w.flush(); | |
+ response.flushBuffer(); | |
- if (resumeEventDelivery) { | |
- ctx.resumeDelivery(); | |
- } | |
+ if (resumeEventDelivery) { | |
+ ctx.resumeDelivery(); | |
+ } | |
- logger.info("HTTP Request received and response sent."); | |
+ logger.info("HTTP Request received and response sent."); | |
- // getNullActivity().endActivity(); | |
- } catch (Exception e) { | |
- logger.severe("Error while sending back HTTP response", e); | |
- } | |
- } | |
+ // getNullActivity().endActivity(); | |
+ } catch (Exception e) { | |
+ logger.severe("Error while sending back HTTP response", e); | |
+ } | |
+ } | |
} | |
-- | |
1.7.10.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment