commit | author | age
|
f13c4c
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
5fe7df
|
16 |
package com.gitblit;
|
JM |
17 |
|
d896e6
|
18 |
|
892570
|
19 |
/**
|
JM |
20 |
* Constant values used by Gitblit.
|
|
21 |
*
|
|
22 |
* @author James Moger
|
|
23 |
*
|
|
24 |
*/
|
5fe7df
|
25 |
public class Constants {
|
JM |
26 |
|
2a7306
|
27 |
public static final String NAME = "Gitblit";
|
5fe7df
|
28 |
|
2a7306
|
29 |
public static final String FULL_NAME = "Gitblit - a pure Java Git solution";
|
155bf7
|
30 |
|
a4d249
|
31 |
// The build script extracts this exact line so be careful editing it
|
JM |
32 |
// and only use A-Z a-z 0-9 .-_ in the string.
|
a9eb6b
|
33 |
public static final String VERSION = "1.0.0-SNAPSHOT";
|
d39680
|
34 |
|
JM |
35 |
// The build script extracts this exact line so be careful editing it
|
|
36 |
// and only use A-Z a-z 0-9 .-_ in the string.
|
a9eb6b
|
37 |
public static final String VERSION_DATE = "PENDING";
|
a4d249
|
38 |
|
2a7306
|
39 |
// The build script extracts this exact line so be careful editing it
|
JM |
40 |
// and only use A-Z a-z 0-9 .-_ in the string.
|
ff3f0e
|
41 |
public static final String JGIT_VERSION = "JGit 1.3.0 (201202151440-r)";
|
155bf7
|
42 |
|
2a7306
|
43 |
public static final String ADMIN_ROLE = "#admin";
|
JM |
44 |
|
831469
|
45 |
public static final String NOT_FEDERATED_ROLE = "#notfederated";
|
JM |
46 |
|
2a7306
|
47 |
public static final String PROPERTIES_FILE = "gitblit.properties";
|
JM |
48 |
|
5450d0
|
49 |
public static final String GIT_PATH = "/git/";
|
2a7306
|
50 |
|
5450d0
|
51 |
public static final String ZIP_PATH = "/zip/";
|
85c2e6
|
52 |
|
5450d0
|
53 |
public static final String SYNDICATION_PATH = "/feed/";
|
85c2e6
|
54 |
|
831469
|
55 |
public static final String FEDERATION_PATH = "/federation/";
|
31abc2
|
56 |
|
93f0b1
|
57 |
public static final String RPC_PATH = "/rpc/";
|
6d874a
|
58 |
|
JM |
59 |
public static final String PAGES= "/pages/";
|
831469
|
60 |
|
1f9dae
|
61 |
public static final String BORDER = "***********************************************************";
|
db653a
|
62 |
|
831469
|
63 |
public static final String FEDERATION_USER = "$gitblit";
|
JM |
64 |
|
|
65 |
public static final String PROPOSAL_EXT = ".json";
|
6d874a
|
66 |
|
JM |
67 |
public static final String ENCODING = "UTF-8";
|
|
68 |
|
a45caa
|
69 |
public static final int LEN_SHORTLOG = 80;
|
JM |
70 |
|
|
71 |
public static final int LEN_SHORTLOG_REFS = 60;
|
|
72 |
|
1aabf0
|
73 |
public static final String DEFAULT_BRANCH = "default";
|
JM |
74 |
|
380afa
|
75 |
public static final String CONFIG_GITBLIT = "gitblit";
|
4a5a55
|
76 |
|
380afa
|
77 |
public static final String CONFIG_CUSTOM_FIELDS = "customFields";
|
4a5a55
|
78 |
|
831469
|
79 |
public static String getGitBlitVersion() {
|
JM |
80 |
return NAME + " v" + VERSION;
|
|
81 |
}
|
|
82 |
|
88598b
|
83 |
/**
|
831469
|
84 |
* Enumeration representing the four access restriction levels.
|
88598b
|
85 |
*/
|
dfb889
|
86 |
public static enum AccessRestrictionType {
|
JM |
87 |
NONE, PUSH, CLONE, VIEW;
|
|
88 |
|
d0d438
|
89 |
public static AccessRestrictionType fromName(String name) {
|
dfb889
|
90 |
for (AccessRestrictionType type : values()) {
|
d0d438
|
91 |
if (type.name().equalsIgnoreCase(name)) {
|
dfb889
|
92 |
return type;
|
JM |
93 |
}
|
|
94 |
}
|
|
95 |
return NONE;
|
|
96 |
}
|
f98825
|
97 |
|
JM |
98 |
public boolean exceeds(AccessRestrictionType type) {
|
|
99 |
return this.ordinal() > type.ordinal();
|
|
100 |
}
|
|
101 |
|
dfb889
|
102 |
public boolean atLeast(AccessRestrictionType type) {
|
JM |
103 |
return this.ordinal() >= type.ordinal();
|
|
104 |
}
|
|
105 |
|
|
106 |
public String toString() {
|
f98825
|
107 |
return name();
|
dfb889
|
108 |
}
|
JM |
109 |
}
|
|
110 |
|
831469
|
111 |
/**
|
JM |
112 |
* Enumeration representing the types of federation tokens.
|
|
113 |
*/
|
|
114 |
public static enum FederationToken {
|
|
115 |
ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
|
|
116 |
|
|
117 |
public static FederationToken fromName(String name) {
|
|
118 |
for (FederationToken type : values()) {
|
|
119 |
if (type.name().equalsIgnoreCase(name)) {
|
|
120 |
return type;
|
|
121 |
}
|
|
122 |
}
|
|
123 |
return REPOSITORIES;
|
|
124 |
}
|
|
125 |
|
|
126 |
public String toString() {
|
|
127 |
return name();
|
|
128 |
}
|
5fe7df
|
129 |
}
|
831469
|
130 |
|
JM |
131 |
/**
|
|
132 |
* Enumeration representing the types of federation requests.
|
|
133 |
*/
|
|
134 |
public static enum FederationRequest {
|
df162c
|
135 |
POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_TEAMS, PULL_SETTINGS, PULL_SCRIPTS, STATUS;
|
831469
|
136 |
|
JM |
137 |
public static FederationRequest fromName(String name) {
|
|
138 |
for (FederationRequest type : values()) {
|
|
139 |
if (type.name().equalsIgnoreCase(name)) {
|
|
140 |
return type;
|
|
141 |
}
|
|
142 |
}
|
|
143 |
return PULL_REPOSITORIES;
|
|
144 |
}
|
|
145 |
|
|
146 |
public String toString() {
|
|
147 |
return name();
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Enumeration representing the statii of federation requests.
|
|
153 |
*/
|
|
154 |
public static enum FederationPullStatus {
|
c729c5
|
155 |
PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
|
831469
|
156 |
|
JM |
157 |
public static FederationPullStatus fromName(String name) {
|
|
158 |
for (FederationPullStatus type : values()) {
|
|
159 |
if (type.name().equalsIgnoreCase(name)) {
|
|
160 |
return type;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
return PENDING;
|
|
164 |
}
|
|
165 |
|
|
166 |
@Override
|
|
167 |
public String toString() {
|
|
168 |
return name();
|
|
169 |
}
|
|
170 |
}
|
8f73a7
|
171 |
|
831469
|
172 |
/**
|
JM |
173 |
* Enumeration representing the federation types.
|
|
174 |
*/
|
|
175 |
public static enum FederationStrategy {
|
|
176 |
EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
|
|
177 |
|
|
178 |
public static FederationStrategy fromName(String name) {
|
|
179 |
for (FederationStrategy type : values()) {
|
|
180 |
if (type.name().equalsIgnoreCase(name)) {
|
|
181 |
return type;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
return FEDERATE_THIS;
|
|
185 |
}
|
|
186 |
|
8f73a7
|
187 |
public boolean exceeds(FederationStrategy type) {
|
JM |
188 |
return this.ordinal() > type.ordinal();
|
|
189 |
}
|
|
190 |
|
|
191 |
public boolean atLeast(FederationStrategy type) {
|
|
192 |
return this.ordinal() >= type.ordinal();
|
|
193 |
}
|
|
194 |
|
831469
|
195 |
@Override
|
JM |
196 |
public String toString() {
|
|
197 |
return name();
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
4aafd4
|
201 |
/**
|
JM |
202 |
* Enumeration representing the possible results of federation proposal
|
|
203 |
* requests.
|
|
204 |
*/
|
|
205 |
public static enum FederationProposalResult {
|
|
206 |
ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
|
|
207 |
|
|
208 |
@Override
|
|
209 |
public String toString() {
|
|
210 |
return name();
|
|
211 |
}
|
|
212 |
}
|
93f0b1
|
213 |
|
JM |
214 |
/**
|
|
215 |
* Enumeration representing the possible remote procedure call requests from
|
|
216 |
* a client.
|
|
217 |
*/
|
|
218 |
public static enum RpcRequest {
|
ec5a88
|
219 |
// Order is important here. anything above LIST_SETTINGS requires
|
JM |
220 |
// administrator privileges and web.allowRpcManagement.
|
f08aab
|
221 |
GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS,
|
JM |
222 |
CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,
|
|
223 |
LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,
|
|
224 |
LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
|
|
225 |
LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS,
|
|
226 |
LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
|
ec5a88
|
227 |
EDIT_SETTINGS, LIST_STATUS;
|
31abc2
|
228 |
|
93f0b1
|
229 |
public static RpcRequest fromName(String name) {
|
JM |
230 |
for (RpcRequest type : values()) {
|
|
231 |
if (type.name().equalsIgnoreCase(name)) {
|
|
232 |
return type;
|
|
233 |
}
|
|
234 |
}
|
b2fde8
|
235 |
return null;
|
ec5a88
|
236 |
}
|
31abc2
|
237 |
|
ca9d0f
|
238 |
public boolean exceeds(RpcRequest type) {
|
JM |
239 |
return this.ordinal() > type.ordinal();
|
|
240 |
}
|
31abc2
|
241 |
|
93f0b1
|
242 |
@Override
|
JM |
243 |
public String toString() {
|
|
244 |
return name();
|
|
245 |
}
|
|
246 |
}
|
33d8d8
|
247 |
|
JM |
248 |
/**
|
|
249 |
* Enumeration of the search types.
|
|
250 |
*/
|
|
251 |
public static enum SearchType {
|
|
252 |
AUTHOR, COMMITTER, COMMIT;
|
|
253 |
|
|
254 |
public static SearchType forName(String name) {
|
|
255 |
for (SearchType type : values()) {
|
|
256 |
if (type.name().equalsIgnoreCase(name)) {
|
|
257 |
return type;
|
|
258 |
}
|
|
259 |
}
|
|
260 |
return COMMIT;
|
|
261 |
}
|
|
262 |
|
|
263 |
@Override
|
|
264 |
public String toString() {
|
|
265 |
return name().toLowerCase();
|
|
266 |
}
|
|
267 |
}
|
d896e6
|
268 |
|
JM |
269 |
/**
|
|
270 |
* The types of objects that can be indexed and queried.
|
|
271 |
*/
|
|
272 |
public static enum SearchObjectType {
|
|
273 |
commit, blob, issue;
|
|
274 |
|
|
275 |
static SearchObjectType fromName(String name) {
|
|
276 |
for (SearchObjectType value : values()) {
|
|
277 |
if (value.name().equals(name)) {
|
|
278 |
return value;
|
|
279 |
}
|
|
280 |
}
|
|
281 |
return null;
|
|
282 |
}
|
|
283 |
}
|
5fe7df
|
284 |
}
|