<commit_before>package io.teiler.api.endpoint;

import static spark.Spark.before;
import static spark.Spark.get;
import static spark.Spark.post;

import com.google.gson.Gson;
import io.teiler.server.dto.Group;
import io.teiler.server.persistence.entities.GroupEntity;
import io.teiler.server.persistence.repositories.GroupRepository;
import java.security.interfaces.ECKey;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.security.SecureRandom;
import java.math.BigInteger;


@Component
public class GroupEndpoint implements Endpoint {

    private SecureRandom random = new SecureRandom();
    private Gson gson = new Gson();

    private static final Logger LOGGER = LoggerFactory.getLogger(GroupEndpoint.class);
    @Autowired
    private GroupRepository groupRepository;

    private static final int NUMBER_OF_ID_CHARACTERS = 8;
    private static final String GROUP_ID_HEADER = "X-Teiler-GroupID";

    @Override
    public void register() {
        before((req, res) -> LOGGER.debug("API call to '" + req.pathInfo() + "'"));

        post("/v1/group", (req, res) -> {
            Group requestGroup = gson.fromJson(req.body(), Group.class);

            requestGroup.setUuid(createNewUuid());
            LOGGER.debug("New Group: " + requestGroup.getName() + ", " + requestGroup.getUuid());

            Group responseGroup = new Group(
                groupRepository.create(requestGroup.getUuid(), requestGroup.getName()));

            return gson.toJson(responseGroup);
        });

        get("/v1/group", (req, res) -> {
            String uuid = req.headers(GROUP_ID_HEADER);
            LOGGER.debug("Request with group ID: " + uuid);

            Group responseGroup = new Group(groupRepository.get(uuid));

            return gson.toJson(responseGroup);
        });


    }

    // this needs to go somewhere else
    private String createNewUuid() {
        String uuid = null;
        List<String> allIds = groupRepository.getAllIds();
        do {
            uuid = new BigInteger(NUMBER_OF_ID_CHARACTERS * 5, random).toString(32);
        } while (allIds.contains(uuid));
        return uuid;
    }
}<commit_msg>Fix unneeded assignment, remove unneded imports<commit_after>package io.teiler.api.endpoint;

import static spark.Spark.before;
import static spark.Spark.get;
import static spark.Spark.post;

import com.google.gson.Gson;
import io.teiler.server.dto.Group;
import io.teiler.server.persistence.repositories.GroupRepository;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.security.SecureRandom;
import java.math.BigInteger;


@Component
public class GroupEndpoint implements Endpoint {

    private SecureRandom random = new SecureRandom();
    private Gson gson = new Gson();

    private static final Logger LOGGER = LoggerFactory.getLogger(GroupEndpoint.class);
    @Autowired
    private GroupRepository groupRepository;

    private static final int NUMBER_OF_ID_CHARACTERS = 8;
    private static final String GROUP_ID_HEADER = "X-Teiler-GroupID";

    @Override
    public void register() {
        before((req, res) -> LOGGER.debug("API call to '" + req.pathInfo() + "'"));

        post("/v1/group", (req, res) -> {
            Group requestGroup = gson.fromJson(req.body(), Group.class);

            requestGroup.setUuid(createNewUuid());
            LOGGER.debug("New Group: " + requestGroup.getName() + ", " + requestGroup.getUuid());

            Group responseGroup = new Group(
                groupRepository.create(requestGroup.getUuid(), requestGroup.getName()));

            return gson.toJson(responseGroup);
        });

        get("/v1/group", (req, res) -> {
            String uuid = req.headers(GROUP_ID_HEADER);
            LOGGER.debug("Request with group ID: " + uuid);

            Group responseGroup = new Group(groupRepository.get(uuid));

            return gson.toJson(responseGroup);
        });


    }

    // this needs to go somewhere else
    private String createNewUuid() {
        String uuid;
        List<String> allIds = groupRepository.getAllIds();
        do {
            uuid = new BigInteger(NUMBER_OF_ID_CHARACTERS * 5, random).toString(32);
        } while (allIds.contains(uuid));
        return uuid;
    }
}
{'fraction_non_alphanumeric': 0.11315789473684211, 'fraction_numerical': 0.0035087719298245615, 'mean_word_length': 3.131340579710145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1368013', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1303, 'n_words': 294}