blob: 4572033c7cc1d9bb1eeaaecd152117bed66c9fdc [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
25import javax.servlet.http.HttpServletRequest;
26
27/**
28 * Git storage interface for Gitiles.
29 * <p>
30 * Each instance is associated with a single end-user request, which implicitly
31 * includes information about the host and repository.
32 */
33public interface GitilesAccess {
34 /** Factory for per-request access. */
35 public interface Factory {
36 public GitilesAccess forRequest(HttpServletRequest req);
37 }
38
39 /**
40 * List repositories on the host.
41 *
42 * @param branches branches to list along with each repository.
43 * @return map of repository names to descriptions.
44 * @throws ServiceNotEnabledException to trigger an HTTP 403 Forbidden
45 * (matching behavior in {@link org.eclipse.jgit.http.server.RepositoryFilter}).
46 * @throws ServiceNotAuthorizedException to trigger an HTTP 401 Unauthorized
47 * (matching behavior in {@link org.eclipse.jgit.http.server.RepositoryFilter}).
48 * @throws IOException if an error occurred.
49 */
50 public Map<String, RepositoryDescription> listRepositories(Set<String> branches)
51 throws ServiceNotEnabledException, ServiceNotAuthorizedException, IOException;
52
53 /**
54 * @return an opaque object that uniquely identifies the end-user making the
Dave Borowitz01790a22014-03-21 10:03:18 -070055 * request, and supports {@link Object#equals(Object)} and
56 * {@link Object#hashCode()}. Never null.
Dave Borowitz9de65952012-08-13 16:09:45 -070057 */
58 public Object getUserKey();
59
60 /** @return the repository name associated with the request. */
61 public String getRepositoryName();
62
63 /**
64 * @return the description attached to the repository of this request.
65 * @throws IOException an error occurred reading the description string from
66 * the repository.
67 */
68 public RepositoryDescription getRepositoryDescription() throws IOException;
Dave Borowitzded109a2014-03-03 15:25:39 -050069
70 /**
71 * @return configuration to apply to the host/repository for this request.
72 * @throws IOException an error occurred reading the configuration.
73 */
74 public Config getConfig() throws IOException;
Dave Borowitz9de65952012-08-13 16:09:45 -070075}