James Moger
2012-07-14 8b7d3017cb094d3181235df2802f614ec339ef8d
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.
8b7d30 33     public static final String VERSION = "1.0.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.
8b7d30 37     public static final String VERSION_DATE = "2012-07-14";
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     }
112
831469 113     /**
JM 114      * Enumeration representing the types of federation tokens.
115      */
116     public static enum FederationToken {
117         ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
118
119         public static FederationToken fromName(String name) {
120             for (FederationToken type : values()) {
121                 if (type.name().equalsIgnoreCase(name)) {
122                     return type;
123                 }
124             }
125             return REPOSITORIES;
126         }
127
128         public String toString() {
129             return name();
130         }
5fe7df 131     }
831469 132
JM 133     /**
134      * Enumeration representing the types of federation requests.
135      */
136     public static enum FederationRequest {
df162c 137         POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_TEAMS, PULL_SETTINGS, PULL_SCRIPTS, STATUS;
831469 138
JM 139         public static FederationRequest fromName(String name) {
140             for (FederationRequest type : values()) {
141                 if (type.name().equalsIgnoreCase(name)) {
142                     return type;
143                 }
144             }
145             return PULL_REPOSITORIES;
146         }
147
148         public String toString() {
149             return name();
150         }
151     }
152
153     /**
154      * Enumeration representing the statii of federation requests.
155      */
156     public static enum FederationPullStatus {
c729c5 157         PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
831469 158
JM 159         public static FederationPullStatus fromName(String name) {
160             for (FederationPullStatus type : values()) {
161                 if (type.name().equalsIgnoreCase(name)) {
162                     return type;
163                 }
164             }
165             return PENDING;
166         }
167
168         @Override
169         public String toString() {
170             return name();
171         }
172     }
8f73a7 173
831469 174     /**
JM 175      * Enumeration representing the federation types.
176      */
177     public static enum FederationStrategy {
178         EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
179
180         public static FederationStrategy fromName(String name) {
181             for (FederationStrategy type : values()) {
182                 if (type.name().equalsIgnoreCase(name)) {
183                     return type;
184                 }
185             }
186             return FEDERATE_THIS;
187         }
188
8f73a7 189         public boolean exceeds(FederationStrategy type) {
JM 190             return this.ordinal() > type.ordinal();
191         }
192
193         public boolean atLeast(FederationStrategy type) {
194             return this.ordinal() >= type.ordinal();
195         }
196
831469 197         @Override
JM 198         public String toString() {
199             return name();
200         }
201     }
202
4aafd4 203     /**
JM 204      * Enumeration representing the possible results of federation proposal
205      * requests.
206      */
207     public static enum FederationProposalResult {
208         ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
209
210         @Override
211         public String toString() {
212             return name();
213         }
214     }
93f0b1 215
JM 216     /**
217      * Enumeration representing the possible remote procedure call requests from
218      * a client.
219      */
220     public static enum RpcRequest {
ec5a88 221         // Order is important here.  anything above LIST_SETTINGS requires
JM 222         // administrator privileges and web.allowRpcManagement.
f08aab 223         GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS,
JM 224         CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY, 
225         LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, 
226         LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
227         LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS, 
228         LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
ec5a88 229         EDIT_SETTINGS, LIST_STATUS;
31abc2 230
93f0b1 231         public static RpcRequest fromName(String name) {
JM 232             for (RpcRequest type : values()) {
233                 if (type.name().equalsIgnoreCase(name)) {
234                     return type;
235                 }
236             }
b2fde8 237             return null;
ec5a88 238         }        
31abc2 239
ca9d0f 240         public boolean exceeds(RpcRequest type) {
JM 241             return this.ordinal() > type.ordinal();
242         }
31abc2 243
93f0b1 244         @Override
JM 245         public String toString() {
246             return name();
247         }
248     }
33d8d8 249
JM 250     /**
251      * Enumeration of the search types.
252      */
253     public static enum SearchType {
254         AUTHOR, COMMITTER, COMMIT;
255     
256         public static SearchType forName(String name) {
257             for (SearchType type : values()) {
258                 if (type.name().equalsIgnoreCase(name)) {
259                     return type;
260                 }
261             }
262             return COMMIT;
263         }
264     
265         @Override
266         public String toString() {
267             return name().toLowerCase();
268         }
269     }
d896e6 270     
JM 271     /**
272      * The types of objects that can be indexed and queried.
273      */
274     public static enum SearchObjectType {
275         commit, blob, issue;
276
277         static SearchObjectType fromName(String name) {
278             for (SearchObjectType value : values()) {
279                 if (value.name().equals(name)) {
280                     return value;
281                 }
282             }
283             return null;
284         }
285     }
5fe7df 286 }