<commit_before>package gov.usgs.cida.wqp.webservice;

import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipOutputStream;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import gov.usgs.cida.wqp.dao.BlobDao;
import gov.usgs.cida.wqp.parameter.FilterParameters;
import gov.usgs.cida.wqp.util.HttpConstants;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@RestController
public class BlobController {

	protected final BlobDao blobDao;

	@Autowired
	public BlobController(BlobDao blobDao) {
		this.blobDao = blobDao;
	}

	@ApiOperation(value="Return zipped artifact with all files available for the specified organization/project.")
	@GetMapping(value="/organizations/{organization}/projects/{projectIdentifier}/files")
	public void projectBlobFilesGetRestRequest(HttpServletRequest request, HttpServletResponse response, @ApiIgnore FilterParameters filter,
			@PathVariable("organization") String organization, @PathVariable("projectIdentifier") String projectIdentifier) throws IOException {
		response.setHeader(HttpConstants.HEADER_CONTENT_DISPOSITION,"attachment; filename=project.zip");
		OutputStream out = response.getOutputStream();
		ZipOutputStream target = new ZipOutputStream(out);
		blobDao.getFiles(target, organization, projectIdentifier);
		target.finish();
		target.close();
		out.flush();
	}

}<commit_msg>WQP-1155: Add logging to blob service<commit_after>package gov.usgs.cida.wqp.webservice;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipOutputStream;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import gov.usgs.cida.wqp.dao.BlobDao;
import gov.usgs.cida.wqp.parameter.FilterParameters;
import gov.usgs.cida.wqp.parameter.Parameters;
import gov.usgs.cida.wqp.service.ILogService;
import gov.usgs.cida.wqp.util.HttpConstants;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@RestController
public class BlobController {

	protected final BlobDao blobDao;
	protected final ILogService logService;
	
	private static ThreadLocal<BigDecimal> logId = new ThreadLocal<>();

	@Autowired
	public BlobController(BlobDao blobDao, ILogService inLogService) {
		this.blobDao = blobDao;
		logService = inLogService;
	}
	
	public static BigDecimal getLogId() {
		return logId.get();
	}

	public static void setLogId(BigDecimal inLogId) {
		logId.set(inLogId);
	}

	@ApiOperation(value="Return zipped artifact with all files available for the specified organization/project.")
	@GetMapping(value="/organizations/{organization}/projects/{projectIdentifier}/files")
	public void projectBlobFilesGetRestRequest(HttpServletRequest request, HttpServletResponse response, @ApiIgnore FilterParameters filter,
			@PathVariable("organization") String organization, @PathVariable("projectIdentifier") String projectIdentifier) throws IOException {
		List<String> projects = new ArrayList<>();
		response.setHeader(HttpConstants.HEADER_CONTENT_DISPOSITION,"attachment; filename=project.zip");
		projects.add(projectIdentifier);
		filter.setProject(projects);
		setLogId(logService.logRequest(request, response, filter));
		OutputStream out = response.getOutputStream();
		ZipOutputStream target = new ZipOutputStream(out);
		blobDao.getFiles(target, organization, projectIdentifier);
		target.finish();
		target.close();
		out.flush();
		logService.logRequestComplete(getLogId(), String.valueOf(response.getStatus()));
	}

}
{'fraction_non_alphanumeric': 0.10204572803850782, 'fraction_numerical': 0.0009626955475330926, 'mean_word_length': 6.931297709923665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3401532', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1172, 'n_words': 228}