James Moger
2011-11-11 c2fe08bb91494d3ce9dae60ed89f29bb0057bbf8
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.
c2fe08 32     public static final String VERSION = "0.7.0";
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.
c2fe08 36     public static final String VERSION_DATE = "2011-11-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.
9b72a2 40     public static final String JGIT_VERSION = "JGit 1.1.0 (201109151100-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/";
831469 57
1f9dae 58     public static final String BORDER = "***********************************************************";
db653a 59
831469 60     public static final String FEDERATION_USER = "$gitblit";
JM 61
62     public static final String PROPOSAL_EXT = ".json";
63
64     public static String getGitBlitVersion() {
65         return NAME + " v" + VERSION;
66     }
67
88598b 68     /**
831469 69      * Enumeration representing the four access restriction levels.
88598b 70      */
dfb889 71     public static enum AccessRestrictionType {
JM 72         NONE, PUSH, CLONE, VIEW;
73
d0d438 74         public static AccessRestrictionType fromName(String name) {
dfb889 75             for (AccessRestrictionType type : values()) {
d0d438 76                 if (type.name().equalsIgnoreCase(name)) {
dfb889 77                     return type;
JM 78                 }
79             }
80             return NONE;
81         }
f98825 82
JM 83         public boolean exceeds(AccessRestrictionType type) {
84             return this.ordinal() > type.ordinal();
85         }
86
dfb889 87         public boolean atLeast(AccessRestrictionType type) {
JM 88             return this.ordinal() >= type.ordinal();
89         }
90
91         public String toString() {
f98825 92             return name();
dfb889 93         }
JM 94     }
95
831469 96     /**
JM 97      * Enumeration representing the types of federation tokens.
98      */
99     public static enum FederationToken {
100         ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
101
102         public static FederationToken fromName(String name) {
103             for (FederationToken type : values()) {
104                 if (type.name().equalsIgnoreCase(name)) {
105                     return type;
106                 }
107             }
108             return REPOSITORIES;
109         }
110
111         public String toString() {
112             return name();
113         }
5fe7df 114     }
831469 115
JM 116     /**
117      * Enumeration representing the types of federation requests.
118      */
119     public static enum FederationRequest {
4aafd4 120         POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_SETTINGS, STATUS;
831469 121
JM 122         public static FederationRequest fromName(String name) {
123             for (FederationRequest type : values()) {
124                 if (type.name().equalsIgnoreCase(name)) {
125                     return type;
126                 }
127             }
128             return PULL_REPOSITORIES;
129         }
130
131         public String toString() {
132             return name();
133         }
134     }
135
136     /**
137      * Enumeration representing the statii of federation requests.
138      */
139     public static enum FederationPullStatus {
c729c5 140         PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
831469 141
JM 142         public static FederationPullStatus fromName(String name) {
143             for (FederationPullStatus type : values()) {
144                 if (type.name().equalsIgnoreCase(name)) {
145                     return type;
146                 }
147             }
148             return PENDING;
149         }
150
151         @Override
152         public String toString() {
153             return name();
154         }
155     }
8f73a7 156
831469 157     /**
JM 158      * Enumeration representing the federation types.
159      */
160     public static enum FederationStrategy {
161         EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
162
163         public static FederationStrategy fromName(String name) {
164             for (FederationStrategy type : values()) {
165                 if (type.name().equalsIgnoreCase(name)) {
166                     return type;
167                 }
168             }
169             return FEDERATE_THIS;
170         }
171
8f73a7 172         public boolean exceeds(FederationStrategy type) {
JM 173             return this.ordinal() > type.ordinal();
174         }
175
176         public boolean atLeast(FederationStrategy type) {
177             return this.ordinal() >= type.ordinal();
178         }
179
831469 180         @Override
JM 181         public String toString() {
182             return name();
183         }
184     }
185
4aafd4 186     /**
JM 187      * Enumeration representing the possible results of federation proposal
188      * requests.
189      */
190     public static enum FederationProposalResult {
191         ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
192
193         @Override
194         public String toString() {
195             return name();
196         }
197     }
93f0b1 198
JM 199     /**
200      * Enumeration representing the possible remote procedure call requests from
201      * a client.
202      */
203     public static enum RpcRequest {
ec5a88 204         // Order is important here.  anything above LIST_SETTINGS requires
JM 205         // administrator privileges and web.allowRpcManagement.
206         LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS, CREATE_REPOSITORY, EDIT_REPOSITORY,
207         DELETE_REPOSITORY, LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, 
208         LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_FEDERATION_REGISTRATIONS,
209         LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
210         EDIT_SETTINGS, LIST_STATUS;
31abc2 211
93f0b1 212         public static RpcRequest fromName(String name) {
JM 213             for (RpcRequest type : values()) {
214                 if (type.name().equalsIgnoreCase(name)) {
215                     return type;
216                 }
217             }
b2fde8 218             return null;
ec5a88 219         }        
31abc2 220
ca9d0f 221         public boolean exceeds(RpcRequest type) {
JM 222             return this.ordinal() > type.ordinal();
223         }
31abc2 224
93f0b1 225         @Override
JM 226         public String toString() {
227             return name();
228         }
229     }
33d8d8 230
JM 231     /**
232      * Enumeration of the search types.
233      */
234     public static enum SearchType {
235         AUTHOR, COMMITTER, COMMIT;
236     
237         public static SearchType forName(String name) {
238             for (SearchType type : values()) {
239                 if (type.name().equalsIgnoreCase(name)) {
240                     return type;
241                 }
242             }
243             return COMMIT;
244         }
245     
246         @Override
247         public String toString() {
248             return name().toLowerCase();
249         }
250     }
5fe7df 251 }