<commit_before>package no.deichman.services.repository;

import no.deichman.services.uridefaults.BaseURI;
import org.apache.commons.lang3.RandomStringUtils;

public class UniqueURI {

    public static final int NO_OF_DIGITS = 12;

    private String getRandom() {
        return RandomStringUtils.randomNumeric(NO_OF_DIGITS);
    }

    private String getRandom(String type, BaseURI baseURI) {
        String random;
        switch (type) {
            case "work":        random = baseURI.getWorkURI() + "w" + getRandom();
                break;
            case "publication": random = baseURI.getPublicationURI() + "p" + getRandom();
                break;
            default:            random = null;
                break;
        }

        if (random == null) {
            throw new IllegalArgumentException("Unknown URI-type");
        }
        return random;

    }

    public String getNewURI(String type, Repository repository, BaseURI baseURI) {
        String random = null;
        boolean exists = true;

        while (exists) {
            random = getRandom(type, baseURI);
            exists = checkResourceExistence(random, repository);
        }
        return random;

    }

    boolean checkResourceExistence(String random, Repository repository) {
        return repository.askIfResourceExists(random);
    }

}<commit_msg>Reduce scope of UniqueURI to package.<commit_after>package no.deichman.services.repository;

import no.deichman.services.uridefaults.BaseURI;
import org.apache.commons.lang3.RandomStringUtils;

class UniqueURI {

    private static final int NO_OF_DIGITS = 12;

    private String getRandom() {
        return RandomStringUtils.randomNumeric(NO_OF_DIGITS);
    }

    private String getRandom(String type, BaseURI baseURI) {
        String random;
        switch (type) {
            case "work":        random = baseURI.getWorkURI() + "w" + getRandom();
                break;
            case "publication": random = baseURI.getPublicationURI() + "p" + getRandom();
                break;
            default:            random = null;
                break;
        }

        if (random == null) {
            throw new IllegalArgumentException("Unknown URI-type");
        }
        return random;

    }

    String getNewURI(String type, Repository repository, BaseURI baseURI) {
        String random = null;
        boolean exists = true;

        while (exists) {
            random = getRandom(type, baseURI);
            exists = checkResourceExistence(random, repository);
        }
        return random;

    }

    boolean checkResourceExistence(String random, Repository repository) {
        return repository.askIfResourceExists(random);
    }

}
{'fraction_non_alphanumeric': 0.0886355277675616, 'fraction_numerical': 0.002206693637366679, 'mean_word_length': 2.2037691401649, 'pattern_counts': {'":': 4, '<': 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': '1466146', 'n_tokens_mistral': 741, 'n_tokens_neox': 702, 'n_words': 179}