<commit_before>/*code written by <NAME>
 * edited by <NAME>
 */

package gonqbox.servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.jstl.core.Config;

import gonqbox.Pages;
import gonqbox.dao.DAO;
import gonqbox.models.Comment;
import gonqbox.models.User;

/** Purpose: Servlet to add new comment to files in comment section
 *  
 * @author <NAME>
 * @version 0.2
 */
@WebServlet(name = "comment", urlPatterns = { "/comment" })
public class CommentServlet extends HttpServlet{
	
	private static final long serialVersionUID = 2194000724171138285L;

	private ResourceBundle bundle = null;
	
	//DAO Instance to access database
	private DAO dao = DAO.getInstance();
	
	/**
     * Purpose: To display the current set of comments with their 
     * users names displayed.
     * @param request and response
     * @return void
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {
    	String loc = Config.get(request.getSession(), Config.FMT_LOCALE).toString();	
        bundle = ResourceBundle.getBundle("ui_"+loc);

        int fID=Integer.parseInt(request.getParameter("fileID")); 
        
        //get all comments for file into list
        List<Comment> comments = dao.getCommentsByFileID(fID);
        request.setAttribute("comments", comments);
        
        //create list of users for comments so it can be pulled in comment.jsp
        List<User> users = new ArrayList<>();
        for(int i = 0; i<comments.size(); i++) {
			users.add(dao.getUserByUserID(comments.get(i).getUploaderID()));
		}
        
        //set the attribute
        request.setAttribute("users", users);
        
        RequestDispatcher rd=request.getRequestDispatcher(Pages.COMMENT.toString());  
        rd.forward(request,response);  
    }  
}<commit_msg>#61 removed space?<commit_after>/*code written by <NAME>
 * edited by <NAME>
 */

package gonqbox.servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.jstl.core.Config;

import gonqbox.Pages;
import gonqbox.dao.DAO;
import gonqbox.models.Comment;
import gonqbox.models.User;

/** Purpose: Servlet to add new comment to files in comment section
 *  
 * @author <NAME>
 * @version 0.2
 */
@WebServlet(name = "comment", urlPatterns = { "/comment" })
public class CommentServlet extends HttpServlet{
	
	private static final long serialVersionUID = 2194000724171138285L;

	private ResourceBundle bundle = null;
	
	//DAO Instance to access database
	private DAO dao = DAO.getInstance();
	
	/**
     * Purpose: To display the current set of comments with their 
     * users names displayed.
     * @param request and response
     * @return void
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException {
    	String loc = Config.get(request.getSession(), Config.FMT_LOCALE).toString();	
        bundle = ResourceBundle.getBundle("ui_"+loc);

        int fID=Integer.parseInt(request.getParameter("fileID")); 
        
        //get all comments for file into list
        List<Comment> comments = dao.getCommentsByFileID(fID);
        request.setAttribute("comments", comments);
        
        RequestDispatcher rd=request.getRequestDispatcher(Pages.COMMENT.toString());  
        rd.forward(request,response);  
    }  
}
{'fraction_non_alphanumeric': 0.10349096310968062, 'fraction_numerical': 0.011141371626640258, 'mean_word_length': 3.617142857142857, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6194802', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1128, 'n_words': 296}