@Test public void testListFiles() throws IOException, IndexerException { final String projectName = "mercurial"; GenericType<List<String>> type = new GenericType<List<String>>() {}; Indexer.getInstance().prepareIndexer( env, false, true, false, new ArrayList<>(), new ArrayList<>()); Indexer.getInstance().doIndexerExecution(true, null, null); List<String> filesFromRequest = target("projects") .path(projectName) .path("files") .request() .get(type); filesFromRequest.sort(String::compareTo); String files[] = {"Makefile", "bar.txt", "header.h", "main.c", "novel.txt"}; for (int i = 0; i < files.length; i++) { files[i] = "/" + projectName + "/" + files[i]; } List<String> expectedFiles = Arrays.asList(files); expectedFiles.sort(String::compareTo); assertEquals(expectedFiles, filesFromRequest); }
@GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) public Object get(@PathParam("project") String projectName, @PathParam("field") String field) throws IOException { projectName = Laundromat.launderInput(projectName); field = Laundromat.launderInput(field); Project project = env.getProjects().get(projectName); if (project == null) { throw new WebApplicationException( "cannot find project " + projectName + " to get a property", Response.Status.BAD_REQUEST); } return ClassUtil.getFieldValue(project, field); }
ProjectsController { @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) public Object get(@PathParam("project") String projectName, @PathParam("field") String field) throws IOException { projectName = Laundromat.launderInput(projectName); field = Laundromat.launderInput(field); Project project = env.getProjects().get(projectName); if (project == null) { throw new WebApplicationException( "cannot find project " + projectName + " to get a property", Response.Status.BAD_REQUEST); } return ClassUtil.getFieldValue(project, field); } }
ProjectsController { @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) public Object get(@PathParam("project") String projectName, @PathParam("field") String field) throws IOException { projectName = Laundromat.launderInput(projectName); field = Laundromat.launderInput(field); Project project = env.getProjects().get(projectName); if (project == null) { throw new WebApplicationException( "cannot find project " + projectName + " to get a property", Response.Status.BAD_REQUEST); } return ClassUtil.getFieldValue(project, field); }  }
ProjectsController { @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) public Object get(@PathParam("project") String projectName, @PathParam("field") String field) throws IOException { projectName = Laundromat.launderInput(projectName); field = Laundromat.launderInput(field); Project project = env.getProjects().get(projectName); if (project == null) { throw new WebApplicationException( "cannot find project " + projectName + " to get a property", Response.Status.BAD_REQUEST); } return ClassUtil.getFieldValue(project, field); }  @POST @Consumes(MediaType.TEXT_PLAIN) Response addProject(String projectName); @DELETE @Path("/{project}") void deleteProject(@PathParam("project") String projectName); @DELETE @Path("/{project}/data") void deleteProjectData(@PathParam("project") String projectName); @DELETE @Path("/{project}/historycache") void deleteHistoryCache(@PathParam("project") String projectName); @PUT @Path("/{project}/indexed") @Consumes(MediaType.TEXT_PLAIN) void markIndexed(@PathParam("project") String projectName); @PUT @Path("/{project}/property/{field}") void set(
            @PathParam("project") String projectName,
            @PathParam("field") String field,
            final String value
    ); @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) Object get(@PathParam("project") String projectName, @PathParam("field") String field); @GET @Produces(MediaType.APPLICATION_JSON) List<String> listProjects(); @GET @Path("indexed") @Produces(MediaType.APPLICATION_JSON) List<String> listIndexed(); @GET @Path("/{project}/repositories") @Produces(MediaType.APPLICATION_JSON) List<String> getRepositories(@PathParam("project") String projectName); @GET @Path("/{project}/repositories/type") @Produces(MediaType.APPLICATION_JSON) Set<String> getRepositoriesType(@PathParam("project") String projectName); @GET @Path("/{project}/files") @Produces(MediaType.APPLICATION_JSON) Set<String> getProjectIndexFiles(@PathParam("project") String projectName); }
ProjectsController { @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) public Object get(@PathParam("project") String projectName, @PathParam("field") String field) throws IOException { projectName = Laundromat.launderInput(projectName); field = Laundromat.launderInput(field); Project project = env.getProjects().get(projectName); if (project == null) { throw new WebApplicationException( "cannot find project " + projectName + " to get a property", Response.Status.BAD_REQUEST); } return ClassUtil.getFieldValue(project, field); }  @POST @Consumes(MediaType.TEXT_PLAIN) Response addProject(String projectName); @DELETE @Path("/{project}") void deleteProject(@PathParam("project") String projectName); @DELETE @Path("/{project}/data") void deleteProjectData(@PathParam("project") String projectName); @DELETE @Path("/{project}/historycache") void deleteHistoryCache(@PathParam("project") String projectName); @PUT @Path("/{project}/indexed") @Consumes(MediaType.TEXT_PLAIN) void markIndexed(@PathParam("project") String projectName); @PUT @Path("/{project}/property/{field}") void set(
            @PathParam("project") String projectName,
            @PathParam("field") String field,
            final String value
    ); @GET @Path("/{project}/property/{field}") @Produces(MediaType.APPLICATION_JSON) Object get(@PathParam("project") String projectName, @PathParam("field") String field); @GET @Produces(MediaType.APPLICATION_JSON) List<String> listProjects(); @GET @Path("indexed") @Produces(MediaType.APPLICATION_JSON) List<String> listIndexed(); @GET @Path("/{project}/repositories") @Produces(MediaType.APPLICATION_JSON) List<String> getRepositories(@PathParam("project") String projectName); @GET @Path("/{project}/repositories/type") @Produces(MediaType.APPLICATION_JSON) Set<String> getRepositoriesType(@PathParam("project") String projectName); @GET @Path("/{project}/files") @Produces(MediaType.APPLICATION_JSON) Set<String> getProjectIndexFiles(@PathParam("project") String projectName);  }