2 * SonarQube, open source software quality management tool.
3 * Copyright (C) 2008-2014 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * SonarQube 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.
11 * SonarQube 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.
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.
21 package org.sonar.server.permission.ws;
23 import org.sonar.api.server.ws.WebService.NewAction;
24 import org.sonar.core.permission.GlobalPermissions;
25 import org.sonar.core.permission.ProjectPermissions;
26 import org.sonar.core.util.Uuids;
28 import static java.lang.String.format;
30 public class PermissionsWsParametersBuilder {
32 private static final String PERMISSION_PARAM_DESCRIPTION = format("Permission" +
34 "<li>Possible values for global permissions: %s</li>" +
35 "<li>Possible values for project permissions %s</li>" +
37 GlobalPermissions.ALL_ON_ONE_LINE,
38 ProjectPermissions.ALL_ON_ONE_LINE);
39 private static final String PROJECT_PERMISSION_PARAM_DESCRIPTION = format("Permission" +
41 "<li>Possible values for project permissions %s</li>" +
43 ProjectPermissions.ALL_ON_ONE_LINE);
45 private PermissionsWsParametersBuilder() {
46 // static methods only
49 public static void createPermissionParameter(NewAction action) {
50 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION)
51 .setDescription(PERMISSION_PARAM_DESCRIPTION)
55 public static void createProjectPermissionParameter(NewAction action) {
56 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION)
57 .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION)
61 public static void createGroupNameParameter(NewAction action) {
62 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_NAME)
63 .setDescription("Group name or 'anyone' (case insensitive)")
64 .setExampleValue("sonar-administrators");
67 public static void createGroupIdParameter(NewAction action) {
68 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID)
69 .setDescription("Group id")
70 .setExampleValue("42");
73 public static void createProjectParameter(NewAction action) {
74 createProjectIdParameter(action);
75 createProjectKeyParameter(action);
78 private static void createProjectIdParameter(NewAction action) {
79 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID)
80 .setDescription("Project id")
81 .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d");
84 private static void createProjectKeyParameter(NewAction action) {
85 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY)
86 .setDescription("Project key")
87 .setExampleValue("org.apache.hbas:hbase");
90 public static void createUserLoginParameter(NewAction action) {
91 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN)
93 .setDescription("User login")
94 .setExampleValue("g.hopper");
97 public static void createTemplateParameters(NewAction action) {
98 createTemplateIdParameter(action);
99 createTemplateNameParameter(action);
102 private static void createTemplateIdParameter(NewAction action) {
103 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_ID)
104 .setDescription("Template id")
105 .setExampleValue(Uuids.UUID_EXAMPLE_01);
108 private static void createTemplateNameParameter(NewAction action) {
109 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME)
110 .setDescription("Template name")
111 .setExampleValue("Default Permission Template for Projects");
114 public static void createTemplateProjectKeyPatternParameter(NewAction action) {
115 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY_PATTERN)
116 .setDescription("Project key pattern. Must be a valid Java regular expression")
117 .setExampleValue(".*\\.finance\\..*");
120 public static void createTemplateDescriptionParameter(NewAction action) {
121 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION)
122 .setDescription("Description")
123 .setExampleValue("Permissions for all projects related to the financial service");
126 public static void createIdParameter(NewAction action) {
127 action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID)
129 .setDescription("Id")
130 .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");