//# 0 errors, 35 messages
//#
/*
    //#CommentDataServlet.java:1:1: class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#CommentDataServlet.java:1:1: method: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init
 * 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.ui.struts2.ajax;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.WordUtils;
import org.apache.roller.weblogger.business.Weblogger;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.business.WeblogManager;
import org.apache.roller.weblogger.pojos.WeblogEntryComment;
import org.apache.roller.weblogger.util.Utilities;


/**
 * Return comment id and content in JavaScript Object Notation (JSON) format.
 * For example comment with id "3454545346" and content "hi there" will be
 * represented as: {id : "3454545346", content : "hi there"}
 */
public class CommentDataServlet extends HttpServlet {
    //#CommentDataServlet.java:40: method: void org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet()
    //#input(void org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet()): this
    //#CommentDataServlet.java:40: end of method: void org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet()
    
    public void doGet(HttpServletRequest request, 
                      HttpServletResponse response)
            throws ServletException, IOException {
        
        Weblogger roller = WebloggerFactory.getWeblogger();
    //#CommentDataServlet.java:46: method: void org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.doGet(HttpServletRequest, HttpServletResponse)
    //#CommentDataServlet.java:46: Warning: method not available
    //#    -- call on Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "" }"._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "","._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "content: ""._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "{ id: ""._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): request
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): response
    //#pre[1] (void doGet(HttpServletRequest, HttpServletResponse)): request != null
    //#pre[2] (void doGet(HttpServletRequest, HttpServletResponse)): response != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletResponse:getWriter(...)@55 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletResponse:getWriter(...)@57 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletResponse:getWriter(...)@58 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.WeblogManager:getComment(...)@49 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@48 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@46 != null
        try {
            WeblogManager wmgr = roller.getWeblogManager();
    //#CommentDataServlet.java:48: Warning: method not available
    //#    -- call on WeblogManager org.apache.roller.weblogger.business.Weblogger:getWeblogManager()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: WeblogManager org.apache.roller.weblogger.business.Weblogger:getWeblogManager()
            WeblogEntryComment c = wmgr.getComment(request.getParameter("id"));
    //#CommentDataServlet.java:49: Warning: method not available
    //#    -- call on WeblogEntryComment org.apache.roller.weblogger.business.WeblogManager:getComment(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: WeblogEntryComment org.apache.roller.weblogger.business.WeblogManager:getComment(String)
            String content = Utilities.escapeHTML(c.getContent());
    //#CommentDataServlet.java:50: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent()
    //#CommentDataServlet.java:50: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.util.Utilities:escapeHTML(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: String org.apache.roller.weblogger.util.Utilities:escapeHTML(String)
            content = WordUtils.wrap(content, 72);
    //#CommentDataServlet.java:51: Warning: method not available
    //#    -- call on String org.apache.commons.lang.WordUtils:wrap(String, int)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: String org.apache.commons.lang.WordUtils:wrap(String, int)
            content = StringEscapeUtils.escapeJavaScript(content);
    //#CommentDataServlet.java:52: Warning: method not available
    //#    -- call on String org.apache.commons.lang.StringEscapeUtils:escapeJavaScript(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: String org.apache.commons.lang.StringEscapeUtils:escapeJavaScript(String)
            String json = "{ id: \"" + c.getId() + "\"," + "content: \"" + content + "\" }";
    //#CommentDataServlet.java:53: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntryComment:getId()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntryComment:getId()
            response.setContentType("text/html; charset=utf-8");
            response.getWriter().print(json);
            response.flushBuffer();
            response.getWriter().flush();
            response.getWriter().close();
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        }
    }
    //#CommentDataServlet.java:62: end of method: void org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.doGet(HttpServletRequest, HttpServletResponse)
    
}
    //#output(org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/ajax/CommentDataServlet]
    //#output(org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    //#post(org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/ajax/CommentDataServlet] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V == &doGet
    //#CommentDataServlet.java:: end of method: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet.org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet__static_init
    //#CommentDataServlet.java:: end of class: org.apache.roller.weblogger.ui.struts2.ajax.CommentDataServlet
