throw new SipException("Cannot ACK a provisional response!");
}
SIPRequest ackRequest = originalRequest
.createAckRequest((To) lastResponse.getTo());
// Pull the record route headers from the last reesponse.
RecordRouteList recordRouteList = lastResponse.getRecordRouteHeaders();
if (recordRouteList == null) {
// If the record route list is null then we can
// construct the ACK from the specified contact header.
// Note the 3xx check here because 3xx is a redirect.
// The contact header for the 3xx is the redirected
// location so we cannot use that to construct the
// request URI.
if (lastResponse.getContactHeaders() != null
&& lastResponse.getStatusCode() / 100 != 3) {
Contact contact = (Contact) lastResponse.getContactHeaders()
.getFirst();
javax.sip.address.URI uri = (javax.sip.address.URI) contact
.getAddress().getURI().clone();
ackRequest.setRequestURI(uri);
}
return ackRequest;
}
ackRequest.removeHeader(RouteHeader.NAME);
RouteList routeList = new RouteList();
// start at the end of the list and walk backwards
ListIterator<RecordRoute> li = recordRouteList
.listIterator(recordRouteList.size());
while (li.hasPrevious()) {
RecordRoute rr = (RecordRoute) li.previous();
Route route = new Route();
route.setAddress((AddressImpl) ((AddressImpl) rr.getAddress())