use of jakarta.ws.rs.NotFoundException in project metrics by dropwizard.
the class SingletonMetricsJerseyTest method testResourceNotFound.
@Test
public void testResourceNotFound() {
final Response response = target().path("not-found").request().get();
assertThat(response.getStatus()).isEqualTo(404);
try {
target().path("not-found").request().get(ClientResponse.class);
failBecauseExceptionWasNotThrown(NotFoundException.class);
} catch (NotFoundException e) {
assertThat(e.getMessage()).isEqualTo("HTTP 404 Not Found");
}
}
use of jakarta.ws.rs.NotFoundException in project OpenGrok by OpenGrok.
the class ProjectsController method markIndexed.
@PUT
@Path("/{project}/indexed")
@Consumes(MediaType.TEXT_PLAIN)
public Response markIndexed(@Context HttpServletRequest request, @PathParam("project") String projectNameParam) {
// Avoid classification as a taint bug.
final String projectName = Laundromat.launderInput(projectNameParam);
Project project = env.getProjects().get(projectName);
if (project == null) {
LOGGER.log(Level.WARNING, "cannot find project {0} to mark as indexed", projectName);
throw new NotFoundException(String.format("project '%s' does not exist", projectName));
}
project.setIndexed(true);
return ApiTaskManager.getInstance().submitApiTask(PROJECTS_PATH, new ApiTask(request.getRequestURI(), () -> {
// Refresh current version of the project's repositories.
List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project);
if (riList != null) {
for (RepositoryInfo ri : riList) {
Repository repo = getRepository(ri, CommandTimeoutType.RESTFUL);
if (repo != null && repo.getCurrentVersion() != null && repo.getCurrentVersion().length() > 0) {
// getRepository() always creates fresh instance
// of the Repository object so there is no need
// to call setCurrentVersion() on it.
ri.setCurrentVersion(repo.determineCurrentVersion());
}
}
}
CompletableFuture.runAsync(() -> suggester.rebuild(projectName));
// In case this project has just been incrementally indexed,
// its IndexSearcher needs a poke.
env.maybeRefreshIndexSearchers(Collections.singleton(projectName));
env.refreshDateForLastIndexRun();
return null;
}));
}
Aggregations