Revision: a2b15ceaf03d
Author:   Sergey Vetyutnev <[email protected]>
Date:     Fri Jul 13 10:16:09 2012
Log:      CheckImei first update
http://code.google.com/p/jss7/source/detail?r=a2b15ceaf03d

Added:
/map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckImeiRequest.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckImeiResponse.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiRequestImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiResponseImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/RequestedEquipmentInfoImpl.java /map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiRequestTest.java
Deleted:
/map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckIMEIRequest.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckIMEIResponse.java
Modified:
/map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPMessageType.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPDialogMobility.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPServiceMobilityListener.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/EquipmentStatus.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/RequestedEquipmentInfo.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPDialogMobilityImpl.java /map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/EventTestHarness.java

=======================================
--- /dev/null
+++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckImeiRequest.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,61 @@
+/*
+ * TeleStax, Open Source Cloud Communications  Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.map.api.service.mobility.imei;
+
+import org.mobicents.protocols.ss7.map.api.primitives.IMEI;
+import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; +import org.mobicents.protocols.ss7.map.api.service.mobility.MobilityMessage;
+
+/**
+ *
+ * -- Version 2
+ * CheckIMEI ::= OPERATION                                                     
--Timer m
+ *             ARGUMENT
+ *                     imei                                    IMEI
+ *             RESULT
+ *                     equipmentStatus                 EquipmentStatus
+ *             ERRORS {
+ *                     SystemFailure,
+ *                     DataMissing,
+ *                     UnknownEquipment
+ *     }
+ *
+ * -- Version 3
+ * CheckIMEIArg ::= SEQUENCE {
+ *             imei                                            IMEI,
+ *             requestedEquipmentInfo          RequestedEquipmentInfo,
+ *             extensionContainer                      ExtensionContainer      
                OPTIONAL,
+ *     ...}
+ *
+ * @author normandes
+ *
+ */
+public interface CheckImeiRequest extends MobilityMessage {
+
+       public IMEI getIMEI();
+
+       public RequestedEquipmentInfo getRequestedEquipmentInfo();
+
+       public MAPExtensionContainer getExtensionContainer();
+
+}
=======================================
--- /dev/null
+++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckImeiResponse.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,60 @@
+/*
+ * TeleStax, Open Source Cloud Communications  Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.map.api.service.mobility.imei;
+
+import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; +import org.mobicents.protocols.ss7.map.api.service.mobility.MobilityMessage;
+
+/**
+ *
+ * -- Version 2
+ * CheckIMEI ::= OPERATION                                                     
--Timer m
+ *             ARGUMENT
+ *                     imei                                    IMEI
+ *             RESULT
+ *                     equipmentStatus                 EquipmentStatus
+ *             ERRORS {
+ *                     SystemFailure,
+ *                     DataMissing,
+ *                     UnknownEquipment
+ *     }
+ *
+ * -- Version 3
+ * CheckIMEIRes ::= SEQUENCE {
+ *             equipmentStatus                         EquipmentStatus         
                OPTIONAL,
+ *             bmuef                                           UESBI-Iu        
                                OPTIONAL,
+ *             extensionContainer                      [0] ExtensionContainer  
        OPTIONAL,
+ *     ...}
+ *
+ * @author normandes
+ *
+ */
+public interface CheckImeiResponse extends MobilityMessage {
+
+       public EquipmentStatus getEquipmentStatus();
+
+       public UESBIIu getBmuef();
+
+       public MAPExtensionContainer getExtensionContainer();
+
+}
=======================================
--- /dev/null
+++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiRequestImpl.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,255 @@
+/*
+ * TeleStax, Open Source Cloud Communications  Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.map.service.mobility.imei;
+
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+import org.mobicents.protocols.asn.AsnException;
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.map.api.MAPException;
+import org.mobicents.protocols.ss7.map.api.MAPMessageType;
+import org.mobicents.protocols.ss7.map.api.MAPOperationCode;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentException;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentExceptionReason;
+import org.mobicents.protocols.ss7.map.api.primitives.IMEI;
+import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiRequest; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.RequestedEquipmentInfo;
+import org.mobicents.protocols.ss7.map.primitives.IMEIImpl;
+import org.mobicents.protocols.ss7.map.primitives.IMSIImpl;
+import org.mobicents.protocols.ss7.map.primitives.MAPAsnPrimitive;
+import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerImpl; +import org.mobicents.protocols.ss7.map.service.mobility.MobilityMessageImpl;
+
+/**
+ * @author normandes
+ *
+ */
+public class CheckImeiRequestImpl extends MobilityMessageImpl implements CheckImeiRequest, MAPAsnPrimitive {
+
+ private static final Logger logger = Logger.getLogger(CheckImeiRequestImpl.class.getName());
+
+       public static final String _PrimitiveName = "CheckImeiRequest";
+
+       private IMEI imei = null;
+       private RequestedEquipmentInfo requestedEquipmentInfo = null;
+       private MAPExtensionContainer extensionContainer = null;
+
+       private long mapProtocolVersion;
+
+       public CheckImeiRequestImpl(long mapProtocolVersion) {
+               this.mapProtocolVersion = mapProtocolVersion;
+       }
+
+ public CheckImeiRequestImpl(long mapProtocolVersion, IMEI imei, RequestedEquipmentInfo requestedEquipmentInfo,
+                       MAPExtensionContainer extensionContainer) {
+               this.mapProtocolVersion = mapProtocolVersion;
+               this.imei = imei;
+               this.requestedEquipmentInfo = requestedEquipmentInfo;
+               this.extensionContainer = extensionContainer;
+       }
+
+       public long getMapProtocolVersion() {
+               return this.mapProtocolVersion;
+       }
+
+       @Override
+       public int getTag() throws MAPException {
+               if (this.mapProtocolVersion >= 3) {
+                       return Tag.SEQUENCE;
+               } else {
+                       return Tag.STRING_OCTET;
+               }
+       }
+
+       @Override
+       public int getTagClass() {
+               return Tag.CLASS_UNIVERSAL;
+       }
+
+       @Override
+       public boolean getIsPrimitive() {
+               if (this.mapProtocolVersion >= 3) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
+       @Override
+ public void decodeAll(AsnInputStream ansIS) throws MAPParsingComponentException {
+               try {
+                       int length = ansIS.readLength();
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+ public void decodeData(AsnInputStream ansIS, int length) throws MAPParsingComponentException {
+               try {
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+ private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException {
+
+               if (mapProtocolVersion >= 3) {
+                       AsnInputStream ais = 
ansIS.readSequenceStreamData(length);
+                       int num = 0;
+                       while (true) {
+                               if (ais.available() == 0) {
+                                       break;
+                               }
+
+                               int tag = ais.readTag();
+
+                               switch(num) {
+                               case 0:
+                                       // imei
+ if (tag != Tag.STRING_OCTET || ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) {
+                                               throw new 
MAPParsingComponentException(
+ "Error while decoding " + _PrimitiveName + ".imei: bad tag or tag class or is not primitive: TagClass=" + ais.getTagClass() + + ", tag=" + tag, MAPParsingComponentExceptionReason.MistypedParameter);
+                                       }
+                                       this.imei = new IMEIImpl();
+                                       ((IMEIImpl)this.imei).decodeAll(ais);
+                                       break;
+                               case 1:
+                                       // requestedEquipmentInfo
+ if (tag != Tag.STRING_BIT || ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) {
+                                               throw new 
MAPParsingComponentException(
+ "Error while decoding " + _PrimitiveName + ".requestedEquipmentInfo: bad tag or tag class or is not primitive: TagClass=" + ais.getTagClass() + + ", tag=" + tag, MAPParsingComponentExceptionReason.MistypedParameter);
+                                       }
+                                       this.requestedEquipmentInfo = new 
RequestedEquipmentInfoImpl();
+ ((RequestedEquipmentInfoImpl)this.requestedEquipmentInfo).decodeAll(ais);
+                                       break;
+                               default:
+                                       if (tag == Tag.SEQUENCE && 
ais.getTagClass() == Tag.CLASS_UNIVERSAL) {
+                                               if (ais.isTagPrimitive())
+ throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": Parameter extensionContainer is primitive",
+                                                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+                                               this.extensionContainer = new 
MAPExtensionContainerImpl();
+                                               
((MAPExtensionContainerImpl)this.extensionContainer).decodeAll(ais);
+                                       } else {
+                                               ais.advanceElement();
+                                       }
+                                       break;
+                               }
+
+                               num++;
+                       }
+
+                       if (num < 2)
+ throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": Needs at least 2 mandatory parameters, found "
+                                               + num, 
MAPParsingComponentExceptionReason.MistypedParameter);
+               } else {
+                       this.imei = new IMEIImpl();
+                       ((IMEIImpl)this.imei).decodeData(ansIS, length);
+               }
+       }
+
+       @Override
+       public void encodeAll(AsnOutputStream asnOs) throws MAPException {
+               this.encodeAll(asnOs, this.getTagClass(), this.getTag());
+
+       }
+
+       @Override
+ public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws MAPException {
+               try {
+                       asnOs.writeTag(tagClass, this.getIsPrimitive(), tag);
+                       int pos = asnOs.StartContentDefiniteLength();
+                       this.encodeData(asnOs);
+                       asnOs.FinalizeContent(pos);
+               } catch (AsnException e) {
+ throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
+               }
+
+       }
+
+       @Override
+       public void encodeData(AsnOutputStream asnOs) throws MAPException {
+               if (this.imei == null) {
+                       throw new MAPException("imei parameter must not be 
null");
+               }
+
+               if (mapProtocolVersion >= 3) {
+                       if (this.requestedEquipmentInfo == null) {
+ throw new MAPException("requestedEquipmentInfo parameter must not be null");
+                       }
+                       ((IMEIImpl)this.imei).encodeAll(asnOs);
+ ((RequestedEquipmentInfoImpl)this.requestedEquipmentInfo).encodeAll(asnOs);
+                       if (this.extensionContainer != null)
+                               ((MAPExtensionContainerImpl) 
this.extensionContainer).encodeAll(asnOs);
+               } else {
+                       ((IMEIImpl)this.imei).encodeData(asnOs);
+               }
+       }
+
+       @Override
+       public MAPMessageType getMessageType() {
+               return MAPMessageType.checkIMEI_Request;
+       }
+
+       @Override
+       public int getOperationCode() {
+               return MAPOperationCode.checkIMEI;
+       }
+
+       @Override
+       public IMEI getIMEI() {
+               return this.imei;
+       }
+
+       @Override
+       public RequestedEquipmentInfo getRequestedEquipmentInfo() {
+               return this.requestedEquipmentInfo;
+       }
+
+       @Override
+       public MAPExtensionContainer getExtensionContainer() {
+               return this.extensionContainer;
+       }
+
+       @Override
+       public String toString() {
+               //TODO: Implements this
+               return super.toString();
+       }
+
+}
=======================================
--- /dev/null
+++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiResponseImpl.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,208 @@
+package org.mobicents.protocols.ss7.map.service.mobility.imei;
+
+import java.io.IOException;
+
+import org.mobicents.protocols.asn.AsnException;
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.map.api.MAPException;
+import org.mobicents.protocols.ss7.map.api.MAPMessageType;
+import org.mobicents.protocols.ss7.map.api.MAPOperationCode;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentException;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentExceptionReason; +import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiResponse; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.EquipmentStatus;
+import org.mobicents.protocols.ss7.map.api.service.mobility.imei.UESBIIu;
+import org.mobicents.protocols.ss7.map.primitives.MAPAsnPrimitive;
+import org.mobicents.protocols.ss7.map.service.mobility.MobilityMessageImpl;
+
+public class CheckImeiResponseImpl extends MobilityMessageImpl implements CheckImeiResponse, MAPAsnPrimitive {
+
+       public static final String _PrimitiveName = "CheckImeiResponse";
+
+       private EquipmentStatus equipmentStatus;
+       private UESBIIu bmuef;
+       private MAPExtensionContainer extensionContainer;
+
+       private long mapProtocolVersion;
+
+       public CheckImeiResponseImpl(long mapProtocolVersion) {
+               this.mapProtocolVersion = mapProtocolVersion;
+       }
+
+ public CheckImeiResponseImpl(long mapProtocolVersion, UESBIIu bmuef, EquipmentStatus equipmentStatus) {
+               this.mapProtocolVersion = mapProtocolVersion;
+               this.bmuef = bmuef;
+               this.equipmentStatus = equipmentStatus;
+       }
+
+       public long getMapProtocolVersion() {
+               return this.mapProtocolVersion;
+       }
+
+       @Override
+       public int getTag() throws MAPException {
+               if (this.mapProtocolVersion >= 3) {
+                       return Tag.SEQUENCE;
+               } else {
+                       return Tag.ENUMERATED;
+               }
+       }
+
+       @Override
+       public int getTagClass() {
+               return Tag.CLASS_UNIVERSAL;
+       }
+
+       @Override
+       public boolean getIsPrimitive() {
+               if (this.mapProtocolVersion >= 3) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
+       @Override
+ public void decodeAll(AsnInputStream ansIS) throws MAPParsingComponentException {
+               try {
+                       int length = ansIS.readLength();
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+ private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException {
+
+               if (mapProtocolVersion >= 3) {
+                       AsnInputStream ais = 
ansIS.readSequenceStreamData(length);
+                       int num = 0;
+                       while (true) {
+                               if (ais.available() == 0) {
+                                       break;
+                               }
+
+                               int tag = ais.readTag();
+
+                               switch(num) {
+                               case 0:
+                                       // equipmentStatus
+ if (tag != Tag.ENUMERATED || ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive()) {
+                                               throw new 
MAPParsingComponentException(
+ "Error while decoding CheckImeiResponse.requestedEquipmentInfo: bad tag or tag class or is not primitive: TagClass=" + ais.getTagClass() + + ", tag=" + tag, MAPParsingComponentExceptionReason.MistypedParameter);
+                                       }
+                                       int i1 = (int)ansIS.readInteger();
+                                       this.equipmentStatus = 
EquipmentStatus.getInstance(i1);
+                                       break;
+                               case 1:
+                                       // bmuef
+                                       //TODO: Implement
+                                       break;
+                               case 2:
+                                       // extensionContainer
+                                       //TODO: Implement
+                                       break;
+                               default:
+                                       ais.advanceElement();
+                                       break;
+                               }
+
+                               num++;
+                       }
+               } else {
+                       int i1 = ansIS.read();
+                       this.equipmentStatus = EquipmentStatus.getInstance(i1);
+               }
+       }
+
+ public void decodeData(AsnInputStream ansIS, int length) throws MAPParsingComponentException {
+               try {
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding " + _PrimitiveName + ": " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+       @Override
+       public void encodeAll(AsnOutputStream asnOs) throws MAPException {
+               this.encodeAll(asnOs, this.getTagClass(), this.getTag());
+       }
+
+       @Override
+ public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws MAPException {
+               try {
+                       asnOs.writeTag(tagClass, this.getIsPrimitive(), tag);
+                       int pos = asnOs.StartContentDefiniteLength();
+                       this.encodeData(asnOs);
+                       asnOs.FinalizeContent(pos);
+               } catch (AsnException e) {
+ throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
+               }
+
+       }
+
+       @Override
+       public void encodeData(AsnOutputStream asnOs) throws MAPException {
+               /* Fazer as validacoes e lancar essas excecoes caso ocorram
+                * if (this.hlrNumber == null)
+                       throw new MAPException("hlrNumber parameter must not be 
null");*/
+
+               try {
+                       if (mapProtocolVersion >= 3) {
+
+                       } else {
+                               
asnOs.writeIntegerData(this.equipmentStatus.getCode());
+                       }
+               } catch (IOException e) {
+ throw new MAPException("IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
+               } /*catch (AsnException e) {
+ throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
+               }*/
+
+       }
+
+       @Override
+       public MAPMessageType getMessageType() {
+               return MAPMessageType.checkIMEI_Response;
+       }
+
+       @Override
+       public int getOperationCode() {
+               return MAPOperationCode.checkIMEI;
+       }
+
+       @Override
+       public EquipmentStatus getEquipmentStatus() {
+               return this.equipmentStatus;
+       }
+
+       @Override
+       public UESBIIu getBmuef() {
+               return bmuef;
+       }
+
+       @Override
+       public MAPExtensionContainer getExtensionContainer() {
+               return this.extensionContainer;
+       }
+
+       @Override
+       public String toString() {
+               //TODO: Implements this
+               return super.toString();
+       }
+
+}
+
=======================================
--- /dev/null
+++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/imei/RequestedEquipmentInfoImpl.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,103 @@
+package org.mobicents.protocols.ss7.map.service.mobility.imei;
+
+import java.io.IOException;
+
+import org.mobicents.protocols.asn.AsnException;
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.BitSetStrictLength;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.map.api.MAPException;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentException;
+import org.mobicents.protocols.ss7.map.api.MAPParsingComponentExceptionReason; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.RequestedEquipmentInfo;
+
+public class RequestedEquipmentInfoImpl implements RequestedEquipmentInfo {
+
+       private BitSetStrictLength bitString = new BitSetStrictLength(2);
+
+       @Override
+       public boolean getEquipmentStatus() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       @Override
+       public boolean getBmuef() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public int getTag() throws MAPException {
+               return Tag.STRING_BIT;
+       }
+
+       public int getTagClass() {
+               return Tag.CLASS_UNIVERSAL;
+       }
+
+       public boolean getIsPrimitive() {
+               return true;
+       }
+
+ public void decodeAll(AsnInputStream ansIS) throws MAPParsingComponentException {
+               try {
+                       int length = ansIS.readLength();
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding MWStatus: " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding MWStatus: " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+ public void decodeData(AsnInputStream ansIS, int length) throws MAPParsingComponentException {
+               try {
+                       this._decode(ansIS, length);
+               } catch (IOException e) {
+ throw new MAPParsingComponentException("IOException when decoding MWStatus: " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               } catch (AsnException e) {
+ throw new MAPParsingComponentException("AsnException when decoding MWStatus: " + e.getMessage(), e,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+               }
+       }
+
+ private void _decode(AsnInputStream ansIS, int length) throws MAPParsingComponentException, IOException, AsnException {
+               //TODO: I should understand what this mean
+               if (length == 0 || length > 4)
+ throw new MAPParsingComponentException("Error decoding RequestedEquipmentInfoImpl: the RequestedEquipmentInfoImpl field must contain from 1 or 4 octets. Contains: " + length,
+                                       
MAPParsingComponentExceptionReason.MistypedParameter);
+
+               this.bitString = ansIS.readBitStringData(length);
+       }
+
+       public void encodeAll(AsnOutputStream asnOs) throws MAPException {
+               this.encodeAll(asnOs, Tag.CLASS_UNIVERSAL, Tag.STRING_BIT);
+       }
+
+ public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws MAPException {
+               try {
+                       asnOs.writeTag(tagClass, true, tag);
+                       int pos = asnOs.StartContentDefiniteLength();
+                       this.encodeData(asnOs);
+                       asnOs.FinalizeContent(pos);
+               } catch (AsnException e) { //TODO: What is the MWStatus?
+ throw new MAPException("AsnException when encoding MWStatus: " + e.getMessage(), e);
+               }
+       }
+
+       public void encodeData(AsnOutputStream asnOs) throws MAPException {
+               try {
+                       asnOs.writeBitStringData(this.bitString);
+               } catch (IOException e) {
+ throw new MAPException("IOException when encoding MWStatus: " + e.getMessage(), e);
+               } catch (AsnException e) {
+ throw new MAPException("AsnException when encoding MWStatus: " + e.getMessage(), e);
+               }
+       }
+
+
+}
=======================================
--- /dev/null
+++ /map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/mobility/imei/CheckImeiRequestTest.java Fri Jul 13 10:16:09 2012
@@ -0,0 +1,51 @@
+package org.mobicents.protocols.ss7.map.service.mobility.imei;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.ss7.map.primitives.IMEIImpl;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+/**
+ *
+ * @author normandes
+ *
+ */
+public class CheckImeiRequestTest {
+
+       // Real Trace
+       private byte[] getEncodedDataV2() {
+ return new byte[] { 0x04, 0x0A, 0x04, 0x08, 0x53, (byte) 0x97, 0x75, 0x40, 0x31, (byte) 0x93, (byte) 0x95, (byte) 0xF0 };
+       }
+
+       @Test(groups = { "functional.decode", "imei" })
+       public void testDecode() throws Exception {
+               byte[] rawData = getEncodedDataV2();
+               AsnInputStream asnIS = new AsnInputStream(rawData);
+
+               int tag = asnIS.readTag();
+               CheckImeiRequestImpl checkImeiImpl = new 
CheckImeiRequestImpl(2);
+               checkImeiImpl.decodeAll(asnIS);
+
+               assertEquals(checkImeiImpl.getIMEI().getIMEI(), 
"357957041339590");
+       }
+
+       @Test(groups = { "functional.encode", "imei" })
+       public void testEncode() throws Exception {
+               IMEIImpl imei = new IMEIImpl("357957041339590");
+ CheckImeiRequestImpl checkImei = new CheckImeiRequestImpl(2, imei, null, null);
+
+               AsnOutputStream asnOS = new AsnOutputStream();
+               checkImei.encodeAll(asnOS);
+
+               byte[] encodedData = asnOS.toByteArray();
+               byte[] rawData = getEncodedDataV2();
+               assertTrue(Arrays.equals(rawData, encodedData));
+
+       }
+
+}
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckIMEIRequest.java Wed Jul 11 06:13:11 2012
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * TeleStax, Open Source Cloud Communications  Copyright 2012.
- * and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.mobicents.protocols.ss7.map.api.service.mobility.imei;
-
-import org.mobicents.protocols.ss7.map.api.primitives.IMEI;
-import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; -import org.mobicents.protocols.ss7.map.api.service.mobility.MobilityMessage;
-
-/**
- *
-
-MAP V3:
-CheckIMEI-Arg ::= SEQUENCE {
-       imei                    IMEI,
-       requestedEquipmentInfo  RequestedEquipmentInfo,
-       extensionContainer      ExtensionContainer      OPTIONAL,
-       ...}
-
-MAP V2:
-ARGUMENT
-imei   IMEI
-
- *
- *
- * @author sergey vetyutnev
- *
- */
-public interface CheckIMEIRequest extends MobilityMessage {
-
-       public IMEI getImei();
-
-       public RequestedEquipmentInfo getRequestedEquipmentInfo();
-
-       public MAPExtensionContainer getExtensionContainer();
-
-}
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/CheckIMEIResponse.java Wed Jul 11 06:13:11 2012
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.mobicents.protocols.ss7.map.api.service.mobility.imei;
-
-import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer; -import org.mobicents.protocols.ss7.map.api.service.mobility.MobilityMessage;
-
-/**
- *
-
-MAP V3:
-CheckIMEI-Res ::= SEQUENCE {
-       equipmentStatus EquipmentStatus OPTIONAL,
-       bmuef           UESBI-Iu                OPTIONAL,
-       extensionContainer      [0] ExtensionContainer  OPTIONAL,
-       ...}
-
-MAP V2:
-RESULT
-equipmentStatus                EquipmentStatus
-
- *
- *
- * @author sergey vetyutnev
- *
- */
-public interface CheckIMEIResponse extends MobilityMessage {
-
-       public EquipmentStatus getEquipmentStatus();
-
-       public UESBIIu getBmuef();
-
-       public MAPExtensionContainer getExtensionContainer();
-
-}
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPMessageType.java Mon Jun 18 00:18:35 2012 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPMessageType.java Fri Jul 13 10:16:09 2012
@@ -37,6 +37,8 @@
        sendAuthenticationInfo_Response,
        updateLocation_Request,
        updateLocation_Response,
+       checkIMEI_Request,
+       checkIMEI_Response,

        // -- supplementary
        processUnstructuredSSRequest_Request,
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPDialogMobility.java Wed May 30 09:05:18 2012 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPDialogMobility.java Fri Jul 13 10:16:09 2012
@@ -25,6 +25,7 @@
 import org.mobicents.protocols.ss7.map.api.MAPDialog;
 import org.mobicents.protocols.ss7.map.api.MAPException;
 import org.mobicents.protocols.ss7.map.api.primitives.GSNAddress;
+import org.mobicents.protocols.ss7.map.api.primitives.IMEI;
 import org.mobicents.protocols.ss7.map.api.primitives.IMSI;
 import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 import org.mobicents.protocols.ss7.map.api.primitives.LMSI;
@@ -35,6 +36,7 @@
import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.EpsAuthenticationSetList; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.ReSynchronisationInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.RequestingNodeType; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.RequestedEquipmentInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.ADDInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.PagingArea; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.VlrCapability;
@@ -86,6 +88,10 @@
public long addAnyTimeInterrogationResponse(long invokeId) throws MAPException;

        // TODO: add service component adders
+
+       // -- International mobile equipment identities management services
+ public Long addCheckImeiRequest(IMEI imei, RequestedEquipmentInfo requestedEquipmentInfo, MAPExtensionContainer extensionContainer)
+                       throws MAPException;

 }

=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPServiceMobilityListener.java Wed May 30 09:05:18 2012 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/MAPServiceMobilityListener.java Fri Jul 13 10:16:09 2012
@@ -25,6 +25,8 @@
 import org.mobicents.protocols.ss7.map.api.MAPServiceListener;
import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.SendAuthenticationInfoRequest; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.SendAuthenticationInfoResponse; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiRequest; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiResponse; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.UpdateLocationRequest; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.UpdateLocationResponse; import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationRequest;
@@ -48,5 +50,9 @@
        // -- Subscriber Information services
public void onAnyTimeInterrogationRequest(AnyTimeInterrogationRequest request); public void onAnyTimeInterrogationResponse(AnyTimeInterrogationResponse response);
+
+       // -- International mobile equipment identities management services
+       public void onCheckImeiRequest(CheckImeiRequest request);
+       public void onCheckImeiResponse(CheckImeiResponse response);

 }
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/EquipmentStatus.java Wed Jul 11 06:13:11 2012 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/EquipmentStatus.java Fri Jul 13 10:16:09 2012
@@ -24,42 +24,40 @@

 /**
  *
-
-EquipmentStatus ::= ENUMERATED {
-       whiteListed  (0),
-       blackListed  (1),
-       greyListed  (2)}
-
+ * EquipmentStatus ::= ENUMERATED {
+ *             whiteListed             (0),
+ *             blackListed             (1),
+ *             greyListed                      (2) }
  *
- * @author sergey vetyutnev
- *
+ * @author normandes
+ *
  */
 public enum EquipmentStatus {
-       whiteListed(0),
-       blackListed(1),
-       greyListed(2);
-
+
+       whiteListed(0),
+       blackListed(1),
+       greyListed(2);
+
        private int code;
-
+
        private EquipmentStatus(int code) {
                this.code = code;
        }
-
-       public int getCode() {
-               return this.code;
-       }
-
+
        public static EquipmentStatus getInstance(int code) {
                switch (code) {
                case 0:
-                       return EquipmentStatus.whiteListed;
+                       return whiteListed;
                case 1:
-                       return EquipmentStatus.blackListed;
+                       return blackListed;
                case 2:
-                       return EquipmentStatus.greyListed;
+                       return greyListed;
                default:
                        return null;
                }
        }

-}
+       public int getCode() {
+               return code;
+       }
+}
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/RequestedEquipmentInfo.java Wed Jul 11 06:13:11 2012 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/service/mobility/imei/RequestedEquipmentInfo.java Fri Jul 13 10:16:09 2012
@@ -22,24 +22,22 @@

 package org.mobicents.protocols.ss7.map.api.service.mobility.imei;

+import java.io.Serializable;
+
 /**
+ * RequestedEquipmentInfo::= BIT STRING {
+ *             equipmentStatus                         (0),
+ *             bmuef                                           (1)} (SIZE 
(2..8))
+ * -- exception handling: reception of unknown bit assignments in the
+ * -- RequestedEquipmentInfo data type shall be discarded by the receiver
  *
-
-RequestedEquipmentInfo::= BIT STRING {
-       equipmentStatus  (0),
-       bmuef  (1)} (SIZE (2..8))
-       -- exception handling: reception of unknown bit assignments in the
-       -- RequestedEquipmentInfo data type shall be discarded by the receiver
-
- *
- *
- * @author sergey vetyutnev
- *
+ * @author normandes
+ *
  */
-public interface RequestedEquipmentInfo {
+public interface RequestedEquipmentInfo extends Serializable {

        public boolean getEquipmentStatus();
-
+
        public boolean getBmuef();
-
-}
+
+}
=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPDialogMobilityImpl.java Wed May 30 09:05:18 2012 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPDialogMobilityImpl.java Fri Jul 13 10:16:09 2012
@@ -32,6 +32,7 @@
 import org.mobicents.protocols.ss7.map.api.MAPOperationCode;
 import org.mobicents.protocols.ss7.map.api.primitives.AddressString;
 import org.mobicents.protocols.ss7.map.api.primitives.GSNAddress;
+import org.mobicents.protocols.ss7.map.api.primitives.IMEI;
 import org.mobicents.protocols.ss7.map.api.primitives.IMSI;
 import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 import org.mobicents.protocols.ss7.map.api.primitives.LMSI;
@@ -44,6 +45,7 @@
import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.EpsAuthenticationSetList; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.ReSynchronisationInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.RequestingNodeType; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.RequestedEquipmentInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.ADDInfo; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.PagingArea; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.VlrCapability;
@@ -336,6 +338,20 @@
                // TODO Auto-generated method stub
                throw new MAPException("We dont support this yet");
        }
+
+
+       @Override
+ public Long addCheckImeiRequest(IMEI imei, RequestedEquipmentInfo requestedEquipmentInfo,
+                       MAPExtensionContainer extensionContainer) throws 
MAPException {
+
+ if ((this.appCntx.getApplicationContextName() != MAPApplicationContextName.equipmentMngtContext) + || (this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version2 + && this.appCntx.getApplicationContextVersion() != MAPApplicationContextVersion.version3)) { + throw new MAPException("Bad application context name for CheckImeiRequest: must be equipmentMngtContext_V2 or V3");
+               }
+
+               return null;
+       }

 }

=======================================
--- /map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/EventTestHarness.java Sun Jun 3 10:10:08 2012 +++ /map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/functional/EventTestHarness.java Fri Jul 13 10:16:09 2012
@@ -23,6 +23,8 @@
import org.mobicents.protocols.ss7.map.api.service.mobility.MAPServiceMobilityListener; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.SendAuthenticationInfoRequest; import org.mobicents.protocols.ss7.map.api.service.mobility.authentication.SendAuthenticationInfoResponse; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiRequest; +import org.mobicents.protocols.ss7.map.api.service.mobility.imei.CheckImeiResponse; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.UpdateLocationRequest; import org.mobicents.protocols.ss7.map.api.service.mobility.locationManagement.UpdateLocationResponse; import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.AnyTimeInterrogationRequest;
@@ -381,5 +383,17 @@
                // TODO Auto-generated method stub

        }
+
+       @Override
+       public void onCheckImeiRequest(CheckImeiRequest request) {
+               // TODO Auto-generated method stub
+
+       }
+
+       @Override
+       public void onCheckImeiResponse(CheckImeiResponse response) {
+               // TODO Auto-generated method stub
+
+       }
 }

Reply via email to