Search in sources :

Example 1 with GET

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

the class ClientJsonEndpoint method cookie.

@GET
@Path("cookie")
@Produces(MediaType.APPLICATION_JSON)
public Response cookie(@CookieParam(Default.COOKIE_NAME) String cookie) {
    SimpleResult result = new SimpleResult();
    result.setResult(cookie);
    return Response.ok(result).build();
}
Also used : SimpleResult(ru.sbtqa.tag.api.dto.SimpleResult) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Example 2 with GET

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

the class ProjectsController method getRepositories.

@GET
@Path("/{project}/repositories")
@Produces(MediaType.APPLICATION_JSON)
public List<String> getRepositories(@PathParam("project") String projectName) {
    // Avoid classification as a taint bug.
    projectName = Laundromat.launderInput(projectName);
    Project project = env.getProjects().get(projectName);
    if (project != null) {
        List<RepositoryInfo> infos = env.getProjectRepositoriesMap().get(project);
        if (infos != null) {
            return infos.stream().map(RepositoryInfo::getDirectoryNameRelative).collect(Collectors.toList());
        }
    }
    return Collections.emptyList();
}
Also used : Project(org.opengrok.indexer.configuration.Project) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Example 3 with GET

use of jakarta.ws.rs.GET 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 GET

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

the class ClientJsonEndpoint method getWithParams.

@GET
@Path("get-with-params-placeholder")
@Produces(MediaType.APPLICATION_JSON)
public Response getWithParams(@HeaderParam(Default.HEADER_PARAMETER_NAME_1) String header1, @HeaderParam("header2") String header2, @QueryParam(Default.QUERY_PARAMETER_NAME_1) String query) {
    SimpleResult result = new SimpleResult();
    result.setResult(query + header1 + header2);
    return Response.ok(result).build();
}
Also used : SimpleResult(ru.sbtqa.tag.api.dto.SimpleResult) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Example 5 with GET

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

the class ProjectsController method getRepositoriesType.

@GET
@Path("/{project}/repositories/type")
@Produces(MediaType.APPLICATION_JSON)
public Set<String> getRepositoriesType(@PathParam("project") String projectName) {
    // Avoid classification as a taint bug.
    projectName = Laundromat.launderInput(projectName);
    Project project = env.getProjects().get(projectName);
    if (project != null) {
        List<RepositoryInfo> infos = env.getProjectRepositoriesMap().get(project);
        if (infos != null) {
            return infos.stream().map(RepositoryInfo::getType).collect(Collectors.toSet());
        }
    }
    return Collections.emptySet();
}
Also used : Project(org.opengrok.indexer.configuration.Project) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Aggregations

GET (jakarta.ws.rs.GET)13 Produces (jakarta.ws.rs.Produces)13 Path (jakarta.ws.rs.Path)9 CorsEnable (org.opengrok.web.api.v1.filter.CorsEnable)6 File (java.io.File)5 WebApplicationException (jakarta.ws.rs.WebApplicationException)4 Project (org.opengrok.indexer.configuration.Project)4 PathAuthorized (org.opengrok.web.api.v1.filter.PathAuthorized)4 FileUtil.toFile (org.opengrok.web.util.FileUtil.toFile)4 ArrayList (java.util.ArrayList)3 RepositoryInfo (org.opengrok.indexer.history.RepositoryInfo)3 Instant (java.time.Instant)2 List (java.util.List)2 Document (org.apache.lucene.document.Document)2 IndexDatabase.getDocument (org.opengrok.indexer.index.IndexDatabase.getDocument)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StdDateFormat (com.fasterxml.jackson.databind.util.StdDateFormat)1 Inject (jakarta.inject.Inject)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 Consumes (jakarta.ws.rs.Consumes)1