if ((statusCode / 100 == 2) && cseqMethod.equals(Request.INVITE)) {
if (transaction instanceof SIPServerTransaction && (statusCode / 100 == 2) && cseqMethod.equals(Request.INVITE)) {
	public void setLastResponse(SIPTransaction transaction,			SIPResponse sipResponse) {		int statusCode = sipResponse.getStatusCode();		if (statusCode == 100) {			sipStack.getLogWriter().logWarning(					"Invalid status code - 100 in setLastResponse - ignoring");			return;		}		this.lastResponse = sipResponse;		this.setAssigned();		// Adjust state of the Dialog state machine.		if (sipStack.isLoggingEnabled()) {			sipStack.getLogWriter().logDebug(					"sipDialog: setLastResponse:" + this + " lastResponse = "							+ this.lastResponse.getFirstLine());		}		if (this.getState() == DialogState.TERMINATED) {			if (sipStack.isLoggingEnabled()) {				sipStack						.getLogWriter()						.logDebug(								"sipDialog: setLastResponse -- dialog is terminated - ignoring ");			}			return;		}		String cseqMethod = sipResponse.getCSeq().getMethod();		if (!this.isServer()) {			if (sipStack.isDialogCreated(cseqMethod)) {				// Make a final tag assignment.				if (getState() == null && statusCode / 100 == 1						&& getState() != DialogState.CONFIRMED) {					// Guard aginst slipping back into early state from					// confirmed					// state					setState(SIPDialog.EARLY_STATE);					if (sipResponse.getStatusCode() != 100) {						if (sipResponse.getToTag() != null								&& this.getRemoteTag() == null) {							setRemoteTag(sipResponse.getToTag());							this.setDialogId(sipResponse.getDialogId(false));							sipStack.putDialog(this);							this.addRoute(sipResponse);						}					}				} else if (statusCode / 100 == 2) {					// This is a dialog creating method (such as INVITE).					// 2xx response -- set the state to the confirmed					// state. To tag is MANDATORY for the response.					if (sipResponse.getToTag() != null					/* && this.getState() != DialogState.CONFIRMED */) {						setRemoteTag(sipResponse.getToTag());						this.setDialogId(sipResponse.getDialogId(false));						sipStack.putDialog(this);						this.addRoute(sipResponse);					} else {						if (transaction instanceof ClientTransaction								&& sipResponse.getStatusCode() / 100 == 2								&& SIPRequest.isTargetRefresh(cseqMethod))							doTargetRefresh(sipResponse);					}					setState(SIPDialog.CONFIRMED_STATE);				} else if (statusCode >= 300						&& statusCode <= 699						&& (getState() == null || (cseqMethod								.equals(getMethod()) && getState().getValue() == SIPDialog.EARLY_STATE))) {					// This case handles 3xx, 4xx, 5xx and 6xx responses.					// RFC 3261 Section 12.3 - dialog termination.					// Independent of the method, if a request outside of a					// dialog generates					// a non-2xx final response, any early dialogs created					// through					// provisional responses to that request are terminated.					setState(SIPDialog.TERMINATED_STATE);				}				// This code is in support of "proxy" servers				// that are constructed as back to back user agents.				// This could be a dialog in the middle of the call setup				// path somewhere. Hence the incoming invite has				// record route headers in it. The response will				// have additional record route headers. However,				// for this dialog only the downstream record route				// headers matter. Ideally proxy servers should				// not be constructed as Back to Back User Agents.				// Remove all the record routes that are present in				// the incoming INVITE so you only have the downstream				// Route headers present in the dialog. Note that				// for an endpoint - you will have no record route				// headers present in the original request so				// the loop will not execute.				if (originalRequest != null) {					RecordRouteList rrList = originalRequest							.getRecordRouteHeaders();					if (rrList != null) {						ListIterator it = rrList.listIterator(rrList.size());						while (it.hasPrevious()) {							RecordRoute rr = (RecordRoute) it.previous();							Route route = (Route) routeList.getFirst();							if (route != null									&& rr.getAddress().equals(											route.getAddress())) {								routeList.removeFirst();							} else								break;						}					}				}			} else if (cseqMethod.equals(Request.NOTIFY)					&& this.getMethod().equals(Request.SUBSCRIBE)					&& sipResponse.getStatusCode() / 100 == 2					&& this.getState() == null) {				// This is a notify response.				this.setDialogId(sipResponse.getDialogId(true));				sipStack.putDialog(this);				this.setState(SIPDialog.CONFIRMED_STATE);			} else if (cseqMethod.equals(Request.BYE) && statusCode / 100 == 2					&& isTerminatedOnBye()) {				// Dialog will be terminated when the transction is terminated.				setState(SIPDialog.TERMINATED_STATE);			}		} else {			// Processing Server Dialog.			if (cseqMethod.equals(Request.CANCEL)					&& statusCode / 100 == 2					&& (!this.isReInvite())					&& sipStack.isDialogCreated(getMethod())					&& (getState() == null || getState().getValue() == SIPDialog.EARLY_STATE)) {				// Transaction successfully cancelled but dialog has not yet				// been established so delete the dialog.				// Note: this does not apply to re-invite				this.setState(SIPDialog.TERMINATED_STATE);			} else if (cseqMethod.equals(Request.BYE) && statusCode / 100 == 2					&& this.isTerminatedOnBye()) {				// Only transition to terminated state when				// 200 OK is returned for the BYE. Other				// status codes just result in leaving the				// state in COMPLETED state.				this.setState(SIPDialog.TERMINATED_STATE);			} else if (cseqMethod.equals(Request.CANCEL)) {				if (getState() == null						|| getState().getValue() == SIPDialog.EARLY_STATE) {					setState(SIPDialog.TERMINATED_STATE);				}			} else if (getLocalTag() == null					&& sipResponse.getTo().getTag() != null					&& sipStack.isDialogCreated(cseqMethod)) {				setLocalTag(sipResponse.getTo().getTag());				if (statusCode / 100 != 2) {					// Check if we want to put the dialog in the dialog table.					// A dialog is put into the dialog table when the server					// transaction is responded to by a provisional response					// or a final response. The Dialog is terminated					// if the response is an error response.					if (statusCode / 100 == 1) {						setState(SIPDialog.EARLY_STATE);						this.setDialogId(sipResponse.getDialogId(true));						sipStack.putDialog(this);					} else {						this.setState(SIPDialog.TERMINATED_STATE);					}				} else {					// 2XX response handling.					this.setState(SIPDialog.CONFIRMED_STATE);					this.setDialogId(sipResponse.getDialogId(true));					sipStack.putDialog(this);				}			} else if (sipStack.isDialogCreated(cseqMethod)					&& statusCode / 100 == 2) {				// 2XX response handling.				if (sipResponse.getTo().getTag() != null)					setLocalTag(sipResponse.getTo().getTag());				this.setState(SIPDialog.CONFIRMED_STATE);				this.setDialogId(sipResponse.getDialogId(true));				sipStack.putDialog(this);				if (statusCode / 100 == 2 && cseqMethod.equals(Request.INVITE)) {					SIPServerTransaction sipServerTx = (SIPServerTransaction) transaction;					this.startTimer(sipServerTx);				}			}			// In any state: start 2xx retransmission timer for INVITE			if ((statusCode / 100 == 2) && cseqMethod.equals(Request.INVITE)) {				SIPServerTransaction sipServerTx = (SIPServerTransaction) transaction;				this.startTimer(sipServerTx);			}			// Target refresh processing.			if (transaction instanceof ClientTransaction					&& statusCode / 100 == 2					&& SIPRequest.isTargetRefresh(cseqMethod)) {				doTargetRefresh(sipResponse);			}		}	}