Skip to content

Commit

Permalink
tha patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Farooq committed Apr 18, 2018
1 parent 05c005a commit 7846196
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 17 deletions.
Expand Up @@ -19,6 +19,8 @@
*/
package org.restcomm.connect.interpreter;

import javax.servlet.sip.Address;
import javax.servlet.sip.ServletParseException;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipURI;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -50,6 +52,18 @@ public static Sid searchOrganizationBySIPRequest(OrganizationsDao orgDao, SipSer
// try to get destinationOrganizationSid from toUri
destinationOrganizationSid = getOrganizationSidBySipURIHost(orgDao, (SipURI) request.getTo().getURI());
}
if (destinationOrganizationSid == null) {
// try to get destinationOrganizationSid from Refer-To
Address referAddress;
try {
referAddress = request.getAddressHeader("Refer-To");
if(referAddress != null){
destinationOrganizationSid = getOrganizationSidBySipURIHost(orgDao, (SipURI) referAddress.getURI());
}
} catch (ServletParseException e) {
logger.error(e);
}
}
return destinationOrganizationSid;
}
}
Expand Up @@ -199,7 +199,7 @@ public void testTransfer() throws ParseException, InterruptedException, Malforme
.withBody(dialAliceRcml)));

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

Expand Down Expand Up @@ -239,7 +239,7 @@ public void testTransfer() throws ParseException, InterruptedException, Malforme
null, null));
assertTrue(georgeCall.waitForAck(5000));

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

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

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

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

final SipCall bobCall = bobPhone.createSipCall();

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

assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
Expand Down Expand Up @@ -376,7 +376,7 @@ public void testTransferToAnyNumber() throws ParseException, InterruptedExceptio
null, null));
assertTrue(georgeCall.waitForAck(5000));

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

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

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

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

final SipCall bobCall = bobPhone.createSipCall();

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

assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
Expand Down Expand Up @@ -504,7 +504,7 @@ public void testTransferToNumberWithPlusSign() throws ParseException, Interrupte
null, null));
assertTrue(georgeCall.waitForAck(5000));

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

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

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

Expand Down Expand Up @@ -633,7 +633,7 @@ public void testTransferHangupByBob() throws ParseException, InterruptedExceptio
null, null));
assertTrue(georgeCall.waitForAck(5000));

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

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

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

Expand Down Expand Up @@ -850,7 +850,7 @@ public void testTransferWithAbsentReferUrlAndApplication() throws ParseException
.withBody(dialAliceRcml)));

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

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

final SipCall bobCall = bobPhone.createSipCall();

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

assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
Expand Down Expand Up @@ -915,7 +915,7 @@ public void testTransferWithOutOfDialogRefer() throws ParseException, Interrupte
.withBody(dialAliceRcml)));

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

Expand Down Expand Up @@ -982,7 +982,7 @@ public void testTransferIncorrectReferTarget() throws ParseException, Interrupte
.withBody(dialJoeRcml)));

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

Expand Down Expand Up @@ -1025,7 +1025,7 @@ public void testTransferIncorrectReferTarget() throws ParseException, Interrupte
georgeCall.listenForDisconnect();
bobCall.listenForDisconnect();

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

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

0 comments on commit 7846196

Please sign in to comment.