<commit_before>package com.rueckert.customer.controller;

import java.io.IOException;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rueckert.customer.config.CloudConfig;
import com.rueckert.customer.domain.Customer;
import com.rueckert.customer.repositories.CustomerRepository;

@RestController
@ResponseStatus(value = HttpStatus.CREATED)
public class CustomerController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	private CustomerRepository repository;
	private RabbitTemplate rabbitTemplate;
	private ObjectMapper objectMapper = new ObjectMapper();

	@Autowired
	public void setRepository(CustomerRepository repository) {
		this.repository = repository;
	}

	@Autowired
	public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
		this.rabbitTemplate = rabbitTemplate;
	}

	@RequestMapping(value = "/customer", method = RequestMethod.GET)
	@ResponseStatus(code = HttpStatus.OK)
	public Iterable<Customer> getCustomers() {
		String instanceIndex = retrieveInstanceIndex();
		logger.info(String.format("Instance Index {%s}", instanceIndex));

		return repository.findAll();
	}

	private String retrieveInstanceIndex() {
		String vcapApplication = System.getenv("VCAP_APPLICATION");
		try {
			JsonNode jsonNode = objectMapper.readValue(vcapApplication, JsonNode.class);
			JsonNode instanceIndex = jsonNode.get("instance_index");
			return instanceIndex.asText();
		} catch (IOException e) {
			return "Unknown";
		}
	}

	@RequestMapping(value = "/customer/{id}", method = RequestMethod.GET)
	@ResponseStatus(code = HttpStatus.OK)<commit_msg>Added a version indicator for testing and added manifest files for deployment.<commit_after>package com.rueckert.customer.controller;

import java.io.IOException;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.rueckert.customer.config.CloudConfig;
import com.rueckert.customer.domain.Customer;
import com.rueckert.customer.repositories.CustomerRepository;

@RestController
@ResponseStatus(value = HttpStatus.CREATED)
public class CustomerController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	private CustomerRepository repository;
	private RabbitTemplate rabbitTemplate;
	private ObjectMapper objectMapper = new ObjectMapper();

	@Autowired
	public void setRepository(CustomerRepository repository) {
		this.repository = repository;
	}

	@Autowired
	public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
		this.rabbitTemplate = rabbitTemplate;
	}

	@RequestMapping(value = "/customer", method = RequestMethod.GET)
	@ResponseStatus(code = HttpStatus.OK)
	public Iterable<Customer> getCustomers() {
		String instanceIndex = retrieveInstanceIndex();
		logger.info(String.format("Current version {%s}", "6"));
		logger.info(String.format("Instance Index {%s}", instanceIndex));

		return repository.findAll();
	}

	private String retrieveInstanceIndex() {
		String vcapApplication = System.getenv("VCAP_APPLICATION");
		try {
			JsonNode jsonNode = objectMapper.readValue(vcapApplication, JsonNode.class);
			JsonNode instanceIndex = jsonNode.get("instance_index");
			return instanceIndex.asText();
		} catch (IOException e) {
			return "Unknown";
		}
	}

	@RequestMapping(value = "/customer/{id}", method = RequestMethod.GET)
	@ResponseStatus(code = HttpStatus.OK)
{'fraction_non_alphanumeric': 0.10231578947368421, 'fraction_numerical': 0.0010526315789473684, 'mean_word_length': 6.5532591414944354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2893970', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1284, 'n_words': 256}