From ae64fe3edb2f5e96a2d40c8bce24bae4fa7fd4a2 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Mon, 7 Sep 2015 17:00:10 +0200 Subject: [PATCH] Add template package in the permission.ws package --- .../permission/ws/DeleteTemplateAction.java | 1 + .../ws/PermissionChangeBuilder.java | 4 +- .../ws/PermissionDependenciesFinder.java | 12 ++--- .../permission/ws/PermissionQueryParser.java | 2 +- .../permission/ws/PermissionRequest.java | 26 +++++----- .../permission/ws/PermissionsWsModule.java | 11 +++++ .../ws/ResourceTypeToQualifier.java | 4 +- .../SearchProjectPermissionsDataLoader.java | 2 +- .../server/permission/ws/WsGroupRef.java | 8 ++-- .../permission/ws/WsPermissionParameters.java | 48 +++++++++---------- .../server/permission/ws/WsProjectRef.java | 10 ++-- .../server/permission/ws/WsTemplateRef.java | 10 ++-- .../AddGroupToTemplateAction.java | 10 ++-- .../AddUserToTemplateAction.java | 5 +- .../{ => template}/ApplyTemplateAction.java | 6 ++- .../{ => template}/CreateTemplateAction.java | 7 +-- .../DefaultPermissionTemplateFinder.java | 8 ++-- .../PermissionTemplateDtoBuilder.java | 14 +++--- ...mplateDtoToPermissionTemplateResponse.java | 6 +-- .../RemoveGroupFromTemplateAction.java | 6 ++- .../RemoveUserFromTemplateAction.java | 5 +- .../{ => template}/SearchTemplatesAction.java | 3 +- .../{ => template}/SearchTemplatesData.java | 4 +- .../SearchTemplatesDataLoader.java | 6 +-- .../SetDefaultTemplateAction.java | 5 +- .../{ => template}/UpdateTemplateAction.java | 7 ++- .../permission/ws/template/package-info.java | 24 ++++++++++ .../create_template-example.json | 0 .../search_templates-example.json | 0 .../update_template-example.json | 0 .../AddGroupToTemplateActionTest.java | 6 ++- .../AddUserToTemplateActionTest.java | 5 +- .../ApplyTemplateActionTest.java | 4 +- .../CreateTemplateActionTest.java | 2 +- .../DefaultPermissionTemplateFinderTest.java | 3 +- .../DeleteTemplateActionTest.java | 5 +- .../RemoveGroupFromTemplateActionTest.java | 4 +- .../RemoveUserFromTemplateActionTest.java | 5 +- .../SearchTemplatesActionTest.java | 2 +- .../SetDefaultTemplateActionTest.java | 4 +- .../UpdateTemplateActionTest.java | 3 +- .../SearchTemplatesActionTest/empty.json | 0 42 files changed, 189 insertions(+), 108 deletions(-) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/AddGroupToTemplateAction.java (94%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/AddUserToTemplateAction.java (95%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/ApplyTemplateAction.java (91%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/CreateTemplateAction.java (94%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/DefaultPermissionTemplateFinder.java (94%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/PermissionTemplateDtoBuilder.java (80%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/PermissionTemplateDtoToPermissionTemplateResponse.java (90%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/RemoveGroupFromTemplateAction.java (93%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/RemoveUserFromTemplateAction.java (94%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/SearchTemplatesAction.java (98%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/SearchTemplatesData.java (96%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/SearchTemplatesDataLoader.java (95%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/SetDefaultTemplateAction.java (95%) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{ => template}/UpdateTemplateAction.java (94%) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/package-info.java rename server/sonar-server/src/main/resources/org/sonar/server/permission/ws/{ => template}/create_template-example.json (100%) rename server/sonar-server/src/main/resources/org/sonar/server/permission/ws/{ => template}/search_templates-example.json (100%) rename server/sonar-server/src/main/resources/org/sonar/server/permission/ws/{ => template}/update_template-example.json (100%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/AddGroupToTemplateActionTest.java (98%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/AddUserToTemplateActionTest.java (96%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/ApplyTemplateActionTest.java (98%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/CreateTemplateActionTest.java (99%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/DefaultPermissionTemplateFinderTest.java (96%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/DeleteTemplateActionTest.java (96%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/RemoveGroupFromTemplateActionTest.java (98%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/RemoveUserFromTemplateActionTest.java (97%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/SearchTemplatesActionTest.java (99%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/SetDefaultTemplateActionTest.java (97%) rename server/sonar-server/src/test/java/org/sonar/server/permission/ws/{ => template}/UpdateTemplateActionTest.java (98%) rename server/sonar-server/src/test/resources/org/sonar/server/permission/ws/{ => template}/SearchTemplatesActionTest/empty.json (100%) diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java index 4acc8fcdff6..4813560a92c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java @@ -27,6 +27,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionChangeBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionChangeBuilder.java index 2049200bbe4..3418bfe0413 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionChangeBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionChangeBuilder.java @@ -33,7 +33,7 @@ public class PermissionChangeBuilder { this.dependenciesFinder = dependenciesFinder; } - PermissionChange buildUserPermissionChange(DbSession dbSession, PermissionRequest request) { + public PermissionChange buildUserPermissionChange(DbSession dbSession, PermissionRequest request) { PermissionChange permissionChange = new PermissionChange() .setPermission(request.permission()) .setUserLogin(request.userLogin()); @@ -42,7 +42,7 @@ public class PermissionChangeBuilder { return permissionChange; } - PermissionChange buildGroupPermissionChange(DbSession dbSession, PermissionRequest request) { + public PermissionChange buildGroupPermissionChange(DbSession dbSession, PermissionRequest request) { String groupName = dependenciesFinder.getGroupName(dbSession, request); PermissionChange permissionChange = new PermissionChange() diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionDependenciesFinder.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionDependenciesFinder.java index fd56efbd8b0..9838e66f733 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionDependenciesFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionDependenciesFinder.java @@ -47,7 +47,7 @@ public class PermissionDependenciesFinder { /** * @throws org.sonar.server.exceptions.NotFoundException if a project identifier is provided but it's not found */ - Optional searchProject(DbSession dbSession, PermissionRequest request) { + public Optional searchProject(DbSession dbSession, PermissionRequest request) { if (!request.project().isPresent()) { return Optional.absent(); } @@ -56,11 +56,11 @@ public class PermissionDependenciesFinder { return Optional.of(componentFinder.getProjectByUuidOrKey(dbSession, wsProjectRef.uuid(), wsProjectRef.key())); } - ComponentDto getProject(DbSession dbSession, WsProjectRef projectRef) { + public ComponentDto getProject(DbSession dbSession, WsProjectRef projectRef) { return componentFinder.getProjectByUuidOrKey(dbSession, projectRef.uuid(), projectRef.key()); } - String getGroupName(DbSession dbSession, PermissionRequest request) { + public String getGroupName(DbSession dbSession, PermissionRequest request) { GroupDto group = getGroup(dbSession, request.group()); return group == null ? ANYONE : group.getName(); @@ -71,7 +71,7 @@ public class PermissionDependenciesFinder { * @return null if it's the anyone group */ @CheckForNull - GroupDto getGroup(DbSession dbSession, WsGroupRef group) { + public GroupDto getGroup(DbSession dbSession, WsGroupRef group) { Long groupId = group.id(); String groupName = group.name(); @@ -94,12 +94,12 @@ public class PermissionDependenciesFinder { return groupDto; } - UserDto getUser(DbSession dbSession, String userLogin) { + public UserDto getUser(DbSession dbSession, String userLogin) { return checkFound(dbClient.userDao().selectActiveUserByLogin(dbSession, userLogin), format("User with login '%s' is not found'", userLogin)); } - PermissionTemplateDto getTemplate(DbSession dbSession, WsTemplateRef template) { + public PermissionTemplateDto getTemplate(DbSession dbSession, WsTemplateRef template) { if (template.uuid() != null) { return checkFound(dbClient.permissionTemplateDao().selectByUuid(dbSession, template.uuid()), format("Permission template with id '%s' is not found", template.uuid())); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionQueryParser.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionQueryParser.java index 27f2c9b58c1..8f39e643329 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionQueryParser.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionQueryParser.java @@ -29,7 +29,7 @@ class PermissionQueryParser { // Utility class } - static String fromSelectionModeToMembership(String selectionModeString) { + public static String fromSelectionModeToMembership(String selectionModeString) { SelectionMode selectionMode = SelectionMode.fromParam(selectionModeString); if (SelectionMode.SELECTED == selectionMode) { return GroupMembershipQuery.IN; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java index fcce33c3cd9..11e48d6b1be 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java @@ -54,7 +54,7 @@ class PermissionRequest { query = builder.query; } - static class Builder { + public static class Builder { private final Request request; @@ -72,7 +72,7 @@ class PermissionRequest { private String selected; private String query; - Builder(Request request) { + public Builder(Request request) { this.request = request; } @@ -89,17 +89,17 @@ class PermissionRequest { return new PermissionRequest(this); } - Builder withUser() { + public Builder withUser() { this.withUser = true; return this; } - Builder withGroup() { + public Builder withGroup() { this.withGroup = true; return this; } - Builder withPagination() { + public Builder withPagination() { this.withPagination = true; return this; } @@ -151,35 +151,35 @@ class PermissionRequest { } } - String permission() { + public String permission() { return permission; } - String userLogin() { + public String userLogin() { return userLogin; } - WsGroupRef group() { + public WsGroupRef group() { return group; } - Optional project() { + public Optional project() { return project; } - Integer page() { + public Integer page() { return page; } - Integer pageSize() { + public Integer pageSize() { return pageSize; } - String selected() { + public String selected() { return selected; } - String query() { + public String query() { return query; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsModule.java index 9f9ed0213dc..957ef41e692 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsModule.java @@ -21,6 +21,17 @@ package org.sonar.server.permission.ws; import org.sonar.core.platform.Module; +import org.sonar.server.permission.ws.template.AddGroupToTemplateAction; +import org.sonar.server.permission.ws.template.AddUserToTemplateAction; +import org.sonar.server.permission.ws.template.ApplyTemplateAction; +import org.sonar.server.permission.ws.template.CreateTemplateAction; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder; +import org.sonar.server.permission.ws.template.RemoveGroupFromTemplateAction; +import org.sonar.server.permission.ws.template.RemoveUserFromTemplateAction; +import org.sonar.server.permission.ws.template.SearchTemplatesAction; +import org.sonar.server.permission.ws.template.SearchTemplatesDataLoader; +import org.sonar.server.permission.ws.template.SetDefaultTemplateAction; +import org.sonar.server.permission.ws.template.UpdateTemplateAction; public class PermissionsWsModule extends Module { @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ResourceTypeToQualifier.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ResourceTypeToQualifier.java index a751be79838..8c850cbd33d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ResourceTypeToQualifier.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ResourceTypeToQualifier.java @@ -24,9 +24,9 @@ import com.google.common.base.Function; import javax.annotation.Nonnull; import org.sonar.api.resources.ResourceType; -class ResourceTypeToQualifier { +public class ResourceTypeToQualifier { - static final Function RESOURCE_TYPE_TO_QUALIFIER = Singleton.INSTANCE; + public static final Function RESOURCE_TYPE_TO_QUALIFIER = Singleton.INSTANCE; private enum Singleton implements Function { INSTANCE; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsDataLoader.java index a3785a78598..a8489228ae6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsDataLoader.java @@ -58,7 +58,7 @@ public class SearchProjectPermissionsDataLoader { this.rootQualifiers = Collections2.transform(resourceTypes.getRoots(), RESOURCE_TYPE_TO_QUALIFIER); } - public SearchProjectPermissionsData load(Request wsRequest) { + SearchProjectPermissionsData load(Request wsRequest) { DbSession dbSession = dbClient.openSession(false); try { SearchProjectPermissionsData.Builder data = newBuilder(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsGroupRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsGroupRef.java index 2c735193a12..329b2d4f665 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsGroupRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsGroupRef.java @@ -31,7 +31,7 @@ import static org.sonar.server.ws.WsUtils.checkRequest; /** * Group from a WS request. Guaranties the group id or the group name is provided, not both. */ -class WsGroupRef { +public class WsGroupRef { private final Long id; private final String name; @@ -43,7 +43,7 @@ class WsGroupRef { this.name = name; } - static WsGroupRef fromRequest(Request wsRequest) { + public static WsGroupRef fromRequest(Request wsRequest) { Long id = wsRequest.paramAsLong(PARAM_GROUP_ID); String name = wsRequest.param(PARAM_GROUP_NAME); @@ -51,12 +51,12 @@ class WsGroupRef { } @CheckForNull - Long id() { + public Long id() { return this.id; } @CheckForNull - String name() { + public String name() { return this.name; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsPermissionParameters.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsPermissionParameters.java index 274c2c2991b..41f8aeefe30 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsPermissionParameters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsPermissionParameters.java @@ -27,23 +27,23 @@ import org.sonar.core.util.Uuids; import static java.lang.String.format; -class WsPermissionParameters { +public class WsPermissionParameters { - static final String PARAM_PERMISSION = "permission"; - static final String PARAM_GROUP_NAME = "groupName"; - static final String PARAM_GROUP_ID = "groupId"; - static final String PARAM_PROJECT_ID = "projectId"; - static final String PARAM_PROJECT_KEY = "projectKey"; - static final String PARAM_USER_LOGIN = "login"; - static final String PARAM_TEMPLATE_ID = "templateId"; - static final String PARAM_TEMPLATE_NAME = "templateName"; + public static final String PARAM_PERMISSION = "permission"; + public static final String PARAM_GROUP_NAME = "groupName"; + public static final String PARAM_GROUP_ID = "groupId"; + public static final String PARAM_PROJECT_ID = "projectId"; + public static final String PARAM_PROJECT_KEY = "projectKey"; + public static final String PARAM_USER_LOGIN = "login"; + public static final String PARAM_TEMPLATE_ID = "templateId"; + public static final String PARAM_TEMPLATE_NAME = "templateName"; - static final String PARAM_ID = "id"; - static final String PARAM_NAME = "name"; - static final String PARAM_DESCRIPTION = "description"; - static final String PARAM_PATTERN = "projectKeyPattern"; + public static final String PARAM_ID = "id"; + public static final String PARAM_NAME = "name"; + public static final String PARAM_DESCRIPTION = "description"; + public static final String PARAM_PATTERN = "projectKeyPattern"; - static final String PARAM_QUALIFIER = "qualifier"; + public static final String PARAM_QUALIFIER = "qualifier"; private static final String PERMISSION_PARAM_DESCRIPTION = format("Permission" + "
    " + @@ -62,31 +62,31 @@ class WsPermissionParameters { // static methods only } - static void createPermissionParameter(NewAction action) { + public static void createPermissionParameter(NewAction action) { action.createParam(PARAM_PERMISSION) .setDescription(PERMISSION_PARAM_DESCRIPTION) .setRequired(true); } - static void createProjectPermissionParameter(NewAction action) { + public static void createProjectPermissionParameter(NewAction action) { action.createParam(PARAM_PERMISSION) .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION) .setRequired(true); } - static void createGroupNameParameter(NewAction action) { + public static void createGroupNameParameter(NewAction action) { action.createParam(PARAM_GROUP_NAME) .setDescription("Group name or 'anyone' (case insensitive)") .setExampleValue("sonar-administrators"); } - static void createGroupIdParameter(NewAction action) { + public static void createGroupIdParameter(NewAction action) { action.createParam(PARAM_GROUP_ID) .setDescription("Group id") .setExampleValue("42"); } - static void createProjectParameter(NewAction action) { + public static void createProjectParameter(NewAction action) { createProjectIdParameter(action); createProjectKeyParameter(action); } @@ -103,14 +103,14 @@ class WsPermissionParameters { .setExampleValue("org.apache.hbas:hbase"); } - static void createUserLoginParameter(NewAction action) { + public static void createUserLoginParameter(NewAction action) { action.createParam(PARAM_USER_LOGIN) .setRequired(true) .setDescription("User login") .setExampleValue("g.hopper"); } - static void createTemplateParameters(NewAction action) { + public static void createTemplateParameters(NewAction action) { createTemplateIdParameter(action); createTemplateNameParameter(action); } @@ -127,19 +127,19 @@ class WsPermissionParameters { .setExampleValue("Default Permission Template for Projects"); } - static void createTemplateProjectKeyPatternParameter(NewAction action) { + public static void createTemplateProjectKeyPatternParameter(NewAction action) { action.createParam(PARAM_PATTERN) .setDescription("Project key pattern. Must be a valid Java regular expression") .setExampleValue(".*\\.finance\\..*"); } - static void createTemplateDescriptionParameter(NewAction action) { + public static void createTemplateDescriptionParameter(NewAction action) { action.createParam(PARAM_DESCRIPTION) .setDescription("Description") .setExampleValue("Permissions for all projects related to the financial service"); } - static void createIdParameter(NewAction action) { + public static void createIdParameter(NewAction action) { action.createParam(PARAM_ID) .setRequired(true) .setDescription("Id") diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java index feda183aba9..9e1f6989edc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java @@ -31,7 +31,7 @@ import static org.sonar.server.ws.WsUtils.checkRequest; /** * Project identifiers from a WS request. Guaranties the project id and project key are not provided at the same time. */ -class WsProjectRef { +public class WsProjectRef { private final String uuid; private final String key; @@ -41,7 +41,7 @@ class WsProjectRef { checkRequest(uuid != null ^ key != null, "Project id or project key can be provided, not both."); } - static Optional optionalFromRequest(Request wsRequest) { + public static Optional optionalFromRequest(Request wsRequest) { if (!hasProjectParam(wsRequest)) { return Optional.absent(); } @@ -49,19 +49,19 @@ class WsProjectRef { return Optional.of(new WsProjectRef(wsRequest)); } - static WsProjectRef fromRequest(Request wsRequest) { + public static WsProjectRef fromRequest(Request wsRequest) { checkRequest(hasProjectParam(wsRequest), "Project id or project key must be provided, not both."); return new WsProjectRef(wsRequest); } @CheckForNull - String uuid() { + public String uuid() { return this.uuid; } @CheckForNull - String key() { + public String key() { return this.key; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java index 82377eea06d..aeb3f8c0140 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java @@ -31,7 +31,7 @@ import static org.sonar.server.ws.WsUtils.checkRequest; /** * Template from a WS request. Guaranties the template id or the template name is provided, not both. */ -class WsTemplateRef { +public class WsTemplateRef { private final String uuid; private final String name; @@ -43,24 +43,24 @@ class WsTemplateRef { this.name = name; } - static WsTemplateRef fromRequest(Request wsRequest) { + public static WsTemplateRef fromRequest(Request wsRequest) { String uuid = wsRequest.param(PARAM_TEMPLATE_ID); String name = wsRequest.param(PARAM_TEMPLATE_NAME); return new WsTemplateRef(uuid, name); } - static WsTemplateRef newTemplateRef(@Nullable String uuid, @Nullable String name) { + public static WsTemplateRef newTemplateRef(@Nullable String uuid, @Nullable String name) { return new WsTemplateRef(uuid, name); } @CheckForNull - String uuid() { + public String uuid() { return this.uuid; } @CheckForNull - String name() { + public String name() { return this.name; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupToTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java similarity index 94% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupToTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java index 741b4dcf189..7b459b8cc1d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupToTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import javax.annotation.Nullable; import org.sonar.api.server.ws.Request; @@ -29,18 +29,22 @@ import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionQuery; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.db.user.GroupDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsGroupRef; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static org.sonar.api.security.DefaultGroups.ANYONE; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; +import static org.sonar.server.permission.ws.PermissionRequestValidator.validateNotAnyoneAndAdminPermission; +import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION; import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupIdParameter; import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupNameParameter; import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectPermissionParameter; import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters; -import static org.sonar.server.permission.ws.PermissionRequestValidator.validateNotAnyoneAndAdminPermission; -import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; public class AddGroupToTemplateAction implements PermissionsWsAction { private final DbClient dbClient; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserToTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java similarity index 95% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserToTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java index 16a2f53a0f9..c8658d3f088 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserToTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Predicate; import java.util.List; @@ -31,6 +31,9 @@ import org.sonar.db.permission.PermissionQuery; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.db.permission.UserWithPermissionDto; import org.sonar.db.user.UserDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static com.google.common.collect.FluentIterable.from; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ApplyTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java similarity index 91% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/ApplyTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java index 7556a66d110..ab97c359cc8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ApplyTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -29,6 +29,10 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.server.permission.ApplyPermissionTemplateQuery; import org.sonar.server.permission.PermissionService; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsProjectRef; +import org.sonar.server.permission.ws.WsTemplateRef; import static java.util.Collections.singletonList; import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/CreateTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java similarity index 94% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/CreateTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java index 69f2f6fbe18..2e949840264 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/CreateTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -27,6 +27,7 @@ import org.sonar.api.utils.System2; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; +import org.sonar.server.permission.ws.PermissionsWsAction; import org.sonar.server.user.UserSession; import org.sonarqube.ws.WsPermissions.PermissionTemplate; import org.sonarqube.ws.WsPermissions.WsCreatePermissionTemplateResponse; @@ -41,8 +42,8 @@ import static org.sonar.server.permission.ws.WsPermissionParameters.createTempla import static org.sonar.server.permission.ws.PermissionRequestValidator.MSG_TEMPLATE_WITH_SAME_NAME; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPattern; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateTemplateNameFormat; -import static org.sonar.server.permission.ws.PermissionTemplateDtoBuilder.create; -import static org.sonar.server.permission.ws.PermissionTemplateDtoToPermissionTemplateResponse.toPermissionTemplateResponse; +import static org.sonar.server.permission.ws.template.PermissionTemplateDtoBuilder.create; +import static org.sonar.server.permission.ws.template.PermissionTemplateDtoToPermissionTemplateResponse.toPermissionTemplateResponse; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinder.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinder.java similarity index 94% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinder.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinder.java index d1381b44be2..2ee49517dee 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinder.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import java.util.List; @@ -43,21 +43,21 @@ public class DefaultPermissionTemplateFinder { this.resourceTypes = resourceTypes; } - Set getDefaultTemplateUuids() { + public Set getDefaultTemplateUuids() { return from(resourceTypes.getRoots()) .transform(RESOURCE_TYPE_TO_QUALIFIER) .transform(new QualifierToDefaultTemplate(settings)) .toSortedSet(natural()); } - List getDefaultTemplatesByQualifier() { + public List getDefaultTemplatesByQualifier() { return from(resourceTypes.getRoots()) .transform(RESOURCE_TYPE_TO_QUALIFIER) .transform(new QualifierToTemplateUuidQualifier(settings)) .toList(); } - static class TemplateUuidQualifier { + public static class TemplateUuidQualifier { private final String templateUuid; private final String qualifier; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoBuilder.java similarity index 80% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoBuilder.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoBuilder.java index 55702eb799d..79e658da409 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoBuilder.java @@ -18,14 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Date; import org.sonar.api.utils.System2; import org.sonar.core.util.Uuids; import org.sonar.db.permission.PermissionTemplateDto; -class PermissionTemplateDtoBuilder { +public class PermissionTemplateDtoBuilder { private final System2 system; private String name; private String description; @@ -35,26 +35,26 @@ class PermissionTemplateDtoBuilder { this.system = system; } - static PermissionTemplateDtoBuilder create(System2 system) { + public static PermissionTemplateDtoBuilder create(System2 system) { return new PermissionTemplateDtoBuilder(system); } - PermissionTemplateDtoBuilder setName(String name) { + public PermissionTemplateDtoBuilder setName(String name) { this.name = name; return this; } - PermissionTemplateDtoBuilder setDescription(String description) { + public PermissionTemplateDtoBuilder setDescription(String description) { this.description = description; return this; } - PermissionTemplateDtoBuilder setProjectKeyPattern(String projectKeyPattern) { + public PermissionTemplateDtoBuilder setProjectKeyPattern(String projectKeyPattern) { this.projectKeyPattern = projectKeyPattern; return this; } - PermissionTemplateDto toDto() { + public PermissionTemplateDto toDto() { long now = system.now(); return new PermissionTemplateDto() .setName(name) diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoToPermissionTemplateResponse.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java similarity index 90% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoToPermissionTemplateResponse.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java index 1b9be42037c..28f77ac5563 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionTemplateDtoToPermissionTemplateResponse.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/PermissionTemplateDtoToPermissionTemplateResponse.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import javax.annotation.Nonnull; @@ -26,9 +26,9 @@ import org.sonar.api.utils.DateUtils; import org.sonar.db.permission.PermissionTemplateDto; import org.sonarqube.ws.WsPermissions.PermissionTemplate; -class PermissionTemplateDtoToPermissionTemplateResponse { +public class PermissionTemplateDtoToPermissionTemplateResponse { - static PermissionTemplate toPermissionTemplateResponse(PermissionTemplateDto dto) { + public static PermissionTemplate toPermissionTemplateResponse(PermissionTemplateDto dto) { return Singleton.INSTANCE.apply(dto); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java similarity index 93% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java index 36614093345..d86cd253b4e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -27,6 +27,10 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.db.user.GroupDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsGroupRef; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserFromTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java similarity index 94% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserFromTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java index dd22e79b2a2..a8147e40d7b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserFromTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -27,6 +27,9 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; import org.sonar.db.user.UserDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java similarity index 98% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java index 87abcb2ee08..81ac05f93a0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import org.sonar.api.i18n.I18n; import org.sonar.api.server.ws.Request; @@ -28,6 +28,7 @@ import org.sonar.core.permission.ProjectPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; +import org.sonar.server.permission.ws.PermissionsWsAction; import org.sonar.server.user.UserSession; import org.sonarqube.ws.WsPermissions.Permission; import org.sonarqube.ws.WsPermissions.PermissionTemplate; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesData.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesData.java similarity index 96% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesData.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesData.java index dac2868fca4..b328477e35c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesData.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; @@ -26,7 +26,7 @@ import com.google.common.collect.Table; import java.util.List; import java.util.Set; import org.sonar.db.permission.PermissionTemplateDto; -import org.sonar.server.permission.ws.DefaultPermissionTemplateFinder.TemplateUuidQualifier; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder.TemplateUuidQualifier; import static com.google.common.base.Objects.firstNonNull; import static com.google.common.base.Preconditions.checkState; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesDataLoader.java similarity index 95% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesDataLoader.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesDataLoader.java index 79a2984efdc..dd561143f2c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchTemplatesDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesDataLoader.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import com.google.common.collect.Lists; @@ -33,10 +33,10 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.CountByTemplateAndPermissionDto; import org.sonar.db.permission.PermissionTemplateDto; -import org.sonar.server.permission.ws.DefaultPermissionTemplateFinder.TemplateUuidQualifier; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder.TemplateUuidQualifier; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; -import static org.sonar.server.permission.ws.SearchTemplatesData.newBuilder; +import static org.sonar.server.permission.ws.template.SearchTemplatesData.newBuilder; public class SearchTemplatesDataLoader { private final DbClient dbClient; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SetDefaultTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java similarity index 95% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/SetDefaultTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java index 79a54ed1e78..d2ffbb4d671 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SetDefaultTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Set; import org.sonar.api.i18n.I18n; @@ -30,6 +30,9 @@ import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.platform.PersistentSettings; import org.sonar.server.user.UserSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UpdateTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java similarity index 94% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/UpdateTemplateAction.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java index d7ba4b5b0f5..8eaf61cb37a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UpdateTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Date; import javax.annotation.Nullable; @@ -29,6 +29,9 @@ import org.sonar.api.utils.System2; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.PermissionTemplateDto; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.PermissionsWsAction; +import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import org.sonarqube.ws.WsPermissions.PermissionTemplate; import org.sonarqube.ws.WsPermissions.WsUpdatePermissionTemplateResponse; @@ -46,7 +49,7 @@ import static org.sonar.server.permission.ws.WsPermissionParameters.createTempla import static org.sonar.server.permission.ws.PermissionRequestValidator.MSG_TEMPLATE_WITH_SAME_NAME; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPattern; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateTemplateNameFormat; -import static org.sonar.server.permission.ws.PermissionTemplateDtoToPermissionTemplateResponse.toPermissionTemplateResponse; +import static org.sonar.server.permission.ws.template.PermissionTemplateDtoToPermissionTemplateResponse.toPermissionTemplateResponse; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/package-info.java new file mode 100644 index 00000000000..a252c1b8247 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +@ParametersAreNonnullByDefault +package org.sonar.server.permission.ws.template; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/create_template-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/create_template-example.json similarity index 100% rename from server/sonar-server/src/main/resources/org/sonar/server/permission/ws/create_template-example.json rename to server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/create_template-example.json diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_templates-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json similarity index 100% rename from server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_templates-example.json rename to server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/update_template-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/update_template-example.json similarity index 100% rename from server/sonar-server/src/main/resources/org/sonar/server/permission/ws/update_template-example.json rename to server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/update_template-example.json diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupToTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupToTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java index d84111c2965..006c5521436 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupToTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import java.util.List; @@ -44,6 +44,8 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.WsPermissionParameters; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.WsActionTester; @@ -60,8 +62,8 @@ import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.GroupTesting.newGroupDto; import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID; import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID; import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION; +import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID; import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME; @Category(DbTests.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserToTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java similarity index 96% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserToTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java index 6a28cbda890..2ab68a4378e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserToTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import java.util.List; @@ -43,6 +43,9 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.WsPermissionParameters; +import org.sonar.server.permission.ws.template.AddUserToTemplateAction; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.WsActionTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/ApplyTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/ApplyTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java index 27f64b19f6e..d8554d9a6ad 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/ApplyTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; @@ -54,6 +54,8 @@ import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.issue.index.IssueAuthorizationIndexer; import org.sonar.server.permission.PermissionFinder; import org.sonar.server.permission.PermissionService; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.template.ApplyTemplateAction; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.TestResponse; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/CreateTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java similarity index 99% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/CreateTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java index 160aebb1afe..991600c8f54 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/CreateTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import javax.annotation.Nullable; import org.junit.Before; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinderTest.java similarity index 96% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinderTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinderTest.java index 5831af38b1f..2e8e6219703 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/DefaultPermissionTemplateFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DefaultPermissionTemplateFinderTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.List; import java.util.Set; @@ -28,6 +28,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.ResourceType; import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/DeleteTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java similarity index 96% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/DeleteTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java index 33575ba5b19..8515de5e20f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/DeleteTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Collections; import javax.annotation.Nullable; @@ -42,6 +42,9 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.DeleteTemplateAction; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.TestResponse; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java index 517a9885abe..e372afa7f9f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupFromTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import java.util.List; @@ -43,6 +43,8 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.WsPermissionParameters; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.WsActionTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserFromTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java similarity index 97% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserFromTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java index 7d71fdd1eb6..588e651dc84 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserFromTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import com.google.common.base.Function; import java.util.List; @@ -43,6 +43,9 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.WsPermissionParameters; +import org.sonar.server.permission.ws.template.RemoveUserFromTemplateAction; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.WsActionTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchTemplatesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java similarity index 99% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchTemplatesActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java index dcda8000a5e..230b5424443 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchTemplatesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Date; import java.util.List; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SetDefaultTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java similarity index 97% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/SetDefaultTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java index defa13e539c..6031f41268a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SetDefaultTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.List; import java.util.Properties; @@ -44,6 +44,8 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.i18n.I18nRule; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; +import org.sonar.server.permission.ws.template.SetDefaultTemplateAction; import org.sonar.server.platform.PersistentSettings; import org.sonar.server.platform.ServerSettings; import org.sonar.server.tester.UserSessionRule; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UpdateTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/permission/ws/UpdateTemplateActionTest.java rename to server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java index 82d2404779c..515fa91123d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UpdateTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.permission.ws; +package org.sonar.server.permission.ws.template; import java.util.Date; import javax.annotation.Nullable; @@ -38,6 +38,7 @@ import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; +import org.sonar.server.permission.ws.PermissionDependenciesFinder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; import org.sonar.server.ws.TestResponse; diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchTemplatesActionTest/empty.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json similarity index 100% rename from server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchTemplatesActionTest/empty.json rename to server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json -- 2.39.5