* Basically, first Join/Replace header is considered for targetting. If it
* is not there, look for encoded sas.
*/
static SipTargetedRequestInfo get (SipServletRequestImpl request) {
try {
SipApplicationSessionImpl sas = null;
String appName = null;
SipTargetedRequestInfo stri = null;
SessionTarget st = request.getSessionTarget();
if (st != null) {
return st.getTargetedRequestInfo();
}
// XXX it is a pity that we do the SAS loading twice.
// once here to check for a targeted request and once in the Factory
// when we actually create the ss/sas for the request
// maybe we can refactor a bit, so that if we have a targeted
// request we already set the SAS that we found on the request somehow...
String uriEncodedSasId = null;
Address routeAddr = request.getInitialPoppedRoute();
if (routeAddr != null) {
uriEncodedSasId = UriUtil.getAndDecodeParameter(
routeAddr.getURI(), URIImpl.SASID_PARAM);
}
if (uriEncodedSasId == null)
uriEncodedSasId = UriUtil.getAndDecodeParameter(request.getRequestURI(), URIImpl.SASID_PARAM);
if (uriEncodedSasId != null) {
appName = SipApplicationSessionUtil.getApplicationName(uriEncodedSasId);
if (appName != null) {
sas = SipSessionManagerRegistry.getInstance().get(appName).findSipApplicationSession(uriEncodedSasId);
if (sas != null && sas.isValid()) {
if (m_logger.isLoggable(Level.FINEST)) {
m_logger.log(Level.FINEST, "targeted request for app {0} with encodedURI: {1}", new Object[] {appName, uriEncodedSasId});
}
return new SipTargetedRequestInfo(SipTargetedRequestType.ENCODED_URI, appName);
}