blob: 6434e551bf191a763c421e1f69e1a75ecaf60f3b [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 Borowitzded109a2014-03-03 15:25:39 -050017import org.eclipse.jgit.lib.Config;
Dave Borowitz9de65952012-08-13 16:09:45 -070018import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
19import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
20
21import java.io.IOException;
22import java.util.Map;
23import java.util.Set;
24
Shawn Pearcec709c4c2015-08-28 15:30:42 -070025import javax.annotation.Nullable;
Dave Borowitz9de65952012-08-13 16:09:45 -070026import javax.servlet.http.HttpServletRequest;
27
28/**
29 * Git storage interface for Gitiles.
30 * <p>
31 * Each instance is associated with a single end-user request, which implicitly
32 * includes information about the host and repository.
33 */
34public interface GitilesAccess {
35 /** Factory for per-request access. */
36 public interface Factory {
37 public GitilesAccess forRequest(HttpServletRequest req);
38 }
39
40 /**
41 * List repositories on the host.
42 *
Shawn Pearcec709c4c2015-08-28 15:30:42 -070043 * @param prefix repository base path to list. Trailing "/" is implicitly
44 * added if missing. Null or empty string will match all repositories.
Dave Borowitz9de65952012-08-13 16:09:45 -070045 * @param branches branches to list along with each repository.
46 * @return map of repository names to descriptions.
47 * @throws ServiceNotEnabledException to trigger an HTTP 403 Forbidden
Shawn Pearcec709c4c2015-08-28 15:30:42 -070048 * (matching behavior in
49 * {@link org.eclipse.jgit.http.server.RepositoryFilter}).
Dave Borowitz9de65952012-08-13 16:09:45 -070050 * @throws ServiceNotAuthorizedException to trigger an HTTP 401 Unauthorized
Shawn Pearcec709c4c2015-08-28 15:30:42 -070051 * (matching behavior in
52 * {@link org.eclipse.jgit.http.server.RepositoryFilter}).
Dave Borowitz9de65952012-08-13 16:09:45 -070053 * @throws IOException if an error occurred.
54 */
Shawn Pearcec709c4c2015-08-28 15:30:42 -070055 public Map<String, RepositoryDescription> listRepositories(
56 @Nullable String prefix, Set<String> branches)
57 throws ServiceNotEnabledException, ServiceNotAuthorizedException,
58 IOException;
Dave Borowitz9de65952012-08-13 16:09:45 -070059
60 /**
61 * @return an opaque object that uniquely identifies the end-user making the
Dave Borowitz01790a22014-03-21 10:03:18 -070062 * request, and supports {@link Object#equals(Object)} and
63 * {@link Object#hashCode()}. Never null.
Dave Borowitz9de65952012-08-13 16:09:45 -070064 */
65 public Object getUserKey();
66
67 /** @return the repository name associated with the request. */
68 public String getRepositoryName();
69
70 /**
71 * @return the description attached to the repository of this request.
72 * @throws IOException an error occurred reading the description string from
73 * the repository.
74 */
75 public RepositoryDescription getRepositoryDescription() throws IOException;
Dave Borowitzded109a2014-03-03 15:25:39 -050076
77 /**
78 * @return configuration to apply to the host/repository for this request.
79 * @throws IOException an error occurred reading the configuration.
80 */
81 public Config getConfig() throws IOException;
Dave Borowitz9de65952012-08-13 16:09:45 -070082}