Skip to content

Commit 580496e

Browse files
author
Maria Farooq
committed
tha patch
1 parent 7673442 commit 580496e

3 files changed

Lines changed: 384 additions & 17 deletions

File tree

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/SIPOrganizationUtil.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
package org.restcomm.connect.interpreter;
2121

22+
import javax.servlet.sip.Address;
23+
import javax.servlet.sip.ServletParseException;
2224
import javax.servlet.sip.SipServletRequest;
2325
import javax.servlet.sip.SipURI;
2426
import org.apache.log4j.Logger;
@@ -50,6 +52,18 @@ public static Sid searchOrganizationBySIPRequest(OrganizationsDao orgDao, SipSer
5052
// try to get destinationOrganizationSid from toUri
5153
destinationOrganizationSid = getOrganizationSidBySipURIHost(orgDao, (SipURI) request.getTo().getURI());
5254
}
55+
if (destinationOrganizationSid == null) {
56+
// try to get destinationOrganizationSid from Refer-To
57+
Address referAddress;
58+
try {
59+
referAddress = request.getAddressHeader("Refer-To");
60+
if(referAddress != null){
61+
destinationOrganizationSid = getOrganizationSidBySipURIHost(orgDao, (SipURI) referAddress.getURI());
62+
}
63+
} catch (ServletParseException e) {
64+
logger.error(e);
65+
}
66+
}
5367
return destinationOrganizationSid;
5468
}
5569
}

restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ReferOrganizationTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void testTransfer() throws ParseException, InterruptedException, Malforme
199199
.withBody(dialAliceRcml)));
200200

201201
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
202-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
202+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
203203
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
204204
alicePhone.addUpdateCredential(c);
205205

@@ -239,7 +239,7 @@ public void testTransfer() throws ParseException, InterruptedException, Malforme
239239
null, null));
240240
assertTrue(georgeCall.waitForAck(5000));
241241

242-
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "127.0.0.1:5080");
242+
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "refertest.restcomm.com");
243243

244244
ReferSubscriber subscription = georgePhone.refer(georgeCall.getDialog(), referTo, null, 5000);
245245
assertNotNull(subscription);
@@ -336,7 +336,7 @@ public void testTransferToAnyNumber() throws ParseException, InterruptedExceptio
336336
.withBody(dialAliceRcml)));
337337

338338
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
339-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
339+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
340340
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
341341
alicePhone.addUpdateCredential(c);
342342

@@ -348,7 +348,7 @@ public void testTransferToAnyNumber() throws ParseException, InterruptedExceptio
348348

349349
final SipCall bobCall = bobPhone.createSipCall();
350350

351-
bobCall.initiateOutgoingCall(bobContact, "sip:0545@127.0.0.1:5080", null, body, "application", "sdp", null, null);
351+
bobCall.initiateOutgoingCall(bobContact, "sip:0545@refertest.restcomm.com", null, body, "application", "sdp", null, null);
352352

353353
assertLastOperationSuccess(bobCall);
354354
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -376,7 +376,7 @@ public void testTransferToAnyNumber() throws ParseException, InterruptedExceptio
376376
null, null));
377377
assertTrue(georgeCall.waitForAck(5000));
378378

379-
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "127.0.0.1:5080");
379+
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "refertest.restcomm.com");
380380

381381
ReferSubscriber subscription = georgePhone.refer(georgeCall.getDialog(), referTo, null, 5000);
382382
assertNotNull(subscription);
@@ -464,7 +464,7 @@ public void testTransferToNumberWithPlusSign() throws ParseException, Interrupte
464464
.withBody(dialAliceRcml)));
465465

466466
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
467-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
467+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
468468
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
469469
alicePhone.addUpdateCredential(c);
470470

@@ -476,7 +476,7 @@ public void testTransferToNumberWithPlusSign() throws ParseException, Interrupte
476476

477477
final SipCall bobCall = bobPhone.createSipCall();
478478

479-
bobCall.initiateOutgoingCall(bobContact, "sip:1112@127.0.0.1:5080", null, body, "application", "sdp", null, null);
479+
bobCall.initiateOutgoingCall(bobContact, "sip:1112@refertest.restcomm.com", null, body, "application", "sdp", null, null);
480480

