SipServletRequest copiedReq = null;
// need special treatment for from and to headers
// Set<String> from = headerMap != null ? headerMap.remove("From") : null;
// Set<String> to = headerMap != null ? headerMap.remove("To") : null;
SipFactoryFacade sfImpl = (SipFactoryFacade) _sf;
SipApplicationSessionImpl sappSessImpl = (SipApplicationSessionImpl) origRequest.getApplicationSession();
try {
if ((from != null) && (to != null)) {
copiedReq = sfImpl.createRequestImpl(sappSessImpl,
origRequest.getMethod(),
sfImpl.createAddress(from.iterator().next()),
sfImpl.createAddress(to.iterator().next()), false,
origRequestImpl);
} else if (from != null) {
copiedReq = sfImpl.createRequestImpl(sappSessImpl,
origRequest.getMethod(),
sfImpl.createAddress(from.iterator().next()),
origRequestImpl.getToImpl(), false, origRequestImpl);
} else if (to != null) {
copiedReq = sfImpl.createRequestImpl(sappSessImpl,
origRequest.getMethod(), origRequestImpl.getFromImpl(),
sfImpl.createAddress(to.iterator().next()), false,
origRequestImpl);
} else {
copiedReq = sfImpl.createRequestImpl(sappSessImpl,
origRequest.getMethod(), origRequestImpl.getFromImpl(),
origRequestImpl.getToImpl(), false, origRequestImpl);
}
} catch (ServletParseException e) {
throw new IllegalArgumentException(e);