//# 2 errors, 167 messages
//#
/*
    //#Trackback.java:1:1: class: org.apache.roller.weblogger.util.Trackback
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.util;

import java.io.IOException;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.pojos.WeblogEntry;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;


/**
 * Represents a trackback request.
 */
public class Trackback {
    
    private static final Log log = LogFactory.getLog(Trackback.class);
    //#Trackback.java:51: method: org.apache.roller.weblogger.util.Trackback.org.apache.roller.weblogger.util.Trackback__static_init
    //#Trackback.java:51: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: org.apache.roller.weblogger.util.Trackback__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.util.Trackback__static_init): __Descendant_Table[org/apache/roller/weblogger/util/Trackback]
    //#output(org.apache.roller.weblogger.util.Trackback__static_init): __Dispatch_Table.parseTrackbackResponse(Ljava/lang/String;Lorg/apache/roller/weblogger/util/RollerMessages;)Lorg/apache/roller/weblogger/util/RollerMessages;
    //#output(org.apache.roller.weblogger.util.Trackback__static_init): __Dispatch_Table.send()Lorg/apache/roller/weblogger/util/RollerMessages;
    //#output(org.apache.roller.weblogger.util.Trackback__static_init): log
    //#post(org.apache.roller.weblogger.util.Trackback__static_init): __Descendant_Table[org/apache/roller/weblogger/util/Trackback] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.Trackback__static_init): __Dispatch_Table.parseTrackbackResponse(Ljava/lang/String;Lorg/apache/roller/weblogger/util/RollerMessages;)Lorg/apache/roller/weblogger/util/RollerMessages; == &parseTrackbackResponse
    //#post(org.apache.roller.weblogger.util.Trackback__static_init): __Dispatch_Table.send()Lorg/apache/roller/weblogger/util/RollerMessages; == &send
    //#post(org.apache.roller.weblogger.util.Trackback__static_init): init'ed(log)
    //#Trackback.java:51: end of method: org.apache.roller.weblogger.util.Trackback.org.apache.roller.weblogger.util.Trackback__static_init
    
    private final WeblogEntry entry;
    private final String trackbackURL;
    
    
    public Trackback(WeblogEntry tEntry, String tURL)
            throws TrackbackNotAllowedException {
    //#Trackback.java:58: method: void org.apache.roller.weblogger.util.Trackback.org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#input(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): "bad url: "._tainted
    //#input(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): tEntry
    //#input(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): tURL
    //#input(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): tURL._tainted
    //#input(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): this
    //#output(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): this.entry
    //#output(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): this.trackbackURL
    //#presumption(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): org.apache.roller.weblogger.config.WebloggerConfig:getProperty(...)@62 != null
    //#post(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): this.entry == tEntry
    //#post(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): init'ed(this.entry)
    //#post(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): this.trackbackURL == tURL
    //#post(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): init'ed(this.trackbackURL)
    //#unanalyzed(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.WebloggerException
    //#test_vector(void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)): org.apache.commons.lang.StringUtils:isEmpty(...)@63: {1}, {0}
        
        // Make sure trackback to URL is allowed
        boolean allowTrackback = true;
        String allowedURLs = WebloggerConfig.getProperty("trackback.allowedURLs");
    //#Trackback.java:62: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        if (!StringUtils.isEmpty(allowedURLs)) {
    //#Trackback.java:63: Warning: method not available
    //#    -- call on bool org.apache.commons.lang.StringUtils:isEmpty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    unanalyzed callee: bool org.apache.commons.lang.StringUtils:isEmpty(String)
            // in the case that the administrator has enabled trackbacks
            // for only specific URLs, set it to false by default
            allowTrackback = false;
            String[] splitURLs = allowedURLs.split("\\|\\|");
            for (int i=0; i < splitURLs.length; i++) {
    //#Trackback.java:68: ?use of default init
    //#    init'ed(splitURLs.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    basic block: bb_3
    //#    assertion: init'ed(splitURLs.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#Trackback.java:68: Warning: test always goes same way
    //#    test predetermined because i == splitURLs.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    from bb: bb_3
    //#    live edge: bb_3-->bb_7
    //#    tested vn: i - undefined
    //#    tested vn values: {0}
    //#Trackback.java:68: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    dead bb: bb_6
                Matcher m = Pattern.compile(splitURLs[i]).matcher(tURL);
    //#Trackback.java:69: Warning: dead code
    //#    dead code here because i == splitURLs.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    dead bb: bb_4
                if (m.matches()) {
                    allowTrackback = true;
    //#Trackback.java:71: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    dead bb: bb_5
                    break;
                }
            }
        }
        