481481
assertLastOperationSuccess(bobCall);
482482
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -504,7 +504,7 @@ public void testTransferToNumberWithPlusSign() throws ParseException, Interrupte
504504
null, null));
505505
assertTrue(georgeCall.waitForAck(5000));
506506

507-
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "127.0.0.1:5080");
507+
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "refertest.restcomm.com");
508508

509509
ReferSubscriber subscription = georgePhone.refer(georgeCall.getDialog(), referTo, null, 5000);
510510
assertNotNull(subscription);
@@ -593,7 +593,7 @@ public void testTransferHangupByBob() throws ParseException, InterruptedExceptio
593593
.withBody(dialAliceRcml)));
594594

595595
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
596-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
596+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
597597
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
598598
alicePhone.addUpdateCredential(c);
599599

@@ -633,7 +633,7 @@ public void testTransferHangupByBob() throws ParseException, InterruptedExceptio
633633
null, null));
634634
assertTrue(georgeCall.waitForAck(5000));
635635

636-
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "127.0.0.1:5080");
636+
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("alice", "refertest.restcomm.com");
637637

638638
ReferSubscriber subscription = georgePhone.refer(georgeCall.getDialog(), referTo, null, 5000);
639639
assertNotNull(subscription);
@@ -721,7 +721,7 @@ public void testTransferByBob() throws ParseException, InterruptedException, Mal
721721
.withBody(dialAliceRcml)));
722722

723723
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
724-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
724+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
725725
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
726726
alicePhone.addUpdateCredential(c);
727727

@@ -850,7 +850,7 @@ public void testTransferWithAbsentReferUrlAndApplication() throws ParseException
850850
.withBody(dialAliceRcml)));
851851

852852
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
853-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
853+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
854854
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
855855
alicePhone.addUpdateCredential(c);
856856

@@ -862,7 +862,7 @@ public void testTransferWithAbsentReferUrlAndApplication() throws ParseException
862862

863863
final SipCall bobCall = bobPhone.createSipCall();
864864

865-
bobCall.initiateOutgoingCall(bobContact, "sip:1212@127.0.0.1:5080", null, body, "application", "sdp", null, null);
865+
bobCall.initiateOutgoingCall(bobContact, "sip:1212@refertest.restcomm.com", null, body, "application", "sdp", null, null);
866866

867867
assertLastOperationSuccess(bobCall);
868868
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -915,7 +915,7 @@ public void testTransferWithOutOfDialogRefer() throws ParseException, Interrupte
915915
.withBody(dialAliceRcml)));
916916

917917
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
918-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
918+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
919919
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
920920
alicePhone.addUpdateCredential(c);
921921

@@ -982,7 +982,7 @@ public void testTransferIncorrectReferTarget() throws ParseException, Interrupte
982982
.withBody(dialJoeRcml)));
983983

984984
SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
985-
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
985+
assertTrue(alicePhone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5091", 3600, 3600));
986986
Credential c = new Credential("refertest.restcomm.com", "alice", clientPassword );
987987
alicePhone.addUpdateCredential(c);
988988

@@ -1025,7 +1025,7 @@ public void testTransferIncorrectReferTarget() throws ParseException, Interrupte
10251025
georgeCall.listenForDisconnect();
10261026
bobCall.listenForDisconnect();
10271027

1028-
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("joe", "127.0.0.1:5080");
1028+
SipURI referTo = georgeSipStack.getAddressFactory().createSipURI("joe", "refertest.restcomm.com");
10291029
georgePhone.refer(georgeCall.getDialog(), referTo, null, 5000);
10301030

10311031
assertTrue(georgeCall.waitForDisconnect(5000));
@@ -1051,7 +1051,7 @@ public static WebArchive createWebArchiveNoGw() {
10511051
archive.delete("/WEB-INF/classes/application.conf");
10521052
archive.addAsWebInfResource("sip.xml");
10531053
archive.addAsWebInfResource("web.xml");
1054-
archive.addAsWebInfResource("restcomm_calllifecycle.xml", "conf/restcomm.xml");
1054+
archive.addAsWebInfResource("restcomm_referorg.xml", "conf/restcomm.xml");
10551055
archive.addAsWebInfResource("restcomm.script_ReferMessageOrgTest", "data/hsql/restcomm.script");
10561056
archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
10571057
logger.info("Packaged Test App");

0 commit comments

Comments
 (0)