You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Constants.java 7.9KB

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