Revision: e6cf82d51110
Author:   Sergey Vetyutnev <[email protected]>
Date:     Mon Jun  3 09:03:39 2013
Log:      TCAP dialog predefined local TransactionId
http://code.google.com/p/jss7/source/detail?r=e6cf82d51110

Added:
/tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/CreateDialogTest.java
Modified:
/cap/cap-api/src/main/java/org/mobicents/protocols/ss7/cap/api/CAPServiceBase.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/CAPServiceBaseImpl.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/CAPServiceCircuitSwitchedCallImpl.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/gprs/CAPServiceGprsImpl.java /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/sms/CAPServiceSmsImpl.java /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPServiceBase.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/MAPServiceBaseImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/callhandling/MAPServiceCallHandlingImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/lsm/MAPServiceLsmImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPServiceMobilityImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/oam/MAPServiceOamImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/pdpContextActivation/MAPServicePdpContextActivationImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/sms/MAPServiceSmsImpl.java /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/supplementary/MAPServiceSupplementaryImpl.java /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPProvider.java /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java

=======================================
--- /dev/null
+++ /tcap/tcap-impl/src/test/java/org/mobicents/protocols/ss7/tcap/CreateDialogTest.java Mon Jun 3 09:03:39 2013
@@ -0,0 +1,162 @@
+/*
+ * 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.tcap;
+
+import static org.testng.Assert.*;
+
+import java.io.IOException;
+
+import org.mobicents.protocols.ss7.sccp.SccpListener;
+import org.mobicents.protocols.ss7.sccp.SccpManagementEventListener;
+import org.mobicents.protocols.ss7.sccp.SccpProvider;
+import org.mobicents.protocols.ss7.sccp.message.MessageFactory;
+import org.mobicents.protocols.ss7.sccp.message.SccpDataMessage;
+import org.mobicents.protocols.ss7.sccp.parameter.ParameterFactory;
+import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
+import org.mobicents.protocols.ss7.tcap.api.tc.dialog.Dialog;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+*
+* @author sergey vetyutnev
+*
+*/
+public class CreateDialogTest {
+
+    private SccpHarnessPreview sccpProv = new SccpHarnessPreview();
+    private TCAPStackImplWrapper tcapStack1;
+
+    @BeforeClass
+    public void setUpClass() {
+        System.out.println("setUpClass");
+    }
+
+    @AfterClass
+    public void tearDownClass() throws Exception {
+        System.out.println("tearDownClass");
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see junit.framework.TestCase#setUp()
+     */
+    @BeforeMethod
+    public void setUp() throws Exception {
+        System.out.println("setUp");
+
+        this.tcapStack1 = new TCAPStackImplWrapper(this.sccpProv, 8);
+
+        this.tcapStack1.start();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see junit.framework.TestCase#tearDown()
+     */
+    @AfterMethod
+    public void tearDown() {
+        this.tcapStack1.stop();
+    }
+
+    @Test(groups = { "functional.flow" })
+    public void createDialogTest() throws Exception {
+
+        SccpAddress localAddress = new SccpAddress();
+        SccpAddress remoteAddress = new SccpAddress();
+
+ Dialog dlg1 = this.tcapStack1.getProvider().getNewDialog(localAddress, remoteAddress);
+        assertEquals((long) dlg1.getLocalDialogId(), 1L);
+
+        try {
+ Dialog dlg2 = this.tcapStack1.getProvider().getNewDialog(localAddress, remoteAddress, 1L);
+            fail("Must be failure because dialogID==1 is busy");
+        } catch (Exception e) {
+        }
+
+ Dialog dlg3 = this.tcapStack1.getProvider().getNewDialog(localAddress, remoteAddress, 2L);
+        assertEquals((long) dlg3.getLocalDialogId(), 2L);
+
+ Dialog dlg4 = this.tcapStack1.getProvider().getNewDialog(localAddress, remoteAddress);
+        assertEquals((long) dlg4.getLocalDialogId(), 3L);
+    }
+
+    private class SccpHarnessPreview implements SccpProvider {
+
+        @Override
+        public void deregisterSccpListener(int arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+ public int getMaxUserDataLength(SccpAddress arg0, SccpAddress arg1) {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        @Override
+        public MessageFactory getMessageFactory() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public ParameterFactory getParameterFactory() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        protected SccpListener sccpListener;
+
+        @Override
+        public void registerSccpListener(int arg0, SccpListener listener) {
+            sccpListener = listener;
+        }
+
+        @Override
+        public void send(SccpDataMessage msg) throws IOException {
+            // we check here that no messages go from TCAP previewMode
+
+            fail("No message must go from TCAP previewMode");
+        }
+
+        @Override
+ public void registerManagementEventListener(SccpManagementEventListener listener) {
+            // TODO Auto-generated method stub
+
+        }
+
+        @Override
+ public void deregisterManagementEventListener(SccpManagementEventListener listener) {
+            // TODO Auto-generated method stub
+
+        }
+    }
+
+}
=======================================
--- /cap/cap-api/src/main/java/org/mobicents/protocols/ss7/cap/api/CAPServiceBase.java Mon May 20 13:09:00 2013 +++ /cap/cap-api/src/main/java/org/mobicents/protocols/ss7/cap/api/CAPServiceBase.java Mon Jun 3 09:03:39 2013
@@ -1,6 +1,6 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2012, Telestax Inc and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -54,6 +54,14 @@
CAPDialog createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress)
             throws CAPException;

+    /**
+     * Create new structured dialog with predefined local TransactionId.
+ * We do not normally invoke this method. Use it only when you need this and only this local TransactionId + * (for example if we need of recreating a Dialog for which a peer already has in memory) + * If a Dialog with local TransactionId is already present there will be CAPException
+     */
+ CAPDialog createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId) throws CAPException;
+
     /**
* Returns true if the service can perform dialogs with given ApplicationContext
      */
=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/CAPServiceBaseImpl.java Mon May 20 13:09:00 2013 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/CAPServiceBaseImpl.java Mon Jun 3 09:03:39 2013
@@ -79,9 +79,9 @@
      * @return
      * @throws CAPException
      */
- protected Dialog createNewTCAPDialog(SccpAddress origAddress, SccpAddress destAddress) throws CAPException { + protected Dialog createNewTCAPDialog(SccpAddress origAddress, SccpAddress destAddress, Long localTrId) throws CAPException {
         try {
- return this.capProviderImpl.getTCAPProvider().getNewDialog(origAddress, destAddress); + return this.capProviderImpl.getTCAPProvider().getNewDialog(origAddress, destAddress, localTrId);
         } catch (TCAPException e) {
             throw new CAPException(e.getMessage(), e);
         }
=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/CAPServiceCircuitSwitchedCallImpl.java Mon May 20 13:09:00 2013 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/CAPServiceCircuitSwitchedCallImpl.java Mon Jun 3 09:03:39 2013
@@ -62,15 +62,20 @@
     }

     @Override
- public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress,
-            SccpAddress destAddress) throws CAPException {
+ public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress) throws CAPException { + return this.createNewDialog(appCntx, origAddress, destAddress, null);
+    }
+
+    @Override
+ public CAPDialogCircuitSwitchedCall createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId)
+            throws CAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
             throw new CAPException(
"Cannot create CAPDialogCircuitSwitchedCall because CAPServiceCircuitSwitchedCall is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); CAPDialogCircuitSwitchedCallImpl dialog = new CAPDialogCircuitSwitchedCallImpl(appCntx, tcapDialog,
                 this.capProviderImpl, this);

=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/gprs/CAPServiceGprsImpl.java Mon May 20 13:09:00 2013 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/gprs/CAPServiceGprsImpl.java Mon Jun 3 09:03:39 2013
@@ -62,14 +62,18 @@
     }

     @Override
