James Moger
2011-09-27 cd4b2b84cc6e55afc7c15dcdaade779aa858da6a
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.
cd4b2b 32     public static final String VERSION = "0.6.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.
cd4b2b 36     public static final String VERSION_DATE = "2011-09-27";
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/";
JM 55
1f9dae 56     public static final String BORDER = "***********************************************************";
db653a 57
831469 58     public static final String FEDERATION_USER = "$gitblit";
JM 59
60     public static final String PROPOSAL_EXT = ".json";
61
62     public static String getGitBlitVersion() {
63         return NAME + " v" + VERSION;
64     }
65
88598b 66     /**
831469 67      * Enumeration representing the four access restriction levels.
88598b 68      */
dfb889 69     public static enum AccessRestrictionType {
JM 70         NONE, PUSH, CLONE, VIEW;
71
d0d438 72         public static AccessRestrictionType fromName(String name) {
dfb889 73             for (AccessRestrictionType type : values()) {
d0d438 74                 if (type.name().equalsIgnoreCase(name)) {
dfb889 75                     return type;
JM 76                 }
77             }
78             return NONE;
79         }
f98825 80
JM 81         public boolean exceeds(AccessRestrictionType type) {
82             return this.ordinal() > type.ordinal();
83         }
84
dfb889 85         public boolean atLeast(AccessRestrictionType type) {
JM 86             return this.ordinal() >= type.ordinal();
87         }
88
89         public String toString() {
f98825 90             return name();
dfb889 91         }
JM 92     }
93
831469 94     /**
JM 95      * Enumeration representing the types of federation tokens.
96      */
97     public static enum FederationToken {
98         ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
99
100         public static FederationToken fromName(String name) {
101             for (FederationToken type : values()) {
102                 if (type.name().equalsIgnoreCase(name)) {
103                     return type;
104                 }
105             }
106             return REPOSITORIES;
107         }
108
109         public String toString() {
110             return name();
111         }
5fe7df 112     }
831469 113
JM 114     /**
115      * Enumeration representing the types of federation requests.
116      */
117     public static enum FederationRequest {
4aafd4 118         POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_SETTINGS, STATUS;
831469 119
JM 120         public static FederationRequest fromName(String name) {
121             for (FederationRequest type : values()) {
122                 if (type.name().equalsIgnoreCase(name)) {
123                     return type;
124                 }
125             }
126             return PULL_REPOSITORIES;
127         }
128
129         public String toString() {
130             return name();
131         }
132     }
133
134     /**
135      * Enumeration representing the statii of federation requests.
136      */
137     public static enum FederationPullStatus {
c729c5 138         PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
831469 139
JM 140         public static FederationPullStatus fromName(String name) {
141             for (FederationPullStatus type : values()) {
142                 if (type.name().equalsIgnoreCase(name)) {
143                     return type;
144                 }
145             }
146             return PENDING;
147         }
148
149         @Override
150         public String toString() {
151             return name();
152         }
153     }
8f73a7 154
831469 155     /**
JM 156      * Enumeration representing the federation types.
157      */
158     public static enum FederationStrategy {
159         EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
160
161         public static FederationStrategy fromName(String name) {
162             for (FederationStrategy type : values()) {
163                 if (type.name().equalsIgnoreCase(name)) {
164                     return type;
165                 }
166             }
167             return FEDERATE_THIS;
168         }
169
8f73a7 170         public boolean exceeds(FederationStrategy type) {
JM 171             return this.ordinal() > type.ordinal();
172         }
173
174         public boolean atLeast(FederationStrategy type) {
175             return this.ordinal() >= type.ordinal();
176         }
177
831469 178         @Override
JM 179         public String toString() {
180             return name();
181         }
182     }
183
4aafd4 184     /**
JM 185      * Enumeration representing the possible results of federation proposal
186      * requests.
187      */
188     public static enum FederationProposalResult {
189         ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
190
191         @Override
192         public String toString() {
193             return name();
194         }
195     }
5fe7df 196 }