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