<commit_before>package com.wemater.api;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
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.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;

import com.wemater.modal.UserModel;
import com.wemater.service.CacheService;
import com.wemater.service.UserService;

@Path("users")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UserResource {

	private UserService service;
	private CacheService<UserModel> cs;

	public UserResource() {
		this.service = new UserService();
		this.cs = new CacheService<UserModel>();

	}

	

	
	@GET
	public Response getAllUsers(@Context UriInfo uriInfo,
										@QueryParam("username") String username,
										@QueryParam("email") String email ,
										@QueryParam("verify") String verificationString
										
										) {
		

		if(username != null){
			System.out.println("username is "+username);
			return Response.ok(service.IfUsernameExist(username)).build();
		
		}
		if(email != null) {
			System.out.println("email is "+email);
			return Response.ok(service.ifEmailExist(email)).build();
		}
		if(verificationString != null){
			System.out.println("verificationString is "+verificationString);
			return Response.ok(service.verifyUserEmail(verificationString, uriInfo)).build();
			
		}  
		
		
		GenericEntity<List<UserModel>> entity = new GenericEntity<List<UserModel>>(
				service.getAllusers(uriInfo)) {
		};

		return Response.ok(entity).build();
	}

	@GET
	@Path("/{profileName}")
	public Response getUser(@HeaderParam("Authorization") String authString,
								@PathParam("profileName") String profilename,
								@Context UriInfo uriInfo,
								@Context Request request) {
		
		return cs.buildResponseWithCacheEtag(request, 
				service.getUser(authString, profilename, uriInfo)).build();

	}

	@POST
	public Response postUser(@Context UriInfo uriInfo, UserModel model) {
		
		return Response.status(Status.CREATED)
				.entity(service.postUser(model, uriInfo)).build();

	}

	@PUT
	@Path("/{profileName}")
	public Response updateUser(@HeaderParam("Authorization") String authString,
			@PathParam("profileName") String profilename, UserModel model,<commit_msg>update[cache removed in get user]<commit_after>package com.wemater.api;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
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.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;

import com.wemater.modal.UserModel;
import com.wemater.service.CacheService;
import com.wemater.service.UserService;

@Path("users")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UserResource {

	private UserService service;
	private CacheService<UserModel> cs;

	public UserResource() {
		this.service = new UserService();
		this.cs = new CacheService<UserModel>();

	}

	

	
	@GET
	public Response getAllUsers(@Context UriInfo uriInfo,
										@QueryParam("username") String username,
										@QueryParam("email") String email ,
										@QueryParam("verify") String verificationString
										
										) {
		

		if(username != null){
			System.out.println("username is "+username);
			return Response.ok(service.IfUsernameExist(username)).build();
		
		}
		if(email != null) {
			System.out.println("email is "+email);
			return Response.ok(service.ifEmailExist(email)).build();
		}
		if(verificationString != null){
			System.out.println("verificationString is "+verificationString);
			return Response.ok(service.verifyUserEmail(verificationString, uriInfo)).build();
			
		}  
		
		
		GenericEntity<List<UserModel>> entity = new GenericEntity<List<UserModel>>(
				service.getAllusers(uriInfo)) {
		};

		return Response.ok(entity).build();
	}

	@GET
	@Path("/{profileName}")
	public Response getUser(@HeaderParam("Authorization") String authString,
								@PathParam("profileName") String profilename,
								@Context UriInfo uriInfo) {
		return Response.ok(service.getUser(authString, profilename, uriInfo)).build();
		
	

	}

	@POST
	public Response postUser(@Context UriInfo uriInfo, UserModel model) {
		
		return Response.status(Status.CREATED)
				.entity(service.postUser(model, uriInfo)).build();

	}

	@PUT
	@Path("/{profileName}")
	public Response updateUser(@HeaderParam("Authorization") String authString,
			@PathParam("profileName") String profilename, UserModel model,
{'fraction_non_alphanumeric': 0.1304095826893354, 'fraction_numerical': 0.0, 'mean_word_length': 4.507446808510639, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3224766', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1602, 'n_words': 305}