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.

PermissionTemplateNewValue.java 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.db.audit.model;
  21. import java.util.Objects;
  22. import javax.annotation.CheckForNull;
  23. import javax.annotation.Nullable;
  24. import org.sonar.db.permission.template.PermissionTemplateDto;
  25. public class PermissionTemplateNewValue extends NewValue {
  26. /**
  27. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  28. */
  29. @Deprecated(since = "10.2")
  30. private String templateUuid;
  31. private String name;
  32. @Nullable
  33. private String keyPattern;
  34. @Nullable
  35. private String description;
  36. @Nullable
  37. private String permission;
  38. /**
  39. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  40. */
  41. @Deprecated(since = "10.2")
  42. @Nullable
  43. private String userUuid;
  44. @Nullable
  45. private String userLogin;
  46. /**
  47. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  48. */
  49. @Deprecated(since = "10.2")
  50. @Nullable
  51. private String groupUuid;
  52. @Nullable
  53. private String groupName;
  54. @Nullable
  55. private Boolean withProjectCreator;
  56. public PermissionTemplateNewValue(String templateUuid, String name) {
  57. this.templateUuid = templateUuid;
  58. this.name = name;
  59. }
  60. public PermissionTemplateNewValue(PermissionTemplateDto permissionTemplateDto) {
  61. this.templateUuid = permissionTemplateDto.getUuid();
  62. this.name = permissionTemplateDto.getName();
  63. this.keyPattern = permissionTemplateDto.getKeyPattern();
  64. this.description = permissionTemplateDto.getDescription();
  65. }
  66. public PermissionTemplateNewValue(@Nullable String templateUuid, @Nullable String name, @Nullable String permission,
  67. @Nullable String userUuid, @Nullable String userLogin, @Nullable String groupUuid, @Nullable String groupName) {
  68. this.templateUuid = templateUuid;
  69. this.name = name;
  70. this.permission = permission;
  71. this.userUuid = userUuid;
  72. this.userLogin = userLogin;
  73. this.groupUuid = groupUuid;
  74. this.groupName = groupName;
  75. }
  76. public PermissionTemplateNewValue(String templateUuid, String permission, String name, boolean withProjectCreator) {
  77. this.templateUuid = templateUuid;
  78. this.name = name;
  79. this.permission = permission;
  80. this.withProjectCreator = withProjectCreator;
  81. }
  82. /**
  83. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  84. */
  85. @Deprecated(since = "10.2")
  86. public String getTemplateUuid() {
  87. return this.templateUuid;
  88. }
  89. public String getName() {
  90. return this.name;
  91. }
  92. @CheckForNull
  93. public String getKeyPattern() {
  94. return this.keyPattern;
  95. }
  96. @CheckForNull
  97. public String getDescription() {
  98. return this.description;
  99. }
  100. @CheckForNull
  101. public String getPermission() {
  102. return this.permission;
  103. }
  104. /**
  105. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  106. */
  107. @Deprecated(since = "10.2")
  108. @CheckForNull
  109. public String getUserUuid() {
  110. return this.userUuid;
  111. }
  112. @CheckForNull
  113. public String getUserLogin() {
  114. return this.userLogin;
  115. }
  116. /**
  117. * @deprecated The uuids in the audit logs are not product requirement anymore and will be removed in 11.x
  118. */
  119. @Deprecated(since = "10.2")
  120. @CheckForNull
  121. public String getGroupUuid() {
  122. return this.groupUuid;
  123. }
  124. @CheckForNull
  125. public String getGroupName() {
  126. return this.groupName;
  127. }
  128. @CheckForNull
  129. public Boolean isWithProjectCreator() {
  130. return this.withProjectCreator;
  131. }
  132. @Override
  133. public String toString() {
  134. StringBuilder sb = new StringBuilder("{");
  135. addField(sb, "\"templateUuid\": ", this.templateUuid, true);
  136. addField(sb, "\"name\": ", this.name, true);
  137. addField(sb, "\"keyPattern\": ", this.keyPattern, true);
  138. addField(sb, "\"description\": ", this.description, true);
  139. addField(sb, "\"permission\": ", this.permission, true);
  140. addField(sb, "\"userUuid\": ", this.userUuid, true);
  141. addField(sb, "\"userLogin\": ", this.userLogin, true);
  142. addField(sb, "\"groupUuid\": ", this.groupUuid, true);
  143. addField(sb, "\"groupName\": ", this.groupName, true);
  144. addField(sb, "\"withProjectCreator\": ", Objects.toString(this.withProjectCreator, ""), false);
  145. endString(sb);
  146. return sb.toString();
  147. }
  148. }