James Moger
2012-08-25 1ab5b3081374c79867ceff2917bccae6dd1a2878
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.
1ab5b3 33     public static final String VERSION = "1.1.0";
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.
1ab5b3 37     public static final String VERSION_DATE = "2012-08-25";
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.
5d9bd7 41     public static final String JGIT_VERSION = "JGit 2.0.0 (201206130900-r)";
155bf7 42
2a7306 43     public static final String ADMIN_ROLE = "#admin";
JM 44
831469 45     public static final String NOT_FEDERATED_ROLE = "#notfederated";
ce2a40 46     
JM 47     public static final String NO_ROLE = "#none";
831469 48
2a7306 49     public static final String PROPERTIES_FILE = "gitblit.properties";
JM 50
5450d0 51     public static final String GIT_PATH = "/git/";
2a7306 52
5450d0 53     public static final String ZIP_PATH = "/zip/";
85c2e6 54
5450d0 55     public static final String SYNDICATION_PATH = "/feed/";
85c2e6 56
831469 57     public static final String FEDERATION_PATH = "/federation/";
31abc2 58
93f0b1 59     public static final String RPC_PATH = "/rpc/";
6d874a 60     
JM 61     public static final String PAGES= "/pages/";
831469 62
1f9dae 63     public static final String BORDER = "***********************************************************";
db653a 64
831469 65     public static final String FEDERATION_USER = "$gitblit";
JM 66
67     public static final String PROPOSAL_EXT = ".json";
6d874a 68     
JM 69     public static final String ENCODING = "UTF-8";
70     
a45caa 71     public static final int LEN_SHORTLOG = 80;
JM 72     
73     public static final int LEN_SHORTLOG_REFS = 60;
74     
1aabf0 75     public static final String DEFAULT_BRANCH = "default";
JM 76     
380afa 77     public static final String CONFIG_GITBLIT = "gitblit";
4a5a55 78     
380afa 79     public static final String CONFIG_CUSTOM_FIELDS = "customFields";
4a5a55 80     
831469 81     public static String getGitBlitVersion() {
JM 82         return NAME + " v" + VERSION;
83     }
84
88598b 85     /**
831469 86      * Enumeration representing the four access restriction levels.
88598b 87      */
dfb889 88     public static enum AccessRestrictionType {
JM 89         NONE, PUSH, CLONE, VIEW;
90
d0d438 91         public static AccessRestrictionType fromName(String name) {
dfb889 92             for (AccessRestrictionType type : values()) {
d0d438 93                 if (type.name().equalsIgnoreCase(name)) {
dfb889 94                     return type;
JM 95                 }
96             }
97             return NONE;
98         }
f98825 99
JM 100         public boolean exceeds(AccessRestrictionType type) {
101             return this.ordinal() > type.ordinal();
102         }
103
dfb889 104         public boolean atLeast(AccessRestrictionType type) {
JM 105             return this.ordinal() >= type.ordinal();
106         }
107
108         public String toString() {
f98825 109             return name();
dfb889 110         }
JM 111     }
6adf56 112     
JM 113     /**
114      * Enumeration representing the types of authorization control for an
115      * access restricted resource.
116      */
117     public static enum AuthorizationControl {
118         AUTHENTICATED, NAMED;
119         
120         public static AuthorizationControl fromName(String name) {
121             for (AuthorizationControl type : values()) {
122                 if (type.name().equalsIgnoreCase(name)) {
123                     return type;
124                 }
125             }
126             return NAMED;
127         }
128         
129         public String toString() {
130             return name();
131         }
132     }
133
dfb889 134
831469 135     /**
JM 136      * Enumeration representing the types of federation tokens.
137      */
138     public static enum FederationToken {
139         ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
140
141         public static FederationToken fromName(String name) {
142             for (FederationToken type : values()) {
143                 if (type.name().equalsIgnoreCase(name)) {
144                     return type;
145                 }
146             }
147             return REPOSITORIES;
148         }
149
150         public String toString() {
151             return name();
152         }
5fe7df 153     }
831469 154
JM 155     /**
156      * Enumeration representing the types of federation requests.
157      */
158     public static enum FederationRequest {
df162c 159         POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_TEAMS, PULL_SETTINGS, PULL_SCRIPTS, STATUS;
831469 160
JM 161         public static FederationRequest fromName(String name) {
162             for (FederationRequest type : values()) {
163                 if (type.name().equalsIgnoreCase(name)) {
164                     return type;
165                 }
166             }
167             return PULL_REPOSITORIES;
168         }
169
170         public String toString() {
171             return name();
172         }
173     }
174
175     /**
176      * Enumeration representing the statii of federation requests.
177      */
178     public static enum FederationPullStatus {
c729c5 179         PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
831469 180
JM 181         public static FederationPullStatus fromName(String name) {
182             for (FederationPullStatus type : values()) {
183                 if (type.name().equalsIgnoreCase(name)) {
184                     return type;
185                 }
186             }
187             return PENDING;
188         }
189
190         @Override
191         public String toString() {
192             return name();
193         }
194     }
8f73a7 195
831469 196     /**
JM 197      * Enumeration representing the federation types.
198      */
199     public static enum FederationStrategy {
200         EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
201
202         public static FederationStrategy fromName(String name) {
203             for (FederationStrategy type : values()) {
204                 if (type.name().equalsIgnoreCase(name)) {
205                     return type;
206                 }
207             }
208             return FEDERATE_THIS;
209         }
210
8f73a7 211         public boolean exceeds(FederationStrategy type) {
JM 212             return this.ordinal() > type.ordinal();
213         }
214
215         public boolean atLeast(FederationStrategy type) {
216             return this.ordinal() >= type.ordinal();
217         }
218
831469 219         @Override
JM 220         public String toString() {
221             return name();
222         }
223     }
224
4aafd4 225     /**
JM 226      * Enumeration representing the possible results of federation proposal
227      * requests.
228      */
229     public static enum FederationProposalResult {
230         ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
231
232         @Override
233         public String toString() {
234             return name();
235         }
236     }
93f0b1 237
JM 238     /**
239      * Enumeration representing the possible remote procedure call requests from
240      * a client.
241      */
242     public static enum RpcRequest {
ec5a88 243         // Order is important here.  anything above LIST_SETTINGS requires
JM 244         // administrator privileges and web.allowRpcManagement.
4ebaf6 245         CLEAR_REPOSITORY_CACHE, GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS,
f08aab 246         CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY, 
JM 247         LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, 
248         LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
249         LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS, 
250         LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
4ebaf6 251         EDIT_SETTINGS, LIST_STATUS;
31abc2 252
93f0b1 253         public static RpcRequest fromName(String name) {
JM 254             for (RpcRequest type : values()) {
255                 if (type.name().equalsIgnoreCase(name)) {
256                     return type;
257                 }
258             }
b2fde8 259             return null;
ec5a88 260         }        
31abc2 261
ca9d0f 262         public boolean exceeds(RpcRequest type) {
JM 263             return this.ordinal() > type.ordinal();
264         }
31abc2 265
93f0b1 266         @Override
JM 267         public String toString() {
268             return name();
269         }
270     }
33d8d8 271
JM 272     /**
273      * Enumeration of the search types.
274      */
275     public static enum SearchType {
276         AUTHOR, COMMITTER, COMMIT;
277     
278         public static SearchType forName(String name) {
279             for (SearchType type : values()) {
280                 if (type.name().equalsIgnoreCase(name)) {
281                     return type;
282                 }
283             }
284             return COMMIT;
285         }
286     
287         @Override
288         public String toString() {
289             return name().toLowerCase();
290         }
291     }
d896e6 292     
JM 293     /**
294      * The types of objects that can be indexed and queried.
295      */
296     public static enum SearchObjectType {
297         commit, blob, issue;
298
299         static SearchObjectType fromName(String name) {
300             for (SearchObjectType value : values()) {
301                 if (value.name().equals(name)) {
302                     return value;
303                 }
304             }
305             return null;
306         }
307     }
5fe7df 308 }