<commit_before>package uk.ac.ebi.biosamples.controller;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import uk.ac.ebi.biosamples.model.Sample;
import uk.ac.ebi.biosamples.service.SampleService;


/**
 * Primary controller for HTML operations.
 * 
 * See {@link SampleRestController} for the equivalent REST controller.
 * 
 * @author faulcon
 *
 */
@Controller
@RequestMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE)
public class HtmlController {

	private SampleService sampleService;	
	
	public HtmlController(@Autowired SampleService sampleService) {
		this.sampleService = sampleService;
	}
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {		
        return "index";
    }
	
	@RequestMapping(value = "/samples/{accession}", method = RequestMethod.GET)
    public String samplesAccession(Model model, @PathVariable String accession, HttpServletRequest request, HttpServletResponse response) {
		Sample sample = null;
		try {
		    sample = sampleService.fetch(accession);
		} catch (IllegalArgumentException e) {
			//did not exist, throw 404
			response.setStatus(HttpStatus.NOT_FOUND.value());
			return "error/404";<commit_msg>improved logging<commit_after>package uk.ac.ebi.biosamples.controller;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import uk.ac.ebi.biosamples.model.Sample;
import uk.ac.ebi.biosamples.service.SampleService;


/**
 * Primary controller for HTML operations.
 * 
 * See {@link SampleRestController} for the equivalent REST controller.
 * 
 * @author faulcon
 *
 */
@Controller
@RequestMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE)
public class HtmlController {

	private Logger log = LoggerFactory.getLogger(getClass());
	
	private SampleService sampleService;	
	
	public HtmlController(@Autowired SampleService sampleService) {
		this.sampleService = sampleService;
	}
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {		
        return "index";
    }
	
	@RequestMapping(value = "/samples/{accession}", method = RequestMethod.GET)
    public String samplesAccession(Model model, @PathVariable String accession, HttpServletRequest request, HttpServletResponse response) {
		Sample sample = null;
		try {
		    sample = sampleService.fetch(accession);
		} catch (IllegalArgumentException e) {
			//did not exist, throw 404
			log.info("Returning a 404 for "+request.getRequestURL());
			response.setStatus(HttpStatus.NOT_FOUND.value());
			return "error/404";
{'fraction_non_alphanumeric': 0.10329018338727076, 'fraction_numerical': 0.004584681769147788, 'mean_word_length': 5.2758037225042305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5939208', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1016, 'n_words': 219}