<commit_before>package org.jboss.da.rest.reports;

import org.apache.commons.lang.NotImplementedException;
import org.jboss.da.communication.CommunicationException;
import org.jboss.da.communication.model.GAV;
import org.jboss.da.listings.api.service.BlackArtifactService;
import org.jboss.da.listings.api.service.WhiteArtifactService;
import org.jboss.da.reports.api.ArtifactReport;
import org.jboss.da.reports.api.ReportsGenerator;
import org.jboss.da.reports.api.VersionLookupResult;
import org.jboss.da.reports.backend.api.VersionFinder;
import org.jboss.da.rest.reports.model.LookupReport;
import org.jboss.da.rest.reports.model.Report;
import org.jboss.da.rest.reports.model.SCMRequest;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

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

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;

/**
 * Main end point for the reports
 * 
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 *
 */
@Path("/reports")
@Api(value = "/reports", description = "Get report of dependencies of projects")
public class Reports {

    @Inject
    private VersionFinder versionFinder;

    @Inject
    private ReportsGenerator reportsGenerator;

    @Inject
    private WhiteArtifactService whiteArtifactService;

    @Inject
    private BlackArtifactService blackArtifactService;

    @POST
    @Path("/scm")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Get dependency report for a project specified in a repository URL",
            hidden = true)
    // TODO unhide when the method will be implemented
    public Report scmGenerator(SCMRequest scmRequest) {
        throw new NotImplementedException();
    }

    @POST
    @Path("/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(
            value = "Get dependency report for a GAV " // TODO change when dependencies will be implemented
                    + "(Currently the dependencies and dependency_versions_satisfied don't contains usefull values)")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Report was successfully generated"),
            @ApiResponse(code = 404,
                    message = "Requested GA was not found or the repository is not available") })
    public Response gavGenerator(GAV gavRequest) {
        ArtifactReport artifactReport = reportsGenerator.getReport(gavRequest);
        if (artifactReport == null)
            return Response
                    .status(Status.NOT_FOUND)
                    .entity("{\"message\": \"Requested GA was not found or the repository is not available\"}")
                    .build();
        else
            return Response.ok().entity(toReport(artifactReport)).build();
    }

    @POST
    @Path("/lookup/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Lookup built versions for the list of provided GAVs")
    @ApiResponses(
            value = {
                    @ApiResponse(code = 200, message = "Lookup report was successfully generated"),
                    @ApiResponse(
                            code = 206,
                            message = "Lookup report was generated, but at least one of the requested GAs "
                                    + "was not found or the repository was not available"),
                    @ApiResponse(
                            code = 404,
                            message = "None of the requested GAs was found or the repository is not available") })
    public Response lookupGav(List<GAV> gavRequest) {
        List<LookupReport> reportsList = new ArrayList<>();
        int responseStatus = 200;
        for (GAV gav : gavRequest) {
            try {
                reportsList.add(toLookupReport(gav));
            } catch (CommunicationException e) {
                responseStatus = 206; // Partial Content HTTP code
            }
        }

        if (reportsList.isEmpty())
            return Response
                    .status(Status.NOT_FOUND)
                    .entity("{\"message\": \"None of the requested GAs was not found or the repository is not available\"}")
                    .build();
        else
            return Response.status(responseStatus).entity(reportsList).build();
    }<commit_msg>Minor issue with error message for reports lookup<commit_after>package org.jboss.da.rest.reports;

import org.apache.commons.lang.NotImplementedException;
import org.jboss.da.communication.CommunicationException;
import org.jboss.da.communication.model.GAV;
import org.jboss.da.listings.api.service.BlackArtifactService;
import org.jboss.da.listings.api.service.WhiteArtifactService;
import org.jboss.da.reports.api.ArtifactReport;
import org.jboss.da.reports.api.ReportsGenerator;
import org.jboss.da.reports.api.VersionLookupResult;
import org.jboss.da.reports.backend.api.VersionFinder;
import org.jboss.da.rest.reports.model.LookupReport;
import org.jboss.da.rest.reports.model.Report;
import org.jboss.da.rest.reports.model.SCMRequest;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

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

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;

/**
 * Main end point for the reports
 * 
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 *
 */
@Path("/reports")
@Api(value = "/reports", description = "Get report of dependencies of projects")
public class Reports {

    @Inject
    private VersionFinder versionFinder;

    @Inject
    private ReportsGenerator reportsGenerator;

    @Inject
    private WhiteArtifactService whiteArtifactService;

    @Inject
    private BlackArtifactService blackArtifactService;

    @POST
    @Path("/scm")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Get dependency report for a project specified in a repository URL",
            hidden = true)
    // TODO unhide when the method will be implemented
    public Report scmGenerator(SCMRequest scmRequest) {
        throw new NotImplementedException();
    }

    @POST
    @Path("/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(
            value = "Get dependency report for a GAV " // TODO change when dependencies will be implemented
                    + "(Currently the dependencies and dependency_versions_satisfied don't contains usefull values)")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Report was successfully generated"),
            @ApiResponse(code = 404,
                    message = "Requested GA was not found or the repository is not available") })
    public Response gavGenerator(GAV gavRequest) {
        ArtifactReport artifactReport = reportsGenerator.getReport(gavRequest);
        if (artifactReport == null)
            return Response
                    .status(Status.NOT_FOUND)
                    .entity("{\"message\": \"Requested GA was not found or the repository is not available\"}")
                    .build();
        else
            return Response.ok().entity(toReport(artifactReport)).build();
    }

    @POST
    @Path("/lookup/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Lookup built versions for the list of provided GAVs")
    @ApiResponses(
            value = {
                    @ApiResponse(code = 200, message = "Lookup report was successfully generated"),
                    @ApiResponse(
                            code = 206,
                            message = "Lookup report was generated, but at least one of the requested GAs "
                                    + "was not found or the repository was not available"),
                    @ApiResponse(
                            code = 404,
                            message = "None of the requested GAs was found or the repository is not available") })
    public Response lookupGav(List<GAV> gavRequest) {
        List<LookupReport> reportsList = new ArrayList<>();
        int responseStatus = 200;
        for (GAV gav : gavRequest) {
            try {
                reportsList.add(toLookupReport(gav));
            } catch (CommunicationException e) {
                responseStatus = 206; // Partial Content HTTP code
            }
        }

        if (reportsList.isEmpty())
            return Response
                    .status(Status.NOT_FOUND)
                    .entity("{\"message\": \"None of the requested GAs was found or the repository is not available\"}")
                    .build();
        else
            return Response.status(responseStatus).entity(reportsList).build();
    }
{'fraction_non_alphanumeric': 0.09672681493915233, 'fraction_numerical': 0.0044062106588334034, 'mean_word_length': 2.623337134169517, 'pattern_counts': {'":': 4, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4044249', 'n_tokens_mistral': 2686, 'n_tokens_neox': 2542, 'n_words': 654}