]> source.dussan.org Git - sonarqube.git/commitdiff
Use WsProjectRef instead of Request to get a project
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 2 Sep 2015 08:47:08 +0000 (10:47 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 2 Sep 2015 14:36:20 +0000 (16:36 +0200)
server/sonar-server/src/main/java/org/sonar/server/permission/ws/ApplyTemplateAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionDependenciesFinder.java

index d449c7d416ea6e1e541f309182ba5538408eddf8..ef3039d7f6113f161534943df4ecfe591856e9d6 100644 (file)
@@ -32,8 +32,8 @@ import org.sonar.server.permission.PermissionService;
 
 import static java.util.Collections.singletonList;
 import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID_EXPLICIT;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
 import static org.sonar.server.permission.ws.Parameters.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
 
 public class ApplyTemplateAction implements PermissionsWsAction {
   private final DbClient dbClient;
@@ -67,7 +67,7 @@ public class ApplyTemplateAction implements PermissionsWsAction {
     DbSession dbSession = dbClient.openSession(false);
     try {
       PermissionTemplateDto template = finder.getTemplate(dbSession, templateUuid);
-      ComponentDto project = finder.getProject(dbSession, wsRequest);
+      ComponentDto project = finder.getProject(dbSession, WsProjectRef.fromRequest(wsRequest));
 
       ApplyPermissionTemplateQuery query = ApplyPermissionTemplateQuery.create(
         template.getUuid(),
index 0fee0e3125809ce8558579a694f6ee2bd5d3660b..5faf1d2dbeff1d774bb629cb8529213bf6cebb1e 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.permission.ws;
 
 import com.google.common.base.Optional;
 import javax.annotation.CheckForNull;
-import org.sonar.api.server.ws.Request;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
@@ -57,9 +56,7 @@ public class PermissionDependenciesFinder {
     return Optional.of(componentFinder.getProjectByUuidOrKey(dbSession, wsProjectRef.uuid(), wsProjectRef.key()));
   }
 
-  public ComponentDto getProject(DbSession dbSession, Request wsRequest) {
-    WsProjectRef projectRef = WsProjectRef.fromRequest(wsRequest);
-
+  public ComponentDto getProject(DbSession dbSession, WsProjectRef projectRef) {
     return componentFinder.getProjectByUuidOrKey(dbSession, projectRef.uuid(), projectRef.key());
   }