<commit_before>package cronapi;

import com.google.gson.JsonObject;
import cronapi.database.TenantService;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

public class RestClient {

	private static ThreadLocal<RestClient> REST_CLIENT = new ThreadLocal<RestClient>();

	private LinkedList<ClientCommand> commands = new LinkedList<>();
	private HttpServletResponse response = CronapiFilter.RESPONSE.get();
	private HttpServletRequest request = CronapiFilter.REQUEST.get();
	private JsonObject query = null;
	private boolean filteredEnabled = false;

	private static List<GrantedAuthority> DEFAULT_AUTHORITIES;

	static {
		DEFAULT_AUTHORITIES = new ArrayList<>();
		DEFAULT_AUTHORITIES.add(new SimpleGrantedAuthority("authenticated"));
	}

	private RestBody body;

	private Var rawBody;

	private TenantService tenantService;

	public static RestClient getRestClient() {
		RestClient restClient = REST_CLIENT.get();
		if (restClient == null) {
			restClient =  new RestClient();
			REST_CLIENT.set(restClient);
		}

		return restClient;
	}

	public static void removeClient() {
		REST_CLIENT.set(null);
		REST_CLIENT.remove();
	}

	public ClientCommand addCommand(ClientCommand command) {
		commands.add(command);
		return command;
	}

	public ClientCommand addCommand(String name) {
		ClientCommand command = new ClientCommand(name);
		commands.add(command);
		return command;
	}

	public LinkedList<ClientCommand> getCommands() {
		return commands;
	}

	public RestBody getBody() {
		if (body == null)
			body = new RestBody();
		return body;
	}

	public void setBody(RestBody body) {
		this.body = body;
	}

	public Var getRawBody() {
		return rawBody;
	}

	public void setRawBody(Var rawBody) {
		this.rawBody = rawBody;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public String getParameter(String key) {
		return request.getParameter(key);
	}

	public String getMethod() {
		return request.getMethod();
	}

	public JsonObject getQuery() {
		return query;
	}

	public void setQuery(JsonObject query) {<commit_msg>Verificação de existe o Request <commit_after>package cronapi;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

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

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

import com.google.gson.JsonObject;

import cronapi.database.TenantService;

public class RestClient {

	private static ThreadLocal<RestClient> REST_CLIENT = new ThreadLocal<RestClient>();

	private LinkedList<ClientCommand> commands = new LinkedList<>();
	private HttpServletResponse response = CronapiFilter.RESPONSE.get();
	private HttpServletRequest request = CronapiFilter.REQUEST.get();
	private JsonObject query = null;
	private boolean filteredEnabled = false;

	private static List<GrantedAuthority> DEFAULT_AUTHORITIES;

	static {
		DEFAULT_AUTHORITIES = new ArrayList<>();
		DEFAULT_AUTHORITIES.add(new SimpleGrantedAuthority("authenticated"));
	}

	private RestBody body;

	private Var rawBody;

	private TenantService tenantService;

	public static RestClient getRestClient() {
		RestClient restClient = REST_CLIENT.get();
		if (restClient == null) {
			restClient =  new RestClient();
			REST_CLIENT.set(restClient);
		}

		return restClient;
	}

	public static void removeClient() {
		REST_CLIENT.set(null);
		REST_CLIENT.remove();
	}

	public ClientCommand addCommand(ClientCommand command) {
		commands.add(command);
		return command;
	}

	public ClientCommand addCommand(String name) {
		ClientCommand command = new ClientCommand(name);
		commands.add(command);
		return command;
	}

	public LinkedList<ClientCommand> getCommands() {
		return commands;
	}

	public RestBody getBody() {
		if (body == null)
			body = new RestBody();
		return body;
	}

	public void setBody(RestBody body) {
		this.body = body;
	}

	public Var getRawBody() {
		return rawBody;
	}

	public void setRawBody(Var rawBody) {
		this.rawBody = rawBody;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public String getParameter(String key) {
		return request.getParameter(key);
	}

	public String getMethod() {
	   if (request == null)
	      request = CronapiFilter.REQUEST.get();
		return request.getMethod();
	}

	public JsonObject getQuery() {
		return query;
	}

	public void setQuery(JsonObject query) {
{'fraction_non_alphanumeric': 0.09524744697564808, 'fraction_numerical': 0.0, 'mean_word_length': 5.143546441495778, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2255946', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1484, 'n_words': 362}