        if(!allowTrackback) {
            throw new TrackbackNotAllowedException(tURL);
    //#Trackback.java:78: ?conditional throw
    //#    allowTrackback == 1
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: void org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    //#    basic block: bb_7
    //#    assertion: allowTrackback == 1
    //#    VN: allowTrackback
    //#    Expected: {-Inf..-1, 1..+Inf}
    //#    Bad: {0}
    //#    Attribs:  Int  Bad singleton  Bad overlaps +/-1000  Bad > Exp
        } else {
            // test url
            try {
                new URL(tURL);
            } catch(MalformedURLException ex) {
                // bad url
                throw new IllegalArgumentException("bad url: "+tURL);
            }
            
            entry = tEntry;
            trackbackURL = tURL;
        }
        
    }
    //#Trackback.java:92: end of method: void org.apache.roller.weblogger.util.Trackback.org.apache.roller.weblogger.util.Trackback(WeblogEntry, String)
    
    
    /**
     * Sends trackback from entry to remote URL.
     * See Trackback spec for details: http://www.sixapart.com/pronet/docs/trackback_spec
     */
    public RollerMessages send() throws WebloggerException {
        
        RollerMessages messages = new RollerMessages();
    //#Trackback.java:101: method: RollerMessages org.apache.roller.weblogger.util.Trackback.send()
    //#input(RollerMessages send()): " "._tainted
    //#input(RollerMessages send()): ""._tainted
    //#input(RollerMessages send()): "&amp;"._tainted
    //#input(RollerMessages send()): "="._tainted
    //#input(RollerMessages send()): "?"._tainted
    //#input(RollerMessages send()): "Sending trackback to url - "._tainted
    //#input(RollerMessages send()): "query string - "._tainted
    //#input(RollerMessages send()): "response:&#10;"._tainted
    //#input(RollerMessages send()): "result = "._tainted
    //#input(RollerMessages send()): log
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[org/apache/roller/weblogger/util/RollerMessages]
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[others]
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addError(Ljava/lang/String;)V
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addError(Ljava/lang/String;Ljava/lang/String;)V
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addError(Ljava/lang/String;[Ljava/lang/String;)V
    //#input(RollerMessages send()): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addMessage(Ljava/lang/String;)V
    //#input(RollerMessages send()): this
    //#input(RollerMessages send()): this.entry
    //#input(RollerMessages send()): this.trackbackURL
    //#input(RollerMessages send()): this.trackbackURL._tainted
    //#output(RollerMessages send()): new ArrayList(RollerMessages#1) num objects
    //#output(RollerMessages send()): new ArrayList(RollerMessages#2) num objects
    //#output(RollerMessages send()): new RollerMessages(send#1) num objects
    //#output(RollerMessages send()): new RollerMessages(send#1).__Tag
    //#output(RollerMessages send()): new RollerMessages(send#1).mErrors
    //#output(RollerMessages send()): new RollerMessages(send#1).mMessages
    //#output(RollerMessages send()): return_value
    //#new obj(RollerMessages send()): new ArrayList(RollerMessages#1)
    //#new obj(RollerMessages send()): new ArrayList(RollerMessages#2)
    //#new obj(RollerMessages send()): new RollerMessages(send#1)
    //#pre[2] (RollerMessages send()): this.entry != null
    //#presumption(RollerMessages send()): org.apache.commons.logging.LogFactory:getLog(...)@51 != null
    //#presumption(RollerMessages send()): org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite(...)@109 != null
    //#post(RollerMessages send()): return_value == &new RollerMessages(send#1)
    //#post(RollerMessages send()): new ArrayList(RollerMessages#1) num objects == 1
    //#post(RollerMessages send()): new ArrayList(RollerMessages#2) num objects == 1
    //#post(RollerMessages send()): new RollerMessages(send#1) num objects == 1
    //#post(RollerMessages send()): new RollerMessages(send#1).__Tag == org/apache/roller/weblogger/util/RollerMessages
    //#post(RollerMessages send()): new RollerMessages(send#1).mErrors == &new ArrayList(RollerMessages#1)
    //#post(RollerMessages send()): new RollerMessages(send#1).mMessages == &new ArrayList(RollerMessages#2)
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.jdom.input.SAXBuilder
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.apache.commons.lang.StringEscapeUtils:unescapeHtml
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.io.StringReader
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.jdom.input.SAXBuilder:build
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.jdom.Document:getRootElement
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.jdom.Element:getName
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.jdom.Element:getChildText
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.Integer:parseInt
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.String:indexOf
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.String:length
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.apache.roller.weblogger.util.RollerMessages$RollerMessage
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.List:add
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.net.URLEncoder:encode
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.util.Map:get
    //#unanalyzed(RollerMessages send()): Effects-of-calling:java.lang.StringBuffer:length
    //#unanalyzed(RollerMessages send()): Effects-of-calling:org.apache.commons.lang.StringUtils:replace
    //#test_vector(RollerMessages send()): org.apache.commons.httpclient.HttpClient:executeMethod(...)@129: {-2_147_483_648..199, 201..403, 405..4_294_967_295}, {200}, {404}
        
        log.debug("Sending trackback to url - "+trackbackURL);
    //#Trackback.java:103: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // Construct data
        String title = entry.getTitle();
    //#Trackback.java:106: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntry:getTitle()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntry:getTitle()
        String excerpt = StringUtils.left( Utilities.removeHTML(entry.getDisplayContent()),255 );
    //#Trackback.java:107: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntry:getDisplayContent()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntry:getDisplayContent()
    //#Trackback.java:107: Warning: method not available
    //#    -- call on String org.apache.commons.lang.StringUtils:left(String, int)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.commons.lang.StringUtils:left(String, int)
        String url = entry.getPermalink();
    //#Trackback.java:108: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntry:getPermalink()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntry:getPermalink()
        String blog_name = entry.getWebsite().getName();
    //#Trackback.java:109: Warning: method not available
    //#    -- call on Weblog org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: Weblog org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite()
    //#Trackback.java:109: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.Weblog:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.Weblog:getName()
        
        // build trackback post parameters as query string
        Map params = new HashMap();
        params.put("title", URLUtilities.encode(title));
        params.put("excerpt", URLUtilities.encode(excerpt));
        params.put("url", URLUtilities.encode(url));
        params.put("blog_name", URLUtilities.encode(blog_name));
        String queryString = URLUtilities.getQueryString(params);
        
        log.debug("query string - "+queryString);
    //#Trackback.java:119: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // prepare http request
        HttpClient client = new HttpClient();
    //#Trackback.java:122: Warning: method not available
    //#    -- call on void org.apache.commons.httpclient.HttpClient()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.httpclient.HttpClient()
        client.setConnectionTimeout(45 * 1000);
    //#Trackback.java:123: Warning: method not available
    //#    -- call on void org.apache.commons.httpclient.HttpClient:setConnectionTimeout(int)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.httpclient.HttpClient:setConnectionTimeout(int)
        HttpMethod method = new PostMethod(trackbackURL);
    //#Trackback.java:124: Warning: method not available
    //#    -- call on void org.apache.commons.httpclient.methods.PostMethod(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.httpclient.methods.PostMethod(String)
        method.setQueryString(queryString);
    //#Trackback.java:125: Warning: method not available
    //#    -- call on void org.apache.commons.httpclient.HttpMethod:setQueryString(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.httpclient.HttpMethod:setQueryString(String)
        
        try {
            // execute trackback
            int statusCode = client.executeMethod(method);
    //#Trackback.java:129: Warning: method not available
    //#    -- call on int org.apache.commons.httpclient.HttpClient:executeMethod(HttpMethod)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: int org.apache.commons.httpclient.HttpClient:executeMethod(HttpMethod)
            
            // read response
            byte[] response = method.getResponseBody();
    //#Trackback.java:132: Warning: method not available
    //#    -- call on byte[] org.apache.commons.httpclient.HttpMethod:getResponseBody()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: byte[] org.apache.commons.httpclient.HttpMethod:getResponseBody()
            String responseString = Utilities.escapeHTML(new String(response, "UTF-8"));
            
            log.debug("result = "+statusCode+" "+method.getStatusText());
    //#Trackback.java:135: Warning: method not available
    //#    -- call on String org.apache.commons.httpclient.HttpMethod:getStatusText()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.commons.httpclient.HttpMethod:getStatusText()
    //#Trackback.java:135: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            log.debug("response:\n"+responseString);
    //#Trackback.java:136: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            
            if(statusCode == HttpStatus.SC_OK) {
                // trackback request succeeded, message will give details
                try {
                    messages = parseTrackbackResponse(new String(response, "UTF-8"), messages);
                } catch (Exception e) {
                    // Cannot parse response, indicates failure
                    messages.addError("weblogEdit.trackbackErrorParsing", responseString);
                }
            } else if(statusCode == HttpStatus.SC_NOT_FOUND) {
                // 404, invalid trackback url
                messages.addError("weblogEdit.trackbackError404");
            } else {
                // some other kind of error with url, like 500, 403, etc
                // just provide a generic error message and give the http response text
                messages.addError("weblogEdit.trackbackErrorResponse",
    //#Trackback.java:152: Warning: method not available
    //#    -- call on String org.apache.commons.httpclient.HttpMethod:getStatusText()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: String org.apache.commons.httpclient.HttpMethod:getStatusText()
                        new String[] {""+statusCode, method.getStatusText()});
            }
            
        } catch (IOException e) {
            // some kind of transport error sending trackback post
            log.debug("Error sending trackback", e);
    //#Trackback.java:158: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object, Throwable)
            messages.addError("weblogEdit.trackbackErrorTransport");
        } finally {
            // release used connection
            method.releaseConnection();
    //#Trackback.java:162: Warning: method not available
    //#    -- call on void org.apache.commons.httpclient.HttpMethod:releaseConnection()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages send()
    //#    unanalyzed callee: void org.apache.commons.httpclient.HttpMethod:releaseConnection()
        }
        
        return messages;
    //#Trackback.java:165: end of method: RollerMessages org.apache.roller.weblogger.util.Trackback.send()
    }
    
    
    /**
     * Parse XML returned from trackback POST, returns error or success message
     * in RollerMessages object.
     */
    private RollerMessages parseTrackbackResponse(String response, RollerMessages messages) 
            throws JDOMException, IOException {
        
        SAXBuilder builder = new SAXBuilder();
    //#Trackback.java:176: method: RollerMessages org.apache.roller.weblogger.util.Trackback.parseTrackbackResponse(String, RollerMessages)
    //#Trackback.java:176: Warning: method not available
    //#    -- call on void org.jdom.input.SAXBuilder()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: void org.jdom.input.SAXBuilder()
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): " "._tainted
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): messages
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): messages.__Tag
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): messages.mErrors
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): messages.mMessages
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[org/apache/roller/weblogger/util/RollerMessages]
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[others]
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addError(Ljava/lang/String;Ljava/lang/String;)V
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addMessage(Ljava/lang/String;)V
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): response
    //#input(RollerMessages parseTrackbackResponse(String, RollerMessages)): response._tainted
    //#output(RollerMessages parseTrackbackResponse(String, RollerMessages)): return_value
    //#pre[1] (RollerMessages parseTrackbackResponse(String, RollerMessages)): messages != null
    //#pre[2] (RollerMessages parseTrackbackResponse(String, RollerMessages)): messages.__Tag == org/apache/roller/weblogger/util/RollerMessages
    //#pre[3] (RollerMessages parseTrackbackResponse(String, RollerMessages)): (soft) messages.mErrors != null
    //#pre[4] (RollerMessages parseTrackbackResponse(String, RollerMessages)): (soft) messages.mMessages != null
    //#presumption(RollerMessages parseTrackbackResponse(String, RollerMessages)): org.jdom.Document:getRootElement(...)@179 != null
    //#presumption(RollerMessages parseTrackbackResponse(String, RollerMessages)): org.jdom.input.SAXBuilder:build(...)@177 != null
    //#post(RollerMessages parseTrackbackResponse(String, RollerMessages)): return_value == messages
    //#post(RollerMessages parseTrackbackResponse(String, RollerMessages)): return_value != null
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.String:indexOf
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:org.apache.roller.weblogger.util.RollerMessages$RollerMessage
    //#unanalyzed(RollerMessages parseTrackbackResponse(String, RollerMessages)): Effects-of-calling:java.util.List:add
    //#test_vector(RollerMessages parseTrackbackResponse(String, RollerMessages)): java.lang.String:equals(...)@181: {0}, {1}
        Document doc = builder.build(
    //#Trackback.java:177: Warning: method not available
    //#    -- call on String org.apache.commons.lang.StringEscapeUtils:unescapeHtml(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: String org.apache.commons.lang.StringEscapeUtils:unescapeHtml(String)
    //#Trackback.java:177: Warning: method not available
    //#    -- call on Document org.jdom.input.SAXBuilder:build(Reader)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: Document org.jdom.input.SAXBuilder:build(Reader)
                new StringReader(StringEscapeUtils.unescapeHtml(response)));
        Element root = doc.getRootElement();
    //#Trackback.java:179: Warning: method not available
    //#    -- call on Element org.jdom.Document:getRootElement()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: Element org.jdom.Document:getRootElement()
        
        if ("response".equals(root.getName())) {
    //#Trackback.java:181: Warning: method not available
    //#    -- call on String org.jdom.Element:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: String org.jdom.Element:getName()
            int code = -99;
            try {
                code = Integer.parseInt(root.getChildText("error"));
    //#Trackback.java:184: Warning: method not available
    //#    -- call on String org.jdom.Element:getChildText(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: String org.jdom.Element:getChildText(String)
            } catch (NumberFormatException ignoredByDesign) {}
            
            String message = root.getChildText("message");
    //#Trackback.java:187: Warning: method not available
    //#    -- call on String org.jdom.Element:getChildText(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.Trackback
    //#    method: RollerMessages parseTrackbackResponse(String, RollerMessages)
    //#    unanalyzed callee: String org.jdom.Element:getChildText(String)
            if (code != 0) {
                messages.addError("weblogEdit.trackbackFailure", Utilities.removeHTML(message));
            } else {
                messages.addMessage("weblogEdit.trackbackSuccess");
            }
        } else {
            messages.addError("weblogEdit.trackbackErrorParsing", Utilities.removeHTML(response));
        }
        
        return messages;
    //#Trackback.java:197: end of method: RollerMessages org.apache.roller.weblogger.util.Trackback.parseTrackbackResponse(String, RollerMessages)
    }
    
}
    //#Trackback.java:: end of class: org.apache.roller.weblogger.util.Trackback
