]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7744 Permission information in WS use Locale.ENGLISH
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 15 Sep 2016 15:34:16 +0000 (17:34 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 16 Sep 2016 15:08:12 +0000 (17:08 +0200)
server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchGlobalPermissionsAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java

index 1dc976c276843c6f57dc3f88e84b15e425dc06bd..077bfb5fda4ba5b7922fe420ce0ce1a0b003252a 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.permission.ws;
 
+import java.util.Locale;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -26,8 +27,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
-import org.sonar.db.permission.OldPermissionQuery;
-import org.sonar.db.user.GroupMembershipQuery;
+import org.sonar.db.permission.PermissionQuery;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.WsPermissions.Permission;
 import org.sonarqube.ws.WsPermissions.WsSearchGlobalPermissionsResponse;
@@ -78,7 +78,7 @@ public class SearchGlobalPermissionsAction implements PermissionsWsAction {
     Permission.Builder permission = newBuilder();
 
     for (String permissionKey : GlobalPermissions.ALL) {
-      OldPermissionQuery permissionQuery = permissionQuery(permissionKey);
+      PermissionQuery permissionQuery = permissionQuery(permissionKey);
 
       response.addPermissions(
         permission
@@ -95,25 +95,25 @@ public class SearchGlobalPermissionsAction implements PermissionsWsAction {
   }
 
   private String i18nDescriptionMessage(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
   }
 
   private String i18nName(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey, permissionKey);
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey, permissionKey);
   }
 
   private int countGroups(DbSession dbSession, String permissionKey) {
     return dbClient.permissionDao().countGroups(dbSession, permissionKey, null);
   }
 
-  private int countUsers(DbSession dbSession, OldPermissionQuery permissionQuery) {
-    return dbClient.permissionDao().countUsers(dbSession, permissionQuery, null);
+  private int countUsers(DbSession dbSession, PermissionQuery permissionQuery) {
+    return dbClient.permissionDao().countUsersByQuery(dbSession, permissionQuery);
   }
 
-  private static OldPermissionQuery permissionQuery(String permissionKey) {
-    return OldPermissionQuery.builder()
-      .permission(permissionKey)
-      .membership(GroupMembershipQuery.IN)
+  private static PermissionQuery permissionQuery(String permissionKey) {
+    return PermissionQuery.builder()
+      .setPermission(permissionKey)
+      .withPermissionOnly()
       .build();
   }
 }
index 16f874738e614f4a78ccc5f5c414112098ea43e4..67fdf06fbb107de90816ed5d9e41ac931c5f3229 100644 (file)
  */
 package org.sonar.server.permission.ws;
 
-import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
-import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentKey;
-import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentUuid;
-import static org.sonar.server.permission.ws.PermissionRequestValidator.validateQualifier;
-import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameters;
-import static org.sonar.server.permission.ws.WsProjectRef.newOptionalWsProjectRef;
-import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
-import static org.sonar.server.ws.WsParameterBuilder.createRootQualifierParameter;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER;
-
 import com.google.common.base.Optional;
+import java.util.Locale;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.server.ws.Request;
@@ -51,6 +39,19 @@ import org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse;
 import org.sonarqube.ws.WsPermissions.SearchProjectPermissionsWsResponse.Project;
 import org.sonarqube.ws.client.permission.SearchProjectPermissionsWsRequest;
 
+import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
+import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentKey;
+import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentUuid;
+import static org.sonar.server.permission.ws.PermissionRequestValidator.validateQualifier;
+import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameters;
+import static org.sonar.server.permission.ws.WsProjectRef.newOptionalWsProjectRef;
+import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
+import static org.sonar.server.ws.WsParameterBuilder.createRootQualifierParameter;
+import static org.sonar.server.ws.WsUtils.writeProtobuf;
+import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID;
+import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY;
+import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER;
+
 public class SearchProjectPermissionsAction implements PermissionsWsAction {
   private static final String PROPERTY_PREFIX = "projects_role.";
   private static final String DESCRIPTION_SUFFIX = ".desc";
@@ -176,10 +177,10 @@ public class SearchProjectPermissionsAction implements PermissionsWsAction {
   }
 
   private String i18nDescriptionMessage(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
   }
 
   private String i18nName(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey, permissionKey);
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey, permissionKey);
   }
 }
index 021bfe1d234a39d677efdf0ca9d03063d8ed2302..afbd5f4273cff7ecfb81355c7f3fe6984d67662f 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.permission.ws.template;
 
+import java.util.Locale;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -152,10 +153,10 @@ public class SearchTemplatesAction implements PermissionsWsAction {
   }
 
   private String i18nDescriptionMessage(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
   }
 
   private String i18nName(String permissionKey) {
-    return i18n.message(userSession.locale(), PROPERTY_PREFIX + permissionKey, permissionKey);
+    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey, permissionKey);
   }
 }