<commit_before>package org.slc.sli.shtick;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

/**
 * @author jstokes
 */
public final class StandardLevel2ClientManual implements Level2ClientManual {

    private final String baseUrl;
    private final Level1Client client;

    protected StandardLevel2ClientManual(final String baseUrl, final Level1Client client) {
        if (baseUrl == null) {
            throw new NullPointerException("baseUrl");
        }

        this.client = client;
        this.baseUrl = baseUrl;
    }

    public StandardLevel2ClientManual(final String baseUrl) {
        this(baseUrl, new JsonLevel1Client());
    }

    @Override
    public List<RestEntity> getStudentsByStudentId(final String token, final List<String> studentIds,
            Map<String, Object> queryArgs) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        if (studentIds == null) {
            throw new NullPointerException("studentIds");
        }
        try {
            final String path = String.format("students/%s", StringUtils.join(studentIds, ','));
            final URLBuilder builder = URLBuilder.baseUrl(baseUrl).addPath(path).query(queryArgs);
            final URL url = builder.build();
            return client.getRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public List<RestEntity> getStudents(final String token, Map<String, Object> queryArgs) throws IOException,
            RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        try {
            final String path = String.format("students");
            final URLBuilder builder = URLBuilder.baseUrl(baseUrl).addPath(path).query(queryArgs);
            final URL url = builder.build();
            return client.getRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public void deleteStudentById(final String token, final String studentId) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        try {
            final URL url = URLBuilder.baseUrl(baseUrl).entityType("student").id(studentId).build();
            client.deleteRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public String postStudent(final String token, final RestEntity entity) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        if (entity == null) {
            throw new NullPointerException("entity");
        }
        try {
            final URL url = URLBuilder.baseUrl(baseUrl).entityType("student").build();
            final URL studentURL = client.postRequest(token, entity, url);<commit_msg>The quest to kill URLBuilder.entityType<commit_after>package org.slc.sli.shtick;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

/**
 * @author jstokes
 */
public final class StandardLevel2ClientManual implements Level2ClientManual {

    private final String baseUrl;
    private final Level1Client client;

    protected StandardLevel2ClientManual(final String baseUrl, final Level1Client client) {
        if (baseUrl == null) {
            throw new NullPointerException("baseUrl");
        }

        this.client = client;
        this.baseUrl = baseUrl;
    }

    public StandardLevel2ClientManual(final String baseUrl) {
        this(baseUrl, new JsonLevel1Client());
    }

    @Override
    public List<RestEntity> getStudentsByStudentId(final String token, final List<String> studentIds,
            Map<String, Object> queryArgs) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        if (studentIds == null) {
            throw new NullPointerException("studentIds");
        }
        try {
            final String path = String.format("students/%s", StringUtils.join(studentIds, ','));
            final URLBuilder builder = URLBuilder.baseUrl(baseUrl).addPath(path).query(queryArgs);
            final URL url = builder.build();
            return client.getRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public List<RestEntity> getStudents(final String token, Map<String, Object> queryArgs) throws IOException,
            RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        try {
            final String path = String.format("students");
            final URLBuilder builder = URLBuilder.baseUrl(baseUrl).addPath(path).query(queryArgs);
            final URL url = builder.build();
            return client.getRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public void deleteStudentById(final String token, final String entityId) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        try {
            final String path = String.format("students/%s", entityId);
            final URLBuilder builder = URLBuilder.baseUrl(baseUrl).addPath(path);
            final URL url = builder.build();
            client.deleteRequest(token, url);
        } catch (final URISyntaxException e) {
            throw new AssertionError(e);
        }
    }

    @Override
    public String postStudent(final String token, final RestEntity entity) throws IOException, RestException {
        if (token == null) {
            throw new NullPointerException("token");
        }
        if (entity == null) {
            throw new NullPointerException("entity");
        }
        try {
            final URL url = URLBuilder.baseUrl(baseUrl).entityType("student").build();
            final URL studentURL = client.postRequest(token, entity, url);
{'fraction_non_alphanumeric': 0.09701838405685154, 'fraction_numerical': 0.0024718059632318863, 'mean_word_length': 2.507042253521127, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6276239', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1658, 'n_words': 438}