* sipStack.logWriter.logMessage(" testing " + this.getOriginalRequest()); * sipStack.logWriter.logMessage("Against " + messageToTest); * sipStack.logWriter.logMessage("isTerminated = " + isTerminated()); * sipStack.logWriter.logMessage("messageBranch = " + messageBranch); * sipStack.logWriter.logMessage("viaList = " + messageToTest.getViaHeaders()); * sipStack.logWriter.logMessage("myBranch = " + getBranch()); * } **/
* sipStack.logWriter.logMessage(" testing " + * this.getOriginalRequest()); sipStack.logWriter.logMessage("Against " + * messageToTest); sipStack.logWriter.logMessage("isTerminated = " + * isTerminated()); sipStack.logWriter.logMessage("messageBranch = " + * messageBranch); sipStack.logWriter.logMessage("viaList = " + * messageToTest.getViaHeaders()); * sipStack.logWriter.logMessage("myBranch = " + getBranch()); } */
    public boolean isMessagePartOfTransaction(SIPMessage messageToTest) {                // List of Via headers in the message to test        ViaList viaHeaders = messageToTest.getViaHeaders();        // Flags whether the select message is part of this transaction        boolean transactionMatches;        String messageBranch = ((Via) viaHeaders.getFirst()).getBranch();        boolean rfc3261Compliant =        getBranch() != null        && messageBranch != null        && getBranch().startsWith(SIPConstants.BRANCH_MAGIC_COOKIE)        && messageBranch.startsWith(SIPConstants.BRANCH_MAGIC_COOKIE);                /**         * if (parentStack.logWriter.needsLogging)  {         * sipStack.logWriter.logMessage("--------- TEST ------------");         * sipStack.logWriter.logMessage(" testing " + this.getOriginalRequest());         * sipStack.logWriter.logMessage("Against " + messageToTest);         * sipStack.logWriter.logMessage("isTerminated = " + isTerminated());         * sipStack.logWriter.logMessage("messageBranch = " + messageBranch);         * sipStack.logWriter.logMessage("viaList = " + messageToTest.getViaHeaders());         * sipStack.logWriter.logMessage("myBranch = " + getBranch());         * }         **/                transactionMatches = false;        if (TransactionState.COMPLETED == this.getState()) {            if (rfc3261Compliant) {                transactionMatches =                getBranch().equals(                ((Via) viaHeaders.getFirst()).getBranch());            } else {                transactionMatches =                getBranch().equals(messageToTest.getTransactionId());            }        } else if (!isTerminated()) {            if (rfc3261Compliant) {                if (viaHeaders != null) {                    // If the branch parameter is the                    //same as this transaction and the method is the same,                    if (getBranch()                    .equals(((Via) viaHeaders.getFirst()).getBranch())) {                        transactionMatches =                        getOriginalRequest().getCSeq().getMethod().equals(                        messageToTest.getCSeq().getMethod());                                            }                }            } else {                // not RFC 3261 compliant.                if (getBranch() != null) {                    transactionMatches =                    getBranch().equals(messageToTest.getTransactionId());                } else {                    transactionMatches =                    getOriginalRequest().getTransactionId().equals(                    messageToTest.getTransactionId());                }                            }                    }        return transactionMatches;            }