Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ServiceMayNotContinueException.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2011-2012, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.transport;
  11. import java.io.IOException;
  12. import org.eclipse.jgit.internal.JGitText;
  13. /**
  14. * Indicates a transport service may not continue execution.
  15. *
  16. * @since 2.0
  17. */
  18. public class ServiceMayNotContinueException extends IOException {
  19. private static final int FORBIDDEN = 403;
  20. private static final long serialVersionUID = 1L;
  21. private final int statusCode;
  22. private boolean output;
  23. /**
  24. * Initialize with no message.
  25. */
  26. public ServiceMayNotContinueException() {
  27. // Do not set a message.
  28. statusCode = FORBIDDEN;
  29. }
  30. /**
  31. * <p>Constructor for ServiceMayNotContinueException.</p>
  32. *
  33. * @param msg
  34. * a message explaining why it cannot continue. This message may
  35. * be shown to an end-user.
  36. */
  37. public ServiceMayNotContinueException(String msg) {
  38. super(msg);
  39. statusCode = FORBIDDEN;
  40. }
  41. /**
  42. * <p>Constructor for ServiceMayNotContinueException.</p>
  43. *
  44. * @param msg
  45. * a message explaining why it cannot continue. This message may
  46. * be shown to an end-user.
  47. * @param statusCode
  48. * the HTTP status code.
  49. * @since 4.5
  50. */
  51. public ServiceMayNotContinueException(String msg, int statusCode) {
  52. super(msg);
  53. this.statusCode = statusCode;
  54. }
  55. /**
  56. * <p>Constructor for ServiceMayNotContinueException.</p>
  57. *
  58. * @param msg
  59. * a message explaining why it cannot continue. This message may
  60. * be shown to an end-user.
  61. * @param cause
  62. * the cause of the exception.
  63. * @since 3.2
  64. */
  65. public ServiceMayNotContinueException(String msg, Throwable cause) {
  66. super(msg, cause);
  67. statusCode = FORBIDDEN;
  68. }
  69. /**
  70. * <p>Constructor for ServiceMayNotContinueException.</p>
  71. *
  72. * @param msg
  73. * a message explaining why it cannot continue. This message may
  74. * be shown to an end-user.
  75. * @param cause
  76. * the cause of the exception.
  77. * @param statusCode
  78. * the HTTP status code.
  79. * @since 4.5
  80. */
  81. public ServiceMayNotContinueException(
  82. String msg, Throwable cause, int statusCode) {
  83. super(msg, cause);
  84. this.statusCode = statusCode;
  85. }
  86. /**
  87. * Initialize with an "internal server error" message and a cause.
  88. *
  89. * @param cause
  90. * the cause of the exception.
  91. * @since 3.2
  92. */
  93. public ServiceMayNotContinueException(Throwable cause) {
  94. this(JGitText.get().internalServerError, cause);
  95. }
  96. /**
  97. * Whether the message was already output to the client.
  98. *
  99. * @return {@code true} if the message was already output to the client.
  100. */
  101. public boolean isOutput() {
  102. return output;
  103. }
  104. /**
  105. * Mark this message has being sent to the client.
  106. */
  107. public void setOutput() {
  108. output = true;
  109. }
  110. /**
  111. * Get status code
  112. *
  113. * @return true if the message was already output to the client.
  114. * @since 4.5
  115. */
  116. public int getStatusCode() {
  117. return statusCode;
  118. }
  119. }