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.

ErrorMessage.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package org.apache.archiva.rest.api.services.v2;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import io.swagger.v3.oas.annotations.media.Schema;
  21. import javax.xml.bind.annotation.XmlRootElement;
  22. import java.io.Serializable;
  23. /**
  24. * @author Olivier Lamy
  25. * @author Martin Stockhammer
  26. * @since 3.0
  27. */
  28. @XmlRootElement( name = "errorMessage" )
  29. @Schema(name="ErrorMessage",description = "Information about the error, that occurred while processing the REST request.")
  30. public class ErrorMessage
  31. implements Serializable
  32. {
  33. private String errorKey = "";
  34. private String[] args = EMPTY;
  35. private String message = "";
  36. private static final String[] EMPTY = new String[0];
  37. public ErrorMessage()
  38. {
  39. // no op
  40. }
  41. public ErrorMessage( String errorKey )
  42. {
  43. this.errorKey = errorKey;
  44. this.args = EMPTY;
  45. }
  46. public ErrorMessage( String errorKey, String[] args )
  47. {
  48. this.errorKey = errorKey;
  49. this.args = args;
  50. }
  51. public static ErrorMessage of(String errorKey, String... args) {
  52. return new ErrorMessage( errorKey, args );
  53. }
  54. @Schema(name="error_key", description = "The key of the error message. If this is empty, the message message must be set.")
  55. public String getErrorKey()
  56. {
  57. return errorKey;
  58. }
  59. public void setErrorKey( String errorKey )
  60. {
  61. this.errorKey = errorKey;
  62. }
  63. @Schema(description = "Parameters that can be filled to the translated error message")
  64. public String[] getArgs()
  65. {
  66. return args;
  67. }
  68. public void setArgs( String[] args )
  69. {
  70. this.args = args;
  71. }
  72. @Schema(description = "Full error message. Either additional to the key in the default language, or if the message is without key.")
  73. public String getMessage()
  74. {
  75. return message;
  76. }
  77. public void setMessage( String message )
  78. {
  79. this.message = message;
  80. }
  81. public ErrorMessage message( String message )
  82. {
  83. this.message = message;
  84. return this;
  85. }
  86. }