<commit_before>package controllers;

import models.Account;
import models.enums.CustomContentType;
import net.hamnaberg.json.*;
import net.hamnaberg.json.Error;
import play.mvc.Result;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


public class APIUserController extends BaseController {

    public static Result get(final Long id) {
        if (request().getHeader("Accept").contains(CustomContentType.JSON_COLLECTION.getIdentifier())) {
            URI uri = URI.create(request().host() + request().path());
            Error error = Error.EMPTY;
            List<Item> items = null;

            if (id == 0) {  // http GET .../users
                items = Account.all()
                        .stream()
                        .map(a -> Item.create(URI.create(uri.toString() + "/" + a.id), a.getProperies()))
                        .collect(Collectors.toList());

            } else {  // http GET .../users/:id
                Account account = Account.findById(id);
                items = new ArrayList<Item>();
                if (account == null) {
                    error = net.hamnaberg.json.Error.create("Account not found", "404", "The " +<commit_msg>Fixed missing protocol in URI<commit_after>package controllers;

import models.Account;
import models.enums.CustomContentType;
import net.hamnaberg.json.*;
import net.hamnaberg.json.Error;
import play.mvc.Result;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


public class APIUserController extends BaseController {

    public static Result get(final Long id) {
        if (request().getHeader("Accept").contains(CustomContentType.JSON_COLLECTION.getIdentifier())) {

            // I don't like the way they did it, but that's the way this framework fixed the protocol thing
            // https://github.com/playframework/playframework/issues/842
            String protocol = request().secure() ? "https://" : "http://";
            
            URI uri = URI.create(protocol + request().host() + request().path());

            Error error = Error.EMPTY;
            List<Item> items = null;

            if (id == 0) {  // http GET .../users
                items = Account.all()
                        .stream()
                        .map(a -> Item.create(URI.create(uri.toString() + "/" + a.id), a.getProperies()))
                        .collect(Collectors.toList());

            } else {  // http GET .../users/:id
                Account account = Account.findById(id);
                items = new ArrayList<Item>();
                if (account == null) {
                    error = net.hamnaberg.json.Error.create("Account not found", "404", "The " +
{'fraction_non_alphanumeric': 0.13412870571221983, 'fraction_numerical': 0.0039768618944323935, 'mean_word_length': 2.098544232922732, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1442504', 'n_tokens_mistral': 764, 'n_tokens_neox': 735, 'n_words': 181}