Search in sources :

Example 1 with PUT

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

the class ClientJsonEndpoint method put.

@PUT
@Path("put")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response put(Client client) {
    SimpleResult result = new SimpleResult();
    result.setResult(client.getId() + client.getName() + client.getEmail());
    return Response.ok(result).build();
}
Also used : SimpleResult(ru.sbtqa.tag.api.dto.SimpleResult) Path(jakarta.ws.rs.Path) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) PUT(jakarta.ws.rs.PUT)

Example 2 with PUT

use of jakarta.ws.rs.PUT 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;
    }));
}
Also used : Project(org.opengrok.indexer.configuration.Project) Repository(org.opengrok.indexer.history.Repository) RepositoryFactory.getRepository(org.opengrok.indexer.history.RepositoryFactory.getRepository) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) NotFoundException(jakarta.ws.rs.NotFoundException) ArrayList(java.util.ArrayList) List(java.util.List) ApiTask(org.opengrok.web.api.ApiTask) Path(jakarta.ws.rs.Path) Consumes(jakarta.ws.rs.Consumes) PUT(jakarta.ws.rs.PUT)

Example 3 with PUT

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

the class ProjectsController method set.

@PUT
@Path("/{project}/property/{field}")
public void set(@PathParam("project") String projectName, @PathParam("field") String field, final String value) throws IOException {
    // Avoid classification as a taint bug.
    projectName = Laundromat.launderInput(projectName);
    field = Laundromat.launderInput(field);
    Project project = env.getProjects().get(projectName);
    if (project != null) {
        // Set the property.
        ClassUtil.setFieldValue(project, field, value);
        // Refresh field values for project's repositories for this project as well.
        List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project);
        if (riList != null) {
            for (RepositoryInfo ri : riList) {
                // Set the property if there is one.
                if (ClassUtil.hasField(ri, field)) {
                    ClassUtil.setFieldValue(ri, field, value);
                }
            }
        }
    } else {
        LOGGER.log(Level.WARNING, "cannot find project {0} to set a property", projectName);
    }
}
Also used : Project(org.opengrok.indexer.configuration.Project) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) Path(jakarta.ws.rs.Path) PUT(jakarta.ws.rs.PUT)

Aggregations

PUT (jakarta.ws.rs.PUT)3 Path (jakarta.ws.rs.Path)3 Consumes (jakarta.ws.rs.Consumes)2 Project (org.opengrok.indexer.configuration.Project)2 RepositoryInfo (org.opengrok.indexer.history.RepositoryInfo)2 NotFoundException (jakarta.ws.rs.NotFoundException)1 Produces (jakarta.ws.rs.Produces)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Repository (org.opengrok.indexer.history.Repository)1 RepositoryFactory.getRepository (org.opengrok.indexer.history.RepositoryFactory.getRepository)1 ApiTask (org.opengrok.web.api.ApiTask)1 SimpleResult (ru.sbtqa.tag.api.dto.SimpleResult)1