Search in sources :

Example 1 with ChangesCollection

use of com.google.gerrit.server.restapi.change.ChangesCollection in project gerrit by GerritCodeReview.

the class RestApiServlet method createRequestInfo.

private RequestInfo createRequestInfo(TraceContext traceContext, String requestUri, List<IdString> path) {
    RequestInfo.Builder requestInfo = RequestInfo.builder(RequestInfo.RequestType.REST, globals.currentUser.get(), traceContext).requestUri(requestUri);
    if (path.size() < 1) {
        return requestInfo.build();
    }
    RestCollection<?, ?> rootCollection = members.get();
    String resourceId = path.get(0).get();
    if (rootCollection instanceof ProjectsCollection) {
        requestInfo.project(Project.nameKey(resourceId));
    } else if (rootCollection instanceof ChangesCollection) {
        Optional<ChangeNotes> changeNotes = globals.changeFinder.findOne(resourceId);
        if (changeNotes.isPresent()) {
            requestInfo.project(changeNotes.get().getProjectName());
        }
    }
    return requestInfo.build();
}
Also used : Optional(java.util.Optional) ChangesCollection(com.google.gerrit.server.restapi.change.ChangesCollection) IdString(com.google.gerrit.extensions.restapi.IdString) ProjectsCollection(com.google.gerrit.server.restapi.project.ProjectsCollection) RequestInfo(com.google.gerrit.server.RequestInfo)

Aggregations

IdString (com.google.gerrit.extensions.restapi.IdString)1 RequestInfo (com.google.gerrit.server.RequestInfo)1 ChangesCollection (com.google.gerrit.server.restapi.change.ChangesCollection)1 ProjectsCollection (com.google.gerrit.server.restapi.project.ProjectsCollection)1 Optional (java.util.Optional)1