<commit_before>package com.enseirb.telecom.s9;

import java.net.URI;
import java.net.URISyntaxException;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.enseirb.telecom.s9.db.UserRepositoryMongo;
import com.enseirb.telecom.s9.service.AccountService;
import com.enseirb.telecom.s9.service.AccountServiceImpl;
import com.sun.jersey.spi.resource.Singleton;

// The Java class will be hosted at the URI path "/app/account"
@Path("/app/account")
@Singleton //NHE: lifecycle for demo purpose, make only 1 endpoint per application
public class UserEndPoints {

	AccountService uManager = new AccountServiceImpl(new UserRepositoryMongo());

	// TODO: update the class to suit your needs

	// The Java method will process HTTP GET requests
	// The Java method will produce content identified by the MIME Media
	// type "text/plain"
	@GET
	@Path("{email}")
	@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public User getIt(@PathParam("email") String email) {
		return uManager.getUser(email);
	}

	@POST
	@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public Response postUser(User user) throws URISyntaxException {
		if (uManager.userExist(user.email) == false) {
			uManager.saveUser(user);
			//NHE that the answer we expect from a post (see location header)
			return Response.created(new URI(user.email)).build();
		} else {
			return Response.status(409).build();
		}

	}

	@PUT
	@Path("{username}")
	@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public Response putUser(User user) {<commit_msg>put fix<commit_after>package com.enseirb.telecom.s9;

import java.net.URI;
import java.net.URISyntaxException;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.enseirb.telecom.s9.db.UserRepositoryMongo;
import com.enseirb.telecom.s9.service.AccountService;
import com.enseirb.telecom.s9.service.AccountServiceImpl;
import com.sun.jersey.spi.resource.Singleton;

// The Java class will be hosted at the URI path "/app/account"
@Path("/app/account")
@Singleton //NHE: lifecycle for demo purpose, make only 1 endpoint per application
public class UserEndPoints {

	AccountService uManager = new AccountServiceImpl(new UserRepositoryMongo());

	// TODO: update the class to suit your needs

	// The Java method will process HTTP GET requests
	// The Java method will produce content identified by the MIME Media
	// type "text/plain"
	@GET
	@Path("{email}")
	@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public User getIt(@PathParam("email") String email) {
		return uManager.getUser(email);
	}

	@POST
	@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public Response postUser(User user) throws URISyntaxException {
		if (uManager.userExist(user.email) == false) {
			uManager.saveUser(user);
			//NHE that the answer we expect from a post (see location header)
			return Response.created(new URI(user.email)).build();
		} else {
			return Response.status(409).build();
		}

	}

	@PUT
	@Path("{email}")
	@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public Response putUser(User user) {
{'fraction_non_alphanumeric': 0.1186581646797893, 'fraction_numerical': 0.004435819240365955, 'mean_word_length': 4.8381877022653725, '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': '2010400', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1175, 'n_words': 297}