- public CAPDialogGprs createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress)
-            throws CAPException {
+ public CAPDialogGprs createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress) throws CAPException { + return this.createNewDialog(appCntx, origAddress, destAddress, null);
+    }
+
+    @Override
+ public CAPDialogGprs createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId) throws CAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new CAPException("Cannot create CAPDialogGprs because CAPServiceGprsl is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); CAPDialogGprsImpl dialog = new CAPDialogGprsImpl(appCntx, tcapDialog, this.capProviderImpl, this);

         this.putCAPDialogIntoCollection(dialog);
=======================================
--- /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/sms/CAPServiceSmsImpl.java Mon May 20 13:09:00 2013 +++ /cap/cap-impl/src/main/java/org/mobicents/protocols/ss7/cap/service/sms/CAPServiceSmsImpl.java Mon Jun 3 09:03:39 2013
@@ -57,14 +57,18 @@
     }

     @Override
- public CAPDialogSms createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress)
-            throws CAPException {
+ public CAPDialogSms createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress) throws CAPException { + return this.createNewDialog(appCntx, origAddress, destAddress, null);
+    }
+
+    @Override
+ public CAPDialogSms createNewDialog(CAPApplicationContext appCntx, SccpAddress origAddress, SccpAddress destAddress, Long localTrId) throws CAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new CAPException("Cannot create CAPDialogSms because CAPServiceSms is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); CAPDialogSmsImpl dialog = new CAPDialogSmsImpl(appCntx, tcapDialog, this.capProviderImpl, this);

         this.putCAPDialogIntoCollection(dialog);
=======================================
--- /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPServiceBase.java Mon May 20 13:09:00 2013 +++ /map/map-api/src/main/java/org/mobicents/protocols/ss7/map/api/MAPServiceBase.java Mon Jun 3 09:03:39 2013
@@ -1,6 +1,6 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2012, Telestax Inc and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -62,6 +62,15 @@
MAPDialog createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException;

+    /**
+     * Create new structured dialog with predefined local TransactionId.
+ * We do not normally invoke this method. Use it only when you need this and only this local TransactionId + * (for example if we need of recreating a Dialog for which a peer already has in memory) + * If a Dialog with local TransactionId is already present there will be MAPException
+     */
+ MAPDialog createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, + SccpAddress destAddress, AddressString destReference, Long localTrId) throws MAPException;
+
     /**
* Returns true if the service can perform dialogs with given ApplicationContext
      */
