"Transaction not available -- could not acquire stack lock");
}
try {
if (SIPTransactionStack.isDialogCreated(sipRequest.getMethod())) {
if (sipStack.findTransaction((SIPRequest) request, true) != null)
throw new TransactionAlreadyExistsException(
"server transaction already exists!");
transaction = (SIPServerTransaction) ((SIPRequest) request)
.getTransaction();
if (transaction == null)
throw new TransactionUnavailableException(
"Transaction not available");
if (transaction.getOriginalRequest() == null)
transaction.setOriginalRequest(sipRequest);
try {
sipStack.addTransaction(transaction);
} catch (IOException ex) {
throw new TransactionUnavailableException(
"Error sending provisional response");
}
// So I can handle timeouts.
transaction.addEventListener(this);
if (isAutomaticDialogSupportEnabled()) {
// If automatic dialog support is enabled then
// this tx gets his own dialog.
String dialogId = sipRequest.getDialogId(true);
SIPDialog dialog = sipStack.getDialog(dialogId);
if (dialog == null) {
dialog = sipStack.createDialog(transaction);
}
transaction.setDialog(dialog, sipRequest.getDialogId(true));
if (sipRequest.getMethod().equals(Request.INVITE) && this.isDialogErrorsAutomaticallyHandled()) {
sipStack.putInMergeTable(transaction, sipRequest);
}
dialog.addRoute(sipRequest);
if (dialog.getRemoteTag() != null
&& dialog.getLocalTag() != null) {
this.sipStack.putDialog(dialog);
}
}
} else {
if (isAutomaticDialogSupportEnabled()) {
/*
* Under automatic dialog support, dialog is tied into a transaction. You cannot
* create a server tx except for dialog creating transactions. After that, all
* subsequent transactions are created for you by the stack.
*/
transaction = (SIPServerTransaction) sipStack.findTransaction(
(SIPRequest) request, true);
if (transaction != null)
throw new TransactionAlreadyExistsException(
"Transaction exists! ");
transaction = (SIPServerTransaction) ((SIPRequest) request)
.getTransaction();
if (transaction == null)
throw new TransactionUnavailableException(
"Transaction not available!");
if (transaction.getOriginalRequest() == null)
transaction.setOriginalRequest(sipRequest);
// Map the transaction.
try {
sipStack.addTransaction(transaction);
} catch (IOException ex) {
throw new TransactionUnavailableException(
"Could not send back provisional response!");
}
// If there is a dialog already assigned then just update the
// dialog state.
String dialogId = sipRequest.getDialogId(true);
SIPDialog dialog = sipStack.getDialog(dialogId);
if (dialog != null) {
dialog.addTransaction(transaction);
dialog.addRoute(sipRequest);
transaction.setDialog(dialog, sipRequest.getDialogId(true));
}
} else {
transaction = (SIPServerTransaction) sipStack.findTransaction(
(SIPRequest) request, true);
if (transaction != null)
throw new TransactionAlreadyExistsException(
"Transaction exists! ");
transaction = (SIPServerTransaction) ((SIPRequest) request)
.getTransaction();
if (transaction != null) {
if (transaction.getOriginalRequest() == null)