blob: ec3b5ffc606a089b658ed0edd6832f4d00c195b3 [file] [log] [blame]
Dave Borowitz9de65952012-08-13 16:09:45 -07001// Copyright 2012 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.gitiles;
16
Dave Borowitz9de65952012-08-13 16:09:45 -070017import java.io.IOException;
18import java.util.Map;
19import java.util.Set;
Shawn Pearcec709c4c2015-08-28 15:30:42 -070020import javax.annotation.Nullable;
Dave Borowitz9de65952012-08-13 16:09:45 -070021import javax.servlet.http.HttpServletRequest;
Dave Borowitz3b744b12016-08-19 16:11:10 -040022import org.eclipse.jgit.lib.Config;
23import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
24import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
Dave Borowitz9de65952012-08-13 16:09:45 -070025
26/**
27 * Git storage interface for Gitiles.
Dave Borowitz40255d52016-08-19 16:16:22 -040028 *
29 * <p>Each instance is associated with a single end-user request, which implicitly includes
30 * information about the host and repository.
Dave Borowitz9de65952012-08-13 16:09:45 -070031 */
32public interface GitilesAccess {
33 /** Factory for per-request access. */
34 public interface Factory {
David Pursehousee3d3ec82016-06-15 22:10:48 +090035 GitilesAccess forRequest(HttpServletRequest req);
Dave Borowitz9de65952012-08-13 16:09:45 -070036 }
37
38 /**
39 * List repositories on the host.
40 *
Dave Borowitz40255d52016-08-19 16:16:22 -040041 * @param prefix repository base path to list. Trailing "/" is implicitly added if missing. Null
42 * or empty string will match all repositories.
Dave Borowitz9de65952012-08-13 16:09:45 -070043 * @param branches branches to list along with each repository.
44 * @return map of repository names to descriptions.
Dave Borowitz40255d52016-08-19 16:16:22 -040045 * @throws ServiceNotEnabledException to trigger an HTTP 403 Forbidden (matching behavior in
46 * {@link org.eclipse.jgit.http.server.RepositoryFilter}).
47 * @throws ServiceNotAuthorizedException to trigger an HTTP 401 Unauthorized (matching behavior in
48 * {@link org.eclipse.jgit.http.server.RepositoryFilter}).
Dave Borowitz9de65952012-08-13 16:09:45 -070049 * @throws IOException if an error occurred.
50 */
Dave Borowitz40255d52016-08-19 16:16:22 -040051 Map<String, RepositoryDescription> listRepositories(@Nullable String prefix, Set<String> branches)
Han-Wen Nienhuysc0200f62016-05-02 17:34:51 +020052 throws ServiceNotEnabledException, ServiceNotAuthorizedException, IOException;
Dave Borowitz9de65952012-08-13 16:09:45 -070053
54 /**
Dave Borowitz40255d52016-08-19 16:16:22 -040055 * @return an opaque object that uniquely identifies the end-user making the request, and supports
56 * {@link Object#equals(Object)} and {@link Object#hashCode()}. Never null.
Dave Borowitz9de65952012-08-13 16:09:45 -070057 */
David Pursehousee3d3ec82016-06-15 22:10:48 +090058 Object getUserKey();
Dave Borowitz9de65952012-08-13 16:09:45 -070059
60 /** @return the repository name associated with the request. */
David Pursehousee3d3ec82016-06-15 22:10:48 +090061 String getRepositoryName();
Dave Borowitz9de65952012-08-13 16:09:45 -070062
63 /**
64 * @return the description attached to the repository of this request.
Dave Borowitz40255d52016-08-19 16:16:22 -040065 * @throws IOException an error occurred reading the description string from the repository.
Dave Borowitz9de65952012-08-13 16:09:45 -070066 */
David Pursehousee3d3ec82016-06-15 22:10:48 +090067 RepositoryDescription getRepositoryDescription() throws IOException;
Dave Borowitzded109a2014-03-03 15:25:39 -050068
69 /**
70 * @return configuration to apply to the host/repository for this request.
71 * @throws IOException an error occurred reading the configuration.
72 */
David Pursehousee3d3ec82016-06-15 22:10:48 +090073 Config getConfig() throws IOException;
Dave Borowitz9de65952012-08-13 16:09:45 -070074}