Search in sources :

Example 1 with DELETE

use of jakarta.ws.rs.DELETE in project OpenGrok by OpenGrok.

the class ProjectsController method deleteProject.

@DELETE
@Path("/{project}")
public Response deleteProject(@Context HttpServletRequest request, @PathParam("project") String projectNameParam) {
    // Avoid classification as a taint bug.
    final String projectName = Laundromat.launderInput(projectNameParam);
    Project project = disableProject(projectName);
    LOGGER.log(Level.INFO, "deleting configuration for project {0}", projectName);
    return ApiTaskManager.getInstance().submitApiTask(PROJECTS_PATH, new ApiTask(request.getRequestURI(), () -> {
        deleteProjectWorkHorse(projectName, project);
        return null;
    }, Response.Status.NO_CONTENT));
}
Also used : Project(org.opengrok.indexer.configuration.Project) ApiTask(org.opengrok.web.api.ApiTask) Path(jakarta.ws.rs.Path) DELETE(jakarta.ws.rs.DELETE)

Example 2 with DELETE

use of jakarta.ws.rs.DELETE in project OpenGrok by OpenGrok.

the class ProjectsController method deleteProjectData.

@DELETE
@Path("/{project}/data")
public Response deleteProjectData(@Context HttpServletRequest request, @PathParam("project") String projectNameParam) {
    // Avoid classification as a taint bug.
    final String projectName = Laundromat.launderInput(projectNameParam);
    disableProject(projectName);
    return ApiTaskManager.getInstance().submitApiTask(PROJECTS_PATH, new ApiTask(request.getRequestURI(), () -> {
        deleteProjectDataWorkHorse(projectName, false);
        return null;
    }, Response.Status.NO_CONTENT));
}
Also used : ApiTask(org.opengrok.web.api.ApiTask) Path(jakarta.ws.rs.Path) DELETE(jakarta.ws.rs.DELETE)

Example 3 with DELETE

use of jakarta.ws.rs.DELETE in project OpenGrok by OpenGrok.

the class ProjectsController method deleteHistoryCacheWorkHorse.

private void deleteHistoryCacheWorkHorse(String projectName, boolean clearHistoryGuru) {
    Project project = disableProject(projectName);
    LOGGER.log(Level.INFO, "deleting history cache for project {0}", projectName);
    List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(project);
    if (repos == null || repos.isEmpty()) {
        LOGGER.log(Level.INFO, "history cache for project {0} is not present", projectName);
        return;
    }
    // Delete history cache data.
    HistoryGuru guru = HistoryGuru.getInstance();
    guru.removeCache(repos.stream().map(x -> {
        try {
            return env.getPathRelativeToSourceRoot(new File((x).getDirectoryName()));
        } catch (ForbiddenSymlinkException e) {
            LOGGER.log(Level.FINER, e.getMessage());
            return "";
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "cannot remove files for repository {0}", x.getDirectoryName());
            // {@code removeCache()} will return nothing.
            return "";
        }
    }).filter(x -> !x.isEmpty()).collect(Collectors.toSet()), clearHistoryGuru);
}
Also used : Repository(org.opengrok.indexer.history.Repository) SuggesterService(org.opengrok.web.api.v1.suggester.provider.service.SuggesterService) Context(jakarta.ws.rs.core.Context) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) Group(org.opengrok.indexer.configuration.Group) Project(org.opengrok.indexer.configuration.Project) CompletableFuture(java.util.concurrent.CompletableFuture) GET(jakarta.ws.rs.GET) ForbiddenSymlinkException(org.opengrok.indexer.util.ForbiddenSymlinkException) PUT(jakarta.ws.rs.PUT) WebApplicationException(jakarta.ws.rs.WebApplicationException) TreeSet(java.util.TreeSet) ApiTask(org.opengrok.web.api.ApiTask) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Path(jakarta.ws.rs.Path) ClassUtil(org.opengrok.indexer.util.ClassUtil) Response(jakarta.ws.rs.core.Response) RepositoryFactory.getRepository(org.opengrok.indexer.history.RepositoryFactory.getRepository) Map(java.util.Map) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) ApiTaskManager(org.opengrok.web.api.ApiTaskManager) RuntimeEnvironment(org.opengrok.indexer.configuration.RuntimeEnvironment) Laundromat(org.opengrok.indexer.web.Laundromat) Produces(jakarta.ws.rs.Produces) CommandTimeoutType(org.opengrok.indexer.configuration.CommandTimeoutType) Consumes(jakarta.ws.rs.Consumes) NotFoundException(jakarta.ws.rs.NotFoundException) POST(jakarta.ws.rs.POST) IOUtils(org.opengrok.indexer.util.IOUtils) Set(java.util.Set) IOException(java.io.IOException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) IndexDatabase(org.opengrok.indexer.index.IndexDatabase) File(java.io.File) List(java.util.List) MediaType(jakarta.ws.rs.core.MediaType) Paths(java.nio.file.Paths) LoggerFactory(org.opengrok.indexer.logger.LoggerFactory) DELETE(jakarta.ws.rs.DELETE) HistoryGuru(org.opengrok.indexer.history.HistoryGuru) Inject(jakarta.inject.Inject) PathParam(jakarta.ws.rs.PathParam) Collections(java.util.Collections) Project(org.opengrok.indexer.configuration.Project) ForbiddenSymlinkException(org.opengrok.indexer.util.ForbiddenSymlinkException) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) HistoryGuru(org.opengrok.indexer.history.HistoryGuru) IOException(java.io.IOException) File(java.io.File)

