| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package com.google.gitiles; |
| 16 | |
| 17 | import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; |
| 18 | import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
| 19 | |
| 20 | import java.io.IOException; |
| 21 | import java.util.Map; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | import javax.servlet.http.HttpServletRequest; |
| 25 | |
| 26 | /** |
| 27 | * Git storage interface for Gitiles. |
| 28 | * <p> |
| 29 | * Each instance is associated with a single end-user request, which implicitly |
| 30 | * includes information about the host and repository. |
| 31 | */ |
| 32 | public interface GitilesAccess { |
| 33 | /** Factory for per-request access. */ |
| 34 | public interface Factory { |
| 35 | public GitilesAccess forRequest(HttpServletRequest req); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * List repositories on the host. |
| 40 | * |
| 41 | * @param branches branches to list along with each repository. |
| 42 | * @return map of repository names to descriptions. |
| 43 | * @throws ServiceNotEnabledException to trigger an HTTP 403 Forbidden |
| 44 | * (matching behavior in {@link org.eclipse.jgit.http.server.RepositoryFilter}). |
| 45 | * @throws ServiceNotAuthorizedException to trigger an HTTP 401 Unauthorized |
| 46 | * (matching behavior in {@link org.eclipse.jgit.http.server.RepositoryFilter}). |
| 47 | * @throws IOException if an error occurred. |
| 48 | */ |
| 49 | public Map<String, RepositoryDescription> listRepositories(Set<String> branches) |
| 50 | throws ServiceNotEnabledException, ServiceNotAuthorizedException, IOException; |
| 51 | |
| 52 | /** |
| 53 | * @return an opaque object that uniquely identifies the end-user making the |
| 54 | * request, and supports {@link #equals(Object)} and {@link #hashCode()}. |
| 55 | * Never null. |
| 56 | */ |
| 57 | public Object getUserKey(); |
| 58 | |
| 59 | /** @return the repository name associated with the request. */ |
| 60 | public String getRepositoryName(); |
| 61 | |
| 62 | /** |
| 63 | * @return the description attached to the repository of this request. |
| 64 | * @throws IOException an error occurred reading the description string from |
| 65 | * the repository. |
| 66 | */ |
| 67 | public RepositoryDescription getRepositoryDescription() throws IOException; |
| 68 | } |