| 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 | |
| Dave Borowitz | ded109a | 2014-03-03 15:25:39 -0500 | [diff] [blame] | 17 | import org.eclipse.jgit.lib.Config; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 18 | import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; |
| 19 | import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
| 20 | |
| 21 | import java.io.IOException; |
| 22 | import java.util.Map; |
| 23 | import java.util.Set; |
| 24 | |
| Shawn Pearce | c709c4c | 2015-08-28 15:30:42 -0700 | [diff] [blame] | 25 | import javax.annotation.Nullable; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 26 | import 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 | */ |
| 34 | public 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 Pearce | c709c4c | 2015-08-28 15:30:42 -0700 | [diff] [blame] | 43 | * @param prefix repository base path to list. Trailing "/" is implicitly |
| 44 | * added if missing. Null or empty string will match all repositories. |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 45 | * @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 Pearce | c709c4c | 2015-08-28 15:30:42 -0700 | [diff] [blame] | 48 | * (matching behavior in |
| 49 | * {@link org.eclipse.jgit.http.server.RepositoryFilter}). |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 50 | * @throws ServiceNotAuthorizedException to trigger an HTTP 401 Unauthorized |
| Shawn Pearce | c709c4c | 2015-08-28 15:30:42 -0700 | [diff] [blame] | 51 | * (matching behavior in |
| 52 | * {@link org.eclipse.jgit.http.server.RepositoryFilter}). |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 53 | * @throws IOException if an error occurred. |
| 54 | */ |
| Shawn Pearce | c709c4c | 2015-08-28 15:30:42 -0700 | [diff] [blame] | 55 | public Map<String, RepositoryDescription> listRepositories( |
| 56 | @Nullable String prefix, Set<String> branches) |
| 57 | throws ServiceNotEnabledException, ServiceNotAuthorizedException, |
| 58 | IOException; |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * @return an opaque object that uniquely identifies the end-user making the |
| Dave Borowitz | 01790a2 | 2014-03-21 10:03:18 -0700 | [diff] [blame] | 62 | * request, and supports {@link Object#equals(Object)} and |
| 63 | * {@link Object#hashCode()}. Never null. |
| Dave Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 64 | */ |
| 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 Borowitz | ded109a | 2014-03-03 15:25:39 -0500 | [diff] [blame] | 76 | |
| 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 Borowitz | 9de6595 | 2012-08-13 16:09:45 -0700 | [diff] [blame] | 82 | } |