Example 4 with DELETE

use of jakarta.ws.rs.DELETE in project OpenGrok by OpenGrok.

the class StatusController method delete.

@DELETE
@Path("/{uuid}")
public Response delete(@PathParam("uuid") String uuid) {
    ApiTask apiTask = ApiTaskManager.getInstance().getApiTask(uuid);
    if (apiTask == null) {
        return Response.status(Response.Status.NOT_FOUND).build();
    }
    if (!apiTask.isDone()) {
        LOGGER.log(Level.WARNING, "API task {0} not yet done", apiTask);
        return Response.status(Response.Status.BAD_REQUEST).build();
    }
    ApiTaskManager.getInstance().deleteApiTask(uuid);
    return Response.ok().build();
}
Also used : ApiTask(org.opengrok.web.api.ApiTask) Path(jakarta.ws.rs.Path) DELETE(jakarta.ws.rs.DELETE)

Example 5 with DELETE

use of jakarta.ws.rs.DELETE in project page-factory-2 by sbtqa.

the class ClientJsonEndpoint method delete.

@DELETE
@Path("delete-client")
@Produces(MediaType.APPLICATION_JSON)
public Response delete(@QueryParam("client") String param) {
    SimpleResult result = new SimpleResult();
    result.setResult(param);
    return Response.ok(result).build();
}
Also used : SimpleResult(ru.sbtqa.tag.api.dto.SimpleResult) Path(jakarta.ws.rs.Path) DELETE(jakarta.ws.rs.DELETE) Produces(jakarta.ws.rs.Produces)

Aggregations

DELETE (jakarta.ws.rs.DELETE)5 Path (jakarta.ws.rs.Path)5 ApiTask (org.opengrok.web.api.ApiTask)4 Produces (jakarta.ws.rs.Produces)2 Project (org.opengrok.indexer.configuration.Project)2 Inject (jakarta.inject.Inject)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 Consumes (jakarta.ws.rs.Consumes)1 GET (jakarta.ws.rs.GET)1 NotFoundException (jakarta.ws.rs.NotFoundException)1 POST (jakarta.ws.rs.POST)1 PUT (jakarta.ws.rs.PUT)1 PathParam (jakarta.ws.rs.PathParam)1 WebApplicationException (jakarta.ws.rs.WebApplicationException)1 Context (jakarta.ws.rs.core.Context)1 MediaType (jakarta.ws.rs.core.MediaType)1 Response (jakarta.ws.rs.core.Response)1 File (java.io.File)1 IOException (java.io.IOException)1 Paths (java.nio.file.Paths)1