James Moger
2012-01-11 9429390b02ec184347380cb97ca32c0dddd475df
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
892570 18 /**
JM 19  * Constant values used by Gitblit.
20  * 
21  * @author James Moger
22  * 
23  */
5fe7df 24 public class Constants {
JM 25
2a7306 26     public static final String NAME = "Gitblit";
5fe7df 27
2a7306 28     public static final String FULL_NAME = "Gitblit - a pure Java Git solution";
155bf7 29
a4d249 30     // The build script extracts this exact line so be careful editing it
JM 31     // and only use A-Z a-z 0-9 .-_ in the string.
942939 32     public static final String VERSION = "0.8.1";
d39680 33
JM 34     // The build script extracts this exact line so be careful editing it
35     // and only use A-Z a-z 0-9 .-_ in the string.
942939 36     public static final String VERSION_DATE = "2012-01-11";
a4d249 37
2a7306 38     // The build script extracts this exact line so be careful editing it
JM 39     // and only use A-Z a-z 0-9 .-_ in the string.
367505 40     public static final String JGIT_VERSION = "JGit 1.2.0 (201112221803-r)";
155bf7 41
2a7306 42     public static final String ADMIN_ROLE = "#admin";
JM 43
831469 44     public static final String NOT_FEDERATED_ROLE = "#notfederated";
JM 45
2a7306 46     public static final String PROPERTIES_FILE = "gitblit.properties";
JM 47
5450d0 48     public static final String GIT_PATH = "/git/";
2a7306 49
5450d0 50     public static final String ZIP_PATH = "/zip/";
85c2e6 51
5450d0 52     public static final String SYNDICATION_PATH = "/feed/";
85c2e6 53
831469 54     public static final String FEDERATION_PATH = "/federation/";
31abc2 55
93f0b1 56     public static final String RPC_PATH = "/rpc/";
6d874a 57     
JM 58     public static final String PAGES= "/pages/";
831469 59
1f9dae 60     public static final String BORDER = "***********************************************************";
db653a 61
831469 62     public static final String FEDERATION_USER = "$gitblit";
JM 63
64     public static final String PROPOSAL_EXT = ".json";
6d874a 65     
JM 66     public static final String ENCODING = "UTF-8";
67     
831469 68     public static String getGitBlitVersion() {
JM 69         return NAME + " v" + VERSION;
70     }
71
88598b 72     /**
831469 73      * Enumeration representing the four access restriction levels.
88598b 74      */
dfb889 75     public static enum AccessRestrictionType {
JM 76         NONE, PUSH, CLONE, VIEW;
77
d0d438 78         public static AccessRestrictionType fromName(String name) {
dfb889 79             for (AccessRestrictionType type : values()) {
d0d438 80                 if (type.name().equalsIgnoreCase(name)) {
dfb889 81                     return type;
JM 82                 }
83             }
84             return NONE;
85         }
f98825 86
JM 87         public boolean exceeds(AccessRestrictionType type) {
88             return this.ordinal() > type.ordinal();
89         }
90
dfb889 91         public boolean atLeast(AccessRestrictionType type) {
JM 92             return this.ordinal() >= type.ordinal();
93         }
94
95         public String toString() {
f98825 96             return name();
dfb889 97         }
JM 98     }
99
831469 100     /**
JM 101      * Enumeration representing the types of federation tokens.
102      */
103     public static enum FederationToken {
104         ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
105
106         public static FederationToken fromName(String name) {
107             for (FederationToken type : values()) {
108                 if (type.name().equalsIgnoreCase(name)) {
109                     return type;
110                 }
111             }
112             return REPOSITORIES;
113         }
114
115         public String toString() {
116             return name();
117         }
5fe7df 118     }
831469 119
JM 120     /**
121      * Enumeration representing the types of federation requests.
122      */
123     public static enum FederationRequest {
df162c 124         POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_TEAMS, PULL_SETTINGS, PULL_SCRIPTS, STATUS;
831469 125
JM 126         public static FederationRequest fromName(String name) {
127             for (FederationRequest type : values()) {
128                 if (type.name().equalsIgnoreCase(name)) {
129                     return type;
130                 }
131             }
132             return PULL_REPOSITORIES;
133         }
134
135         public String toString() {
136             return name();
137         }
138     }
139
140     /**
141      * Enumeration representing the statii of federation requests.
142      */
143     public static enum FederationPullStatus {
c729c5 144         PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
831469 145
JM 146         public static FederationPullStatus fromName(String name) {
147             for (FederationPullStatus type : values()) {
148                 if (type.name().equalsIgnoreCase(name)) {
149                     return type;
150                 }
151             }
152             return PENDING;
153         }
154
155         @Override
156         public String toString() {
157             return name();
158         }
159     }
8f73a7 160
831469 161     /**
JM 162      * Enumeration representing the federation types.
163      */
164     public static enum FederationStrategy {
165         EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
166
167         public static FederationStrategy fromName(String name) {
168             for (FederationStrategy type : values()) {
169                 if (type.name().equalsIgnoreCase(name)) {
170                     return type;
171                 }
172             }
173             return FEDERATE_THIS;
174         }
175
8f73a7 176         public boolean exceeds(FederationStrategy type) {
JM 177             return this.ordinal() > type.ordinal();
178         }
179
180         public boolean atLeast(FederationStrategy type) {
181             return this.ordinal() >= type.ordinal();
182         }
183
831469 184         @Override
JM 185         public String toString() {
186             return name();
187         }
188     }
189
4aafd4 190     /**
JM 191      * Enumeration representing the possible results of federation proposal
192      * requests.
193      */
194     public static enum FederationProposalResult {
195         ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
196
197         @Override
198         public String toString() {
199             return name();
200         }
201     }
93f0b1 202
JM 203     /**
204      * Enumeration representing the possible remote procedure call requests from
205      * a client.
206      */
207     public static enum RpcRequest {
ec5a88 208         // Order is important here.  anything above LIST_SETTINGS requires
JM 209         // administrator privileges and web.allowRpcManagement.
f08aab 210         GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS,
JM 211         CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY, 
212         LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, 
213         LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
214         LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS, 
215         LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
ec5a88 216         EDIT_SETTINGS, LIST_STATUS;
31abc2 217
93f0b1 218         public static RpcRequest fromName(String name) {
JM 219             for (RpcRequest type : values()) {
220                 if (type.name().equalsIgnoreCase(name)) {
221                     return type;
222                 }
223             }
b2fde8 224             return null;
ec5a88 225         }        
31abc2 226
ca9d0f 227         public boolean exceeds(RpcRequest type) {
JM 228             return this.ordinal() > type.ordinal();
229         }
31abc2 230
93f0b1 231         @Override
JM 232         public String toString() {
233             return name();
234         }
235     }
33d8d8 236
JM 237     /**
238      * Enumeration of the search types.
239      */
240     public static enum SearchType {
241         AUTHOR, COMMITTER, COMMIT;
242     
243         public static SearchType forName(String name) {
244             for (SearchType type : values()) {
245                 if (type.name().equalsIgnoreCase(name)) {
246                     return type;
247                 }
248             }
249             return COMMIT;
250         }
251     
252         @Override
253         public String toString() {
254             return name().toLowerCase();
255         }
256     }
5fe7df 257 }