=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/MAPServiceBaseImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/MAPServiceBaseImpl.java Mon Jun 3 09:03:39 2013
@@ -79,9 +79,9 @@
      * @return
      * @throws MAPException
      */
- protected Dialog createNewTCAPDialog(SccpAddress origAddress, SccpAddress destAddress) throws MAPException { + protected Dialog createNewTCAPDialog(SccpAddress origAddress, SccpAddress destAddress, Long localTrId) throws MAPException {
         try {
- return this.mapProviderImpl.getTCAPProvider().getNewDialog(origAddress, destAddress); + return this.mapProviderImpl.getTCAPProvider().getNewDialog(origAddress, destAddress, localTrId);
         } catch (TCAPException e) {
             throw new MAPException(e.getMessage(), e);
         }
=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/callhandling/MAPServiceCallHandlingImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/callhandling/MAPServiceCallHandlingImpl.java Mon Jun 3 09:03:39 2013
@@ -71,15 +71,21 @@
     }

     @Override
- public MAPDialogCallHandling createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, - AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogCallHandling createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
+            AddressString destReference) throws MAPException {
+ return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+    @Override
+ public MAPDialogCallHandling createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, + AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
             throw new MAPException(
"Cannot create MAPDialogRoutingInformation because MAPServiceRoutingInformation is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogCallHandlingImpl dialog = new MAPDialogCallHandlingImpl(appCntx, tcapDialog, this.mapProviderImpl, this,
                 origReference, destReference);

=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/lsm/MAPServiceLsmImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/lsm/MAPServiceLsmImpl.java Mon Jun 3 09:03:39 2013
@@ -73,11 +73,16 @@
      */
public MAPDialogLsm createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException { + return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogLsm createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, + SccpAddress destAddress, AddressString destReference, Long localTrId) throws MAPException {
         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new MAPException("Cannot create MAPDialogLsm because MAPServiceLsm is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId);

MAPDialogLsmImpl dialog = new MAPDialogLsmImpl(appCntx, tcapDialog, this.mapProviderImpl, this, origReference,
                 destReference);
=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPServiceMobilityImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/mobility/MAPServiceMobilityImpl.java Mon Jun 3 09:03:39 2013
@@ -85,14 +85,19 @@
     /*
* Creating a new outgoing MAP Mobility dialog and adding it to the MAPProvider.dialog collection
      */
- public MAPDialogMobility createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, - AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogMobility createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
+            AddressString destReference) throws MAPException {
+ return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogMobility createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, + AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new MAPException("Cannot create MAPDialogMobility because MAPServiceMobility is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogMobilityImpl dialog = new MAPDialogMobilityImpl(appCntx, tcapDialog, this.mapProviderImpl, this,
                 origReference, destReference);

=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/oam/MAPServiceOamImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/oam/MAPServiceOamImpl.java Mon Jun 3 09:03:39 2013
@@ -60,14 +60,19 @@
     /*
* Creating a new outgoing MAP OAM dialog and adding it to the MAPProvider.dialog collection
      */
- public MAPDialogOam createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, - SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogOam createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
+            AddressString destReference) throws MAPException {
+ return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogOam createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, + AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new MAPException("Cannot create MAPDialogOam because MAPServiceOam is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogOamImpl dialog = new MAPDialogOamImpl(appCntx, tcapDialog, this.mapProviderImpl, this, origReference,
                 destReference);

=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/pdpContextActivation/MAPServicePdpContextActivationImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/pdpContextActivation/MAPServicePdpContextActivationImpl.java Mon Jun 3 09:03:39 2013
@@ -60,15 +60,20 @@
     /*
* Creating a new outgoing MAP PdpContextActivation dialog and adding it to the MAPProvider.dialog collection
      */
- public MAPDialogPdpContextActivation createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, - AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogPdpContextActivation createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, + SccpAddress destAddress, AddressString destReference) throws MAPException { + return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogPdpContextActivation createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, + SccpAddress destAddress, AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
             throw new MAPException(
"Cannot create MAPDialogPdpContextActivation because MAPServicePdpContextActivation is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogPdpContextActivationImpl dialog = new MAPDialogPdpContextActivationImpl(appCntx, tcapDialog,
                 this.mapProviderImpl, this, origReference, destReference);

=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/sms/MAPServiceSmsImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/sms/MAPServiceSmsImpl.java Mon Jun 3 09:03:39 2013
@@ -69,14 +69,19 @@
     /*
* Creating a new outgoing MAP SMS dialog and adding it to the MAPProvider.dialog collection
      */
- public MAPDialogSms createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, - SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogSms createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
+            AddressString destReference) throws MAPException {
+ return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogSms createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, + AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new MAPException("Cannot create MAPDialogSms because MAPServiceSms is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogSmsImpl dialog = new MAPDialogSmsImpl(appCntx, tcapDialog, this.mapProviderImpl, this, origReference,
                 destReference);

=======================================
--- /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/supplementary/MAPServiceSupplementaryImpl.java Mon May 20 13:09:00 2013 +++ /map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/service/supplementary/MAPServiceSupplementaryImpl.java Mon Jun 3 09:03:39 2013
@@ -72,14 +72,19 @@
* Creating a new outgoing MAP Supplementary dialog and adding it to the MAPProvider.dialog collection
      *
      */
- public MAPDialogSupplementary createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, - AddressString origReference, SccpAddress destAddress, AddressString destReference) throws MAPException { + public MAPDialogSupplementary createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress,
+            AddressString destReference) throws MAPException {
+ return this.createNewDialog(appCntx, origAddress, origReference, destAddress, destReference, null);
+    }
+
+ public MAPDialogSupplementary createNewDialog(MAPApplicationContext appCntx, SccpAddress origAddress, AddressString origReference, SccpAddress destAddress, + AddressString destReference, Long localTrId) throws MAPException {

         // We cannot create a dialog if the service is not activated
         if (!this.isActivated())
throw new MAPException("Cannot create MAPDialogSupplementary because MAPServiceSupplementary is not activated");

- Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress); + Dialog tcapDialog = this.createNewTCAPDialog(origAddress, destAddress, localTrId); MAPDialogSupplementaryImpl dialog = new MAPDialogSupplementaryImpl(appCntx, tcapDialog, this.mapProviderImpl, this,
                 origReference, destReference);

=======================================
--- /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPProvider.java Mon May 20 13:09:00 2013 +++ /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPProvider.java Mon Jun 3 09:03:39 2013
@@ -43,6 +43,19 @@
      */
Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress) throws TCAPException;

+    /**
+     * Create new structured dialog with predefined local TransactionId.
+ * We do not normally invoke this method. Use it only when you need this and only this local TransactionId + * (for example if we need of recreating a Dialog for which a peer already has in memory) + * If a Dialog with local TransactionId is already present there will be TCAPException
+     *
+     * @param localAddress - desired local address
+ * @param remoteAddress - initial remote address, it can change after first TCContinue.
+     * @param localTrId - predefined local TransactionId
+     * @return
+     */
+ Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress, Long localTrId) throws TCAPException;
+
     /**
      * Create new unstructured dialog.
      *
=======================================
--- /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Sun May 26 11:19:06 2013 +++ /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Mon Jun 3 09:03:39 2013
@@ -153,6 +153,13 @@
         this.tcListeners.remove(lst);

     }
+
+    private boolean checkAvailableTxId(Long id) {
+        if (!this.dialogs.containsKey(id))
+            return true;
+        else
+            return false;
+    }

     // some help methods... crude but will work for first impl.
     private Long getAvailableTxId() throws TCAPException {
@@ -165,7 +172,7 @@
             if (++this.curDialogId > this.stack.getDialogIdRangeEnd())
                 this.curDialogId = this.stack.getDialogIdRangeStart();
             Long id = this.curDialogId;
-            if (!this.dialogs.containsKey(id))
+            if (checkAvailableTxId(id))
                 return id;
         }
     }
@@ -207,7 +214,17 @@
* .protocols.ss7.sccp.parameter.SccpAddress, org.mobicents.protocols.ss7.sccp.parameter.SccpAddress)
      */
public Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress) throws TCAPException { - return getNewDialog(localAddress, remoteAddress, getNextSeqControl()); + return getNewDialog(localAddress, remoteAddress, getNextSeqControl(), null);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+ * @see org.mobicents.protocols.ss7.tcap.api.TCAPProvider#getNewDialog(org.mobicents + * .protocols.ss7.sccp.parameter.SccpAddress, org.mobicents.protocols.ss7.sccp.parameter.SccpAddress, Long id)
+     */
+ public Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress, Long id) throws TCAPException { + return getNewDialog(localAddress, remoteAddress, getNextSeqControl(), id);
     }

     /*
@@ -217,14 +234,14 @@
* (org.mobicents.protocols.ss7.sccp.parameter.SccpAddress, org.mobicents.protocols.ss7.sccp.parameter.SccpAddress)
      */
public Dialog getNewUnstructuredDialog(SccpAddress localAddress, SccpAddress remoteAddress) throws TCAPException { - return _getDialog(localAddress, remoteAddress, false, getNextSeqControl()); + return _getDialog(localAddress, remoteAddress, false, getNextSeqControl(), null);
     }

- private Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress, int seqControl) throws TCAPException {
-        return _getDialog(localAddress, remoteAddress, true, seqControl);
+ private Dialog getNewDialog(SccpAddress localAddress, SccpAddress remoteAddress, int seqControl, Long id) throws TCAPException { + return _getDialog(localAddress, remoteAddress, true, seqControl, id);
     }

- private Dialog _getDialog(SccpAddress localAddress, SccpAddress remoteAddress, boolean structured, int seqControl) + private Dialog _getDialog(SccpAddress localAddress, SccpAddress remoteAddress, boolean structured, int seqControl, Long id)
             throws TCAPException {

         if (this.stack.getPreviewMode()) {
@@ -236,7 +253,13 @@
         }

         synchronized (this.dialogs) {
-            Long id = this.getAvailableTxId();
+            if (id == null) {
+                id = this.getAvailableTxId();
+            } else {
+                if (!checkAvailableTxId(id)) {
+ throw new TCAPException("Suggested local TransactionId is already present in system: " + id);
+                }
+            }
             if (structured) {
DialogImpl di = new DialogImpl(localAddress, remoteAddress, id, structured, this._EXECUTOR, this, seqControl, this.stack.getPreviewMode());

@@ -622,7 +645,7 @@
                                     .getSubsystemNumber(), dId);
di = (DialogImpl) this.createPreviewDialog(ky, localAddress, remoteAddress, seqControl);
                         } else {
- di = (DialogImpl) this.getNewDialog(localAddress, remoteAddress, message.getSls()); + di = (DialogImpl) this.getNewDialog(localAddress, remoteAddress, message.getSls(), null);
                         }

                     } catch (TCAPException e) {

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to