diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-10-15 10:18:04 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-10-15 10:27:10 +0200 |
commit | 3aca3b8c7f87e803bb992d4d993d0ab2c29cee2a (patch) | |
tree | 6dc43b0387f05a640740f4bc7677278399e2f474 | |
parent | cd5a7728f5b4f5059fec3feb2d4ee1b90da315ba (diff) | |
download | sonarqube-3aca3b8c7f87e803bb992d4d993d0ab2c29cee2a.tar.gz sonarqube-3aca3b8c7f87e803bb992d4d993d0ab2c29cee2a.zip |
SONAR-3871 Remove references to scope in provisioning WS and internal service
6 files changed, 12 insertions, 23 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java index 3b72f1265e9..2ff89f43939 100644 --- a/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java +++ b/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java @@ -23,6 +23,7 @@ import com.google.common.base.Strings; import org.sonar.api.component.Component; import org.sonar.api.component.RubyComponentService; import org.sonar.api.i18n.I18n; +import org.sonar.api.resources.Scopes; import org.sonar.core.component.ComponentDto; import org.sonar.core.component.ComponentKeys; import org.sonar.core.resource.ResourceDao; @@ -52,11 +53,11 @@ public class DefaultRubyComponentService implements RubyComponentService { } @Override - public Component findByKey(String key) { + public Component<?> findByKey(String key) { return resourceDao.findByKey(key); } - public void createComponent(String kee, String name, String scope, String qualifier) { + public void createComponent(String kee, String name, String qualifier) { ComponentDto component = (ComponentDto)resourceDao.findByKey(kee); if (component != null) { throw new BadRequestException(formatMessage("Could not create %s, key already exists: %s", qualifier, kee)); @@ -68,7 +69,7 @@ public class DefaultRubyComponentService implements RubyComponentService { .setKey(kee) .setName(name) .setLongName(name) - .setScope(scope) + .setScope(Scopes.PROJECT) .setQualifier(qualifier) .setCreatedAt(new Date())); component = (ComponentDto)resourceDao.findByKey(kee); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb index c9d940bf70e..c36fa2f1f83 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb @@ -82,7 +82,7 @@ class Api::ProjectsController < Api::ApiController key = params[:key] name = params[:name] - Internal.component_api.createComponent(key, name, 'PRJ', 'TRK') + Internal.component_api.createComponent(key, name, 'TRK') Internal.permissions.applyDefaultPermissionTemplate(key) result = Project.by_key(key) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb index b7dd96e8f23..e6b9c2a4ec3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/provisioning_controller.rb @@ -43,7 +43,7 @@ class ProvisioningController < ApplicationController bad_request('provisioning.missing.name') if @name.blank? if @id.nil? or @id.empty? - Internal.component_api.createComponent(@key, @name, 'PRJ', 'TRK') + Internal.component_api.createComponent(@key, @name, 'TRK') Internal.permissions.applyDefaultPermissionTemplate(@key) else Internal.component_api.updateComponent(@id.to_i, @key, @name) diff --git a/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java b/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java index 022e922af68..23930301646 100644 --- a/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java @@ -76,14 +76,13 @@ public class DefaultRubyComponentServiceTest { public void should_create_component_and_index_it() { String componentKey = "new-project"; String componentName = "New Project"; - String scope = Scopes.PROJECT; String qualifier = Qualifiers.PROJECT; long componentId = Long.MAX_VALUE; ComponentDto component = mock(ComponentDto.class); when(component.getId()).thenReturn(componentId); when(resourceDao.findByKey(componentKey)).thenReturn(null).thenReturn(component); - componentService.createComponent(componentKey, componentName, scope, qualifier); + componentService.createComponent(componentKey, componentName, qualifier); ArgumentCaptor<ResourceDto> resourceCaptor = ArgumentCaptor.forClass(ResourceDto.class); verify(resourceDao).insertOrUpdate(resourceCaptor.capture()); @@ -91,7 +90,7 @@ public class DefaultRubyComponentServiceTest { assertThat(created.getKey()).isEqualTo(componentKey); assertThat(created.getName()).isEqualTo(componentName); assertThat(created.getLongName()).isEqualTo(componentName); - assertThat(created.getScope()).isEqualTo(scope); + assertThat(created.getScope()).isEqualTo(Scopes.PROJECT); assertThat(created.getQualifier()).isEqualTo(qualifier); verify(resourceDao, times(2)).findByKey(componentKey); verify(resourceIndexerDao).indexResource(componentId); @@ -101,27 +100,25 @@ public class DefaultRubyComponentServiceTest { public void should_thow_if_create_fails() { String componentKey = "new-project"; String componentName = "New Project"; - String scope = Scopes.PROJECT; String qualifier = Qualifiers.PROJECT; when(resourceDao.findByKey(componentKey)).thenReturn(null); - componentService.createComponent(componentKey, componentName, scope, qualifier); + componentService.createComponent(componentKey, componentName, qualifier); } @Test(expected = BadRequestException.class) public void should_throw_if_component_already_exists() { String componentKey = "new-project"; String componentName = "New Project"; - String scope = Scopes.PROJECT; String qualifier = Qualifiers.PROJECT; when(resourceDao.findByKey(componentKey)).thenReturn(mock(ComponentDto.class)); - componentService.createComponent(componentKey, componentName, scope, qualifier); + componentService.createComponent(componentKey, componentName, qualifier); } @Test(expected = BadRequestException.class) public void should_throw_if_malformed_key1() { - componentService.createComponent("1234", "New Project", Scopes.PROJECT, Qualifiers.PROJECT); + componentService.createComponent("1234", "New Project", Qualifiers.PROJECT); } @Test(expected = NotFoundException.class) diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java index 4020ebcb895..fe09fd00c15 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java @@ -30,8 +30,6 @@ public interface Project { String name(); - String scope(); - String qualifier(); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java index f287c307ad2..e63ac4b73c8 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java @@ -19,9 +19,8 @@ */ package org.sonar.wsclient.project.internal; -import org.sonar.wsclient.unmarshallers.JsonUtils; - import org.sonar.wsclient.project.Project; +import org.sonar.wsclient.unmarshallers.JsonUtils; import java.util.Map; @@ -52,14 +51,8 @@ public class DefaultProject implements Project { } @Override - public String scope() { - return JsonUtils.getString(json, "sc"); - } - - @Override public String qualifier() { return JsonUtils.getString(json, "qu"); } - } |