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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 = "0.9.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 1.3.0 (201202151440-r)";
  35. public static final String ADMIN_ROLE = "#admin";
  36. public static final String NOT_FEDERATED_ROLE = "#notfederated";
  37. public static final String PROPERTIES_FILE = "gitblit.properties";
  38. public static final String GIT_PATH = "/git/";
  39. public static final String ZIP_PATH = "/zip/";
  40. public static final String SYNDICATION_PATH = "/feed/";
  41. public static final String FEDERATION_PATH = "/federation/";
  42. public static final String RPC_PATH = "/rpc/";
  43. public static final String PAGES= "/pages/";
  44. public static final String BORDER = "***********************************************************";
  45. public static final String FEDERATION_USER = "$gitblit";
  46. public static final String PROPOSAL_EXT = ".json";
  47. public static final String ENCODING = "UTF-8";
  48. public static final int LEN_SHORTLOG = 80;
  49. public static final int LEN_SHORTLOG_REFS = 60;
  50. public static String getGitBlitVersion() {
  51. return NAME + " v" + VERSION;
  52. }
  53. /**
  54. * Enumeration representing the four access restriction levels.
  55. */
  56. public static enum AccessRestrictionType {
  57. NONE, PUSH, CLONE, VIEW;
  58. public static AccessRestrictionType fromName(String name) {
  59. for (AccessRestrictionType type : values()) {
  60. if (type.name().equalsIgnoreCase(name)) {
  61. return type;
  62. }
  63. }
  64. return NONE;
  65. }
  66. public boolean exceeds(AccessRestrictionType type) {
  67. return this.ordinal() > type.ordinal();
  68. }
  69. public boolean atLeast(AccessRestrictionType type) {
  70. return this.ordinal() >= type.ordinal();
  71. }
  72. public String toString() {
  73. return name();
  74. }
  75. }
  76. /**
  77. * Enumeration representing the types of federation tokens.
  78. */
  79. public static enum FederationToken {
  80. ALL, USERS_AND_REPOSITORIES, REPOSITORIES;
  81. public static FederationToken fromName(String name) {
  82. for (FederationToken type : values()) {
  83. if (type.name().equalsIgnoreCase(name)) {
  84. return type;
  85. }
  86. }
  87. return REPOSITORIES;
  88. }
  89. public String toString() {
  90. return name();
  91. }
  92. }
  93. /**
  94. * Enumeration representing the types of federation requests.
  95. */
  96. public static enum FederationRequest {
  97. POKE, PROPOSAL, PULL_REPOSITORIES, PULL_USERS, PULL_TEAMS, PULL_SETTINGS, PULL_SCRIPTS, STATUS;
  98. public static FederationRequest fromName(String name) {
  99. for (FederationRequest type : values()) {
  100. if (type.name().equalsIgnoreCase(name)) {
  101. return type;
  102. }
  103. }
  104. return PULL_REPOSITORIES;
  105. }
  106. public String toString() {
  107. return name();
  108. }
  109. }
  110. /**
  111. * Enumeration representing the statii of federation requests.
  112. */
  113. public static enum FederationPullStatus {
  114. PENDING, FAILED, SKIPPED, PULLED, MIRRORED, NOCHANGE, EXCLUDED;
  115. public static FederationPullStatus fromName(String name) {
  116. for (FederationPullStatus type : values()) {
  117. if (type.name().equalsIgnoreCase(name)) {
  118. return type;
  119. }
  120. }
  121. return PENDING;
  122. }
  123. @Override
  124. public String toString() {
  125. return name();
  126. }
  127. }
  128. /**
  129. * Enumeration representing the federation types.
  130. */
  131. public static enum FederationStrategy {
  132. EXCLUDE, FEDERATE_THIS, FEDERATE_ORIGIN;
  133. public static FederationStrategy fromName(String name) {
  134. for (FederationStrategy type : values()) {
  135. if (type.name().equalsIgnoreCase(name)) {
  136. return type;
  137. }
  138. }
  139. return FEDERATE_THIS;
  140. }
  141. public boolean exceeds(FederationStrategy type) {
  142. return this.ordinal() > type.ordinal();
  143. }
  144. public boolean atLeast(FederationStrategy type) {
  145. return this.ordinal() >= type.ordinal();
  146. }
  147. @Override
  148. public String toString() {
  149. return name();
  150. }
  151. }
  152. /**
  153. * Enumeration representing the possible results of federation proposal
  154. * requests.
  155. */
  156. public static enum FederationProposalResult {
  157. ERROR, FEDERATION_DISABLED, MISSING_DATA, NO_PROPOSALS, NO_POKE, ACCEPTED;
  158. @Override
  159. public String toString() {
  160. return name();
  161. }
  162. }
  163. /**
  164. * Enumeration representing the possible remote procedure call requests from
  165. * a client.
  166. */
  167. public static enum RpcRequest {
  168. // Order is important here. anything above LIST_SETTINGS requires
  169. // administrator privileges and web.allowRpcManagement.
  170. GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, LIST_SETTINGS,
  171. CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,
  172. LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,
  173. LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
  174. LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS,
  175. LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
  176. EDIT_SETTINGS, LIST_STATUS;
  177. public static RpcRequest fromName(String name) {
  178. for (RpcRequest type : values()) {
  179. if (type.name().equalsIgnoreCase(name)) {
  180. return type;
  181. }
  182. }
  183. return null;
  184. }
  185. public boolean exceeds(RpcRequest type) {
  186. return this.ordinal() > type.ordinal();
  187. }
  188. @Override
  189. public String toString() {
  190. return name();
  191. }
  192. }
  193. /**
  194. * Enumeration of the search types.
  195. */
  196. public static enum SearchType {
  197. AUTHOR, COMMITTER, COMMIT;
  198. public static SearchType forName(String name) {
  199. for (SearchType type : values()) {
  200. if (type.name().equalsIgnoreCase(name)) {
  201. return type;
  202. }
  203. }
  204. return COMMIT;
  205. }
  206. @Override
  207. public String toString() {
  208. return name().toLowerCase();
  209. }
  210. }
  211. /**
  212. * The types of objects that can be indexed and queried.
  213. */
  214. public static enum SearchObjectType {
  215. commit, blob, issue;
  216. static SearchObjectType fromName(String name) {
  217. for (SearchObjectType value : values()) {
  218. if (value.name().equals(name)) {
  219. return value;
  220. }
  221. }
  222. return null;
  223. }
  224. }
  225. }