aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-29 14:49:50 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-29 15:59:53 +0100
commit4059a10684683984006ea33c68473f7a9d57063f (patch)
treecceb0c80068f34de6cd6d59d314bddf1d965f565
parent527be82b07ecdca9eebaf0f97eb8bfa85616c379 (diff)
downloadsonarqube-4059a10684683984006ea33c68473f7a9d57063f.tar.gz
sonarqube-4059a10684683984006ea33c68473f7a9d57063f.zip
SONAR-5530 Remove AuthorizedComponentDto now useless with project uuid
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java27
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportQueue.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java11
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java54
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/DbCleanerStepTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java38
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java121
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java98
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/computation/db/AnalysisReportDto.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml21
20 files changed, 129 insertions, 320 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
index 6988fda03b5..847393b0ec2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsAction.java
@@ -30,7 +30,6 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.batch.protocol.input.ProjectReferentials;
import org.sonar.core.UtcDateUtils;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.DbSession;
@@ -119,7 +118,7 @@ public class ProjectReferentialsAction implements RequestHandler {
String profileName = request.param(PARAM_PROFILE);
String projectKey = null;
- AuthorizedComponentDto module = dbClient.componentDao().getNullableAuthorizedComponentByKey(projectOrModuleKey, session);
+ ComponentDto module = dbClient.componentDao().getNullableByKey(session, projectOrModuleKey);
// Current project can be null when analysing a new project
if (module != null) {
ComponentDto project = dbClient.componentDao().getNullableRootProjectByKey(projectOrModuleKey, session);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
index b37ea614293..3ae4301d7fa 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentCleanerService.java
@@ -22,7 +22,7 @@ package org.sonar.server.component;
import org.sonar.api.ServerComponent;
import org.sonar.api.resources.Scopes;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.purge.PurgeDao;
import org.sonar.server.db.DbClient;
@@ -40,7 +40,7 @@ public class ComponentCleanerService implements ServerComponent {
public void delete(String projectKey) {
DbSession session = dbClient.openSession(false);
try {
- AuthorizedComponentDto project = dbClient.componentDao().getAuthorizedComponentByKey(projectKey, session);
+ ComponentDto project = dbClient.componentDao().getByKey(session, projectKey);
if (!Scopes.PROJECT.equals(project.scope())) {
throw new IllegalArgumentException("Only project can be deleted");
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
index 225a41c9c37..b8c8f269394 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
@@ -22,7 +22,6 @@ package org.sonar.server.component;
import org.sonar.api.ServerComponent;
import org.sonar.api.web.UserRole;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.preview.PreviewCache;
@@ -47,20 +46,20 @@ public class ComponentService implements ServerComponent {
this.previewCache = previewCache;
}
- public AuthorizedComponentDto getByKey(String key) {
+ public ComponentDto getByKey(String key) {
DbSession session = dbClient.openSession(false);
try {
- return dbClient.componentDao().getAuthorizedComponentByKey(key, session);
+ return dbClient.componentDao().getByKey(session, key);
} finally {
session.close();
}
}
@CheckForNull
- public AuthorizedComponentDto getNullableByKey(String key) {
+ public ComponentDto getNullableByKey(String key) {
DbSession session = dbClient.openSession(false);
try {
- return dbClient.componentDao().getNullableAuthorizedComponentByKey(key, session);
+ return dbClient.componentDao().getNullableByKey(session, key);
} finally {
session.close();
}
@@ -90,7 +89,7 @@ public class ComponentService implements ServerComponent {
DbSession session = dbClient.openSession(false);
try {
- AuthorizedComponentDto projectOrModule = getByKey(projectOrModuleKey);
+ ComponentDto projectOrModule = getByKey(projectOrModuleKey);
resourceKeyUpdaterDao.updateKey(projectOrModule.getId(), newKey);
session.commit();
@@ -106,7 +105,7 @@ public class ComponentService implements ServerComponent {
UserSession.get().checkProjectPermission(UserRole.ADMIN, projectKey);
DbSession session = dbClient.openSession(false);
try {
- AuthorizedComponentDto project = getByKey(projectKey);
+ ComponentDto project = getByKey(projectKey);
return resourceKeyUpdaterDao.checkModuleKeysBeforeRenaming(project.getId(), stringToReplace, replacementString);
} finally {
session.close();
@@ -118,12 +117,12 @@ public class ComponentService implements ServerComponent {
DbSession session = dbClient.openSession(false);
try {
- AuthorizedComponentDto project = getByKey(projectKey);
+ ComponentDto project = getByKey(projectKey);
resourceKeyUpdaterDao.bulkUpdateKey(project.getId(), stringToReplace, replacementString);
session.commit();
- AuthorizedComponentDto newProject = dbClient.componentDao().getAuthorizedComponentById(project.getId(), session);
+ ComponentDto newProject = dbClient.componentDao().getById(project.getId(), session);
previewCache.reportResourceModification(newProject.key());
session.commit();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java b/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java
index 8403037ada4..37e19057d60 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java
@@ -22,7 +22,6 @@ package org.sonar.server.component.db;
import com.google.common.collect.Lists;
import org.sonar.api.ServerComponent;
import org.sonar.api.utils.System2;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.db.ComponentMapper;
import org.sonar.core.persistence.DaoComponent;
@@ -128,32 +127,6 @@ public class ComponentDao extends BaseDao<ComponentMapper, ComponentDto, String>
return mapper(session).findByKeys(keys);
}
- @CheckForNull
- public AuthorizedComponentDto getNullableAuthorizedComponentById(Long id, DbSession session) {
- return mapper(session).selectAuthorizedComponentById(id);
- }
-
- public AuthorizedComponentDto getAuthorizedComponentById(Long id, DbSession session) {
- AuthorizedComponentDto componentDto = getNullableAuthorizedComponentById(id, session);
- if (componentDto == null) {
- throw new NotFoundException(String.format("Project with id '%s' not found", id));
- }
- return componentDto;
- }
-
- @CheckForNull
- public AuthorizedComponentDto getNullableAuthorizedComponentByKey(String key, DbSession session) {
- return mapper(session).selectAuthorizedComponentByKey(key);
- }
-
- public AuthorizedComponentDto getAuthorizedComponentByKey(String key, DbSession session) {
- AuthorizedComponentDto componentDto = getNullableAuthorizedComponentByKey(key, session);
- if (componentDto == null) {
- throw new NotFoundException(String.format("Project with key '%s' not found", key));
- }
- return componentDto;
- }
-
@Override
@CheckForNull
protected ComponentDto doGetNullableByKey(DbSession session, String key) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportQueue.java b/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportQueue.java
index 2f2f78a39ee..77593ec52f9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportQueue.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportQueue.java
@@ -73,7 +73,7 @@ public class AnalysisReportQueue implements ServerComponent {
}
private void checkThatProjectExistsInDatabase(String projectKey, DbSession session) {
- dbClient.componentDao().getAuthorizedComponentByKey(projectKey, session);
+ dbClient.componentDao().getByKey(session, projectKey);
}
private AnalysisReportDto insertInDatabase(AnalysisReportDto reportTemplate, DbSession session) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java b/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java
index eda3b0b66af..378cc130935 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.ServerComponent;
import org.sonar.api.security.DefaultGroups;
import org.sonar.api.web.UserRole;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.permission.PermissionFacade;
import org.sonar.core.persistence.DbSession;
@@ -108,7 +108,7 @@ public class InternalPermissionService implements ServerComponent {
DbSession session = dbClient.openSession(false);
try {
- AuthorizedComponentDto component = dbClient.componentDao().getAuthorizedComponentByKey(componentKey, session);
+ ComponentDto component = dbClient.componentDao().getByKey(session, componentKey);
ResourceDto provisioned = resourceDao.selectProvisionedProject(session, componentKey);
if (provisioned == null) {
checkProjectAdminPermission(componentKey);
@@ -123,7 +123,7 @@ public class InternalPermissionService implements ServerComponent {
}
}
- public void applyDefaultPermissionTemplate(DbSession session, AuthorizedComponentDto component) {
+ public void applyDefaultPermissionTemplate(DbSession session, ComponentDto component) {
permissionFacade.grantDefaultRoles(session, component.getId(), component.qualifier());
synchronizePermissions(session, component.key());
}
@@ -147,7 +147,7 @@ public class InternalPermissionService implements ServerComponent {
}
for (String componentKey : query.getSelectedComponents()) {
- AuthorizedComponentDto component = dbClient.componentDao().getAuthorizedComponentByKey(componentKey, session);
+ ComponentDto component = dbClient.componentDao().getByKey(session, componentKey);
permissionFacade.applyPermissionTemplate(session, query.getTemplateKey(), component.getId());
synchronizePermissions(session, component.uuid());
}
@@ -176,7 +176,7 @@ public class InternalPermissionService implements ServerComponent {
if (changed) {
String project = permissionChangeQuery.component();
if (project != null) {
- synchronizePermissions(session, dbClient.componentDao().getAuthorizedComponentByKey(project, session).uuid());
+ synchronizePermissions(session, dbClient.componentDao().getByKey(session, project).uuid());
}
session.commit();
}
@@ -253,7 +253,7 @@ public class InternalPermissionService implements ServerComponent {
if (componentKey == null) {
return null;
} else {
- AuthorizedComponentDto component = dbClient.componentDao().getAuthorizedComponentByKey(componentKey, session);
+ ComponentDto component = dbClient.componentDao().getByKey(session, componentKey);
return component.getId();
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
index 871ba293139..5abcc46a1f3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
@@ -30,7 +30,7 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metric.ValueType;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.web.UserRole;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
@@ -360,7 +360,7 @@ public class QualityGates {
}
private void checkPermission(UserSession userSession, Long projectId, DbSession session) {
- AuthorizedComponentDto project = componentDao.getAuthorizedComponentById(projectId, session);
+ ComponentDto project = componentDao.getById(projectId, session);
if (!userSession.hasGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN) && !userSession.hasProjectPermission(UserRole.ADMIN, project.key())) {
throw new ForbiddenException("Insufficient privileges");
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
index 2d5724b9383..c1c122c65a0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
@@ -22,7 +22,7 @@ package org.sonar.server.qualityprofile;
import org.sonar.api.ServerComponent;
import org.sonar.api.web.UserRole;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
@@ -55,7 +55,7 @@ public class QProfileProjectOperations implements ServerComponent {
}
void addProject(int profileId, long projectId, UserSession userSession, DbSession session) {
- AuthorizedComponentDto project = db.componentDao().getAuthorizedComponentById(projectId, session);
+ ComponentDto project = db.componentDao().getById(projectId, session);
checkPermission(userSession, project.key());
QualityProfileDto qualityProfile = findNotNull(profileId, session);
@@ -67,7 +67,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void removeProject(int profileId, long projectId, UserSession userSession) {
DbSession session = db.openSession(false);
try {
- AuthorizedComponentDto project = db.componentDao().getAuthorizedComponentById(projectId, session);
+ ComponentDto project = db.componentDao().getById(projectId, session);
checkPermission(userSession, project.key());
QualityProfileDto qualityProfile = findNotNull(profileId, session);
@@ -81,7 +81,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void removeProject(String language, long projectId, UserSession userSession) {
DbSession session = db.openSession(false);
try {
- AuthorizedComponentDto project = db.componentDao().getAuthorizedComponentById(projectId, session);
+ ComponentDto project = db.componentDao().getById(projectId, session);
checkPermission(userSession, project.key());
db.propertiesDao().deleteProjectProperty(QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + language, project.getId(), session);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
index 14185becbdf..7604621f580 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java
@@ -99,9 +99,9 @@ public class ProjectReferentialsActionTest {
module = new ComponentDto().setKey("org.codehaus.sonar:sonar-server").setQualifier(Qualifiers.MODULE);
subModule = new ComponentDto().setKey("org.codehaus.sonar:sonar-server-dao").setQualifier(Qualifiers.MODULE);
- when(componentDao.getNullableAuthorizedComponentByKey(project.key(), session)).thenReturn(project);
- when(componentDao.getNullableAuthorizedComponentByKey(module.key(), session)).thenReturn(module);
- when(componentDao.getNullableAuthorizedComponentByKey(subModule.key(), session)).thenReturn(subModule);
+ when(componentDao.getNullableByKey(session, project.key())).thenReturn(project);
+ when(componentDao.getNullableByKey(session, module.key())).thenReturn(module);
+ when(componentDao.getNullableByKey(session, subModule.key())).thenReturn(subModule);
when(language.getKey()).thenReturn("java");
when(languages.all()).thenReturn(new Language[] {language});
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java
index 6bbbeec965e..9fabffcd74b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentServiceMediumTest.java
@@ -32,7 +32,6 @@ import org.sonar.core.permission.PermissionFacade;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.rule.RuleDto;
import org.sonar.server.component.db.ComponentDao;
-import org.sonar.server.component.db.SnapshotDao;
import org.sonar.server.db.DbClient;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.issue.IssueTesting;
@@ -70,7 +69,6 @@ public class ComponentServiceMediumTest {
project = ComponentTesting.newProjectDto().setKey("sample:root");
tester.get(ComponentDao.class).insert(session, project);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForProject(project));
// project can be seen by anyone
tester.get(PermissionFacade.class).insertGroupPermission(project.getId(), DefaultGroups.ANYONE, UserRole.USER, session);
@@ -113,7 +111,6 @@ public class ComponentServiceMediumTest {
public void update_project_key() throws Exception {
ComponentDto file = ComponentTesting.newFileDto(project).setKey("sample:root:src/File.xoo");
tester.get(ComponentDao.class).insert(session, file);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, project));
IssueDto issue = IssueTesting.newDto(rule, file, project);
db.issueDao().insert(session, issue);
@@ -153,11 +150,9 @@ public class ComponentServiceMediumTest {
public void update_module_key() throws Exception {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
tester.get(ComponentDao.class).insert(session, module);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(module, project));
ComponentDto file = ComponentTesting.newFileDto(module).setKey("sample:root:module:src/File.xoo");
tester.get(ComponentDao.class).insert(session, file);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, project));
IssueDto issue = IssueTesting.newDto(rule, file, project);
db.issueDao().insert(session, issue);
@@ -219,11 +214,9 @@ public class ComponentServiceMediumTest {
public void check_module_keys_before_renaming() throws Exception {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
tester.get(ComponentDao.class).insert(session, module);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(module, project));
ComponentDto file = ComponentTesting.newFileDto(module).setKey("sample:root:module:src/File.xoo");
tester.get(ComponentDao.class).insert(session, file);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, project));
session.commit();
@@ -239,11 +232,9 @@ public class ComponentServiceMediumTest {
public void check_module_keys_before_renaming_return_duplicate_key() throws Exception {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
tester.get(ComponentDao.class).insert(session, module);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(module, project));
ComponentDto module2 = ComponentTesting.newModuleDto(project).setKey("foo:module");
tester.get(ComponentDao.class).insert(session, module2);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(module2, project));
session.commit();
@@ -265,11 +256,9 @@ public class ComponentServiceMediumTest {
public void bulk_update_project_key() throws Exception {
ComponentDto module = ComponentTesting.newModuleDto(project).setKey("sample:root:module");
tester.get(ComponentDao.class).insert(session, module);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(module, project));
ComponentDto file = ComponentTesting.newFileDto(module).setKey("sample:root:module:src/File.xoo");
tester.get(ComponentDao.class).insert(session, file);
- tester.get(SnapshotDao.class).insert(session, SnapshotTesting.createForComponent(file, project));
IssueDto issue = IssueTesting.newDto(rule, file, project);
db.issueDao().insert(session, issue);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java
index 8e9317c41af..f528bba8f5a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java
@@ -25,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.AbstractDaoTestCase;
import org.sonar.core.persistence.DbSession;
@@ -331,59 +330,6 @@ public class ComponentDaoTest extends AbstractDaoTestCase {
}
@Test
- public void get_nullable_authorized_component_by_id() {
- setupData("shared");
-
- AuthorizedComponentDto result = dao.getNullableAuthorizedComponentById(4L, session);
- assertThat(result).isNotNull();
- assertThat(result.getId()).isEqualTo(4);
- assertThat(result.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
- assertThat(result.qualifier()).isEqualTo("FIL");
- assertThat(result.scope()).isEqualTo("FIL");
-
- assertThat(dao.getNullableAuthorizedComponentById(111L, session)).isNull();
- }
-
- @Test
- public void get_authorized_component_by_id() {
- setupData("shared");
-
- assertThat(dao.getAuthorizedComponentById(4L, session)).isNotNull();
- }
-
- @Test(expected = NotFoundException.class)
- public void fail_to_get_authorized_component_by_id_when_project_not_found() {
- setupData("shared");
-
- dao.getAuthorizedComponentById(111L, session);
- }
-
- @Test
- public void get_nullable_authorized_component_by_key() {
- setupData("shared");
-
- AuthorizedComponentDto result = dao.getNullableAuthorizedComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java", session);
- assertThat(result).isNotNull();
- assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
-
- assertThat(dao.getNullableAuthorizedComponentByKey("unknown", session)).isNull();
- }
-
- @Test
- public void get_authorized_component_by_key() {
- setupData("shared");
-
- assertThat(dao.getAuthorizedComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java", session)).isNotNull();
- }
-
- @Test(expected = NotFoundException.class)
- public void fail_to_get_authorized_component_by_key_when_project_not_found() {
- setupData("shared");
-
- dao.getAuthorizedComponentByKey("unknown", session);
- }
-
- @Test
public void insert() {
when(system2.now()).thenReturn(DateUtils.parseDate("2014-06-18").getTime());
setupData("empty");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/DbCleanerStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/DbCleanerStepTest.java
index ec6a4373d54..2c05a1a3045 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/DbCleanerStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/DbCleanerStepTest.java
@@ -22,15 +22,13 @@ package org.sonar.server.computation;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.computation.db.AnalysisReportDto;
import org.sonar.core.computation.dbcleaner.DefaultPurgeTask;
import org.sonar.core.persistence.DbSession;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
public class DbCleanerStepTest {
@@ -46,7 +44,7 @@ public class DbCleanerStepTest {
@Test
public void call_purge_method_of_the_purge_task() {
AnalysisReportDto report = mock(AnalysisReportDto.class);
- when(report.getProject()).thenReturn(mock(AuthorizedComponentDto.class));
+ when(report.getProject()).thenReturn(mock(ComponentDto.class));
sut.execute(mock(DbSession.class), report);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java
index e9872ad3a1d..9ac51861ff4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java
@@ -170,7 +170,7 @@ public class InternalPermissionServiceTest {
@Test
public void add_component_user_permission() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams("user", null, "org.sample.Sample", "user");
setUpComponentUserPermissions("user", 10L, "codeviewer");
@@ -196,7 +196,7 @@ public class InternalPermissionServiceTest {
@Test
public void remove_component_user_permission() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams("user", null, "org.sample.Sample", "codeviewer");
setUpComponentUserPermissions("user", 10L, "codeviewer");
MockUserSession.set().setLogin("admin").addProjectPermissions(UserRole.ADMIN, "org.sample.Sample");
@@ -221,7 +221,7 @@ public class InternalPermissionServiceTest {
@Test
public void add_component_group_permission() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, "group", "org.sample.Sample", "user");
setUpGlobalGroupPermissions("group", "codeviewer");
@@ -246,7 +246,7 @@ public class InternalPermissionServiceTest {
@Test
public void add_component_permission_to_anyone_group() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, DefaultGroups.ANYONE, "org.sample.Sample", "user");
MockUserSession.set().setLogin("admin").addProjectPermissions(UserRole.ADMIN, "org.sample.Sample");
@@ -271,7 +271,7 @@ public class InternalPermissionServiceTest {
@Test
public void remove_component_group_permission() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, "group", "org.sample.Sample", "codeviewer");
setUpComponentGroupPermissions("group", 10L, "codeviewer");
@@ -297,7 +297,7 @@ public class InternalPermissionServiceTest {
@Test
public void remove_component_permission_from_anyone_group() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, DefaultGroups.ANYONE, "org.sample.Sample", "codeviewer");
setUpComponentGroupPermissions(DefaultGroups.ANYONE, 10L, "codeviewer");
@@ -323,7 +323,7 @@ public class InternalPermissionServiceTest {
@Test
public void skip_redundant_add_component_user_permission_change() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams("user", null, "org.sample.Sample", "codeviewer");
setUpComponentUserPermissions("user", 10L, "codeviewer");
@@ -349,7 +349,7 @@ public class InternalPermissionServiceTest {
@Test
public void skip_redundant_add_component_group_permission_change() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, "group", "org.sample.Sample", "codeviewer");
setUpComponentGroupPermissions("group", 10L, "codeviewer");
@@ -407,7 +407,7 @@ public class InternalPermissionServiceTest {
public void fail_on_insufficient_project_rights() throws Exception {
try {
ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
params = buildPermissionChangeParams(null, DefaultGroups.ANYONE, "org.sample.Sample", "user");
MockUserSession.set().setLogin("admin").addProjectPermissions(UserRole.ADMIN);
@@ -430,11 +430,11 @@ public class InternalPermissionServiceTest {
@Test
public void apply_permission_template_on_many_projects() throws Exception {
ComponentDto project1 = ComponentTesting.newProjectDto().setId(1L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample1", session)).thenReturn(project1);
+ when(componentDao.getByKey(session, "org.sample.Sample1")).thenReturn(project1);
ComponentDto project2 = ComponentTesting.newProjectDto().setId(2L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample2", session)).thenReturn(project2);
+ when(componentDao.getByKey(session, "org.sample.Sample2")).thenReturn(project2);
ComponentDto project3 = ComponentTesting.newProjectDto().setId(3L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample3", session)).thenReturn(project3);
+ when(componentDao.getByKey(session, "org.sample.Sample3")).thenReturn(project3);
params = Maps.newHashMap();
params.put("template_key", "my_template_key");
params.put("components", "org.sample.Sample1,org.sample.Sample2,org.sample.Sample3");
@@ -456,13 +456,13 @@ public class InternalPermissionServiceTest {
ComponentDto c1 = mock(ComponentDto.class);
when(c1.getId()).thenReturn(1L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample1", session)).thenReturn(c1);
+ when(componentDao.getByKey(session, "org.sample.Sample1")).thenReturn(c1);
ComponentDto c2 = mock(ComponentDto.class);
when(c2.getId()).thenReturn(2L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample2", session)).thenReturn(c2);
+ when(componentDao.getByKey(session, "org.sample.Sample2")).thenReturn(c1);
ComponentDto c3 = mock(ComponentDto.class);
when(c3.getId()).thenReturn(3L);
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample3", session)).thenReturn(c3);
+ when(componentDao.getByKey(session, "org.sample.Sample3")).thenReturn(c3);
params = Maps.newHashMap();
params.put("template_key", "my_template_key");
params.put("components", "org.sample.Sample1,org.sample.Sample2,org.sample.Sample3");
@@ -482,7 +482,7 @@ public class InternalPermissionServiceTest {
params.put("components", "org.sample.Sample");
ComponentDto project = ComponentTesting.newProjectDto().setId(1L).setKey("org.sample.Sample");
- when(componentDao.getAuthorizedComponentByKey("org.sample.Sample", session)).thenReturn(project);
+ when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);
service.applyPermissionTemplate(params);
@@ -516,7 +516,7 @@ public class InternalPermissionServiceTest {
when(mockComponent.qualifier()).thenReturn(qualifier);
MockUserSession.set().setLogin("admin").addProjectPermissions(UserRole.ADMIN, componentKey);
- when(componentDao.getAuthorizedComponentByKey(componentKey, session)).thenReturn(mockComponent);
+ when(componentDao.getByKey(session, componentKey)).thenReturn(mockComponent);
service.applyDefaultPermissionTemplate(componentKey);
verify(permissionFacade).grantDefaultRoles(session, componentId, qualifier);
@@ -533,7 +533,7 @@ public class InternalPermissionServiceTest {
when(mockComponent.getId()).thenReturn(componentId);
when(mockComponent.qualifier()).thenReturn(qualifier);
- when(componentDao.getAuthorizedComponentByKey(componentKey, session)).thenReturn(mockComponent);
+ when(componentDao.getByKey(session, componentKey)).thenReturn(mockComponent);
when(resourceDao.selectProvisionedProject(session, componentKey)).thenReturn(mock(ResourceDto.class));
service.applyDefaultPermissionTemplate(componentKey);
@@ -549,7 +549,7 @@ public class InternalPermissionServiceTest {
ComponentDto project = new ComponentDto().setId(componentId).setKey(componentKey).setQualifier(qualifier);
- when(componentDao.getAuthorizedComponentByKey(componentKey, session)).thenReturn(project);
+ when(componentDao.getByKey(session, componentKey)).thenReturn(project);
when(resourceDao.selectProvisionedProject(session, componentKey)).thenReturn(mock(ResourceDto.class));
service.applyDefaultPermissionTemplate(componentKey);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
index bfe3863e048..abb27e79fd2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
@@ -35,7 +35,7 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metric.ValueType;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.web.UserRole;
-import org.sonar.core.component.AuthorizedComponentDto;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
@@ -99,7 +99,7 @@ public class QualityGatesTest {
@Before
public void initialize() {
- when(componentDao.getAuthorizedComponentById(anyLong(), eq(session))).thenReturn(new AuthorizedComponentDto().setId(1L).setKey(PROJECT_KEY));
+ when(componentDao.getById(anyLong(), eq(session))).thenReturn(new ComponentDto().setId(1L).setKey(PROJECT_KEY));
when(myBatis.openSession(false)).thenReturn(session);
qGates = new QualityGates(dao, conditionDao, metricFinder, propertiesDao, componentDao, myBatis);
diff --git a/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java
deleted file mode 100644
index 17bb40c1469..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.
- */
-
-package org.sonar.core.component;
-
-import org.sonar.core.persistence.Dto;
-
-/**
- * Used to check that a project exists. Can return provisioned projects and projects from analysis.
- * The root project id is not available because no join on snapshot is done to retrieve it.
- *
- * Warning, this component should not be retrieve from db using a join on snapshots, otherwise provisioned projects will not be returned anymore.
- */
-public class AuthorizedComponentDto extends Dto<String> {
-
- private Long id;
- private String uuid;
- private String kee;
- private String scope;
- private String qualifier;
-
- public Long getId() {
- return id;
- }
-
- public AuthorizedComponentDto setId(Long id) {
- this.id = id;
- return this;
- }
-
- public String uuid() {
- return uuid;
- }
-
- public AuthorizedComponentDto setAuthorizedUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public String key() {
- return kee;
- }
-
- public AuthorizedComponentDto setKey(String key) {
- this.kee = key;
- return this;
- }
-
- public String scope() {
- return scope;
- }
-
- public void setAuthorizedScope(String scope) {
- this.scope = scope;
- }
-
- public String qualifier() {
- return qualifier;
- }
-
- public AuthorizedComponentDto setAuthorizedQualifier(String qualifier) {
- this.qualifier = qualifier;
- return this;
- }
-
- @Override
- public String getKey() {
- return kee;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- AuthorizedComponentDto that = (AuthorizedComponentDto) o;
-
- if (!id.equals(that.id)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public String toString() {
- return "AuthorizedComponentDto{" +
- "id=" + id +
- ", uuid='" + uuid + '\'' +
- ", kee='" + kee + '\'' +
- ", scope='" + scope + '\'' +
- ", qualifier='" + qualifier + '\'' +
- '}';
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
index 91510ea3c0f..71ce1b8122c 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
@@ -20,13 +20,20 @@
package org.sonar.core.component;
import org.sonar.api.component.Component;
+import org.sonar.core.persistence.Dto;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.util.Date;
-public class ComponentDto extends AuthorizedComponentDto implements Component {
+public class ComponentDto extends Dto<String> implements Component {
+
+ private Long id;
+ private String uuid;
+ private String kee;
+ private String scope;
+ private String qualifier;
private String projectUuid;
private String moduleUuid;
@@ -41,30 +48,59 @@ public class ComponentDto extends AuthorizedComponentDto implements Component {
private boolean enabled = true;
private Date authorizationUpdatedAt;
- @Override
+
+ public Long getId() {
+ return id;
+ }
+
public ComponentDto setId(Long id) {
- super.setId(id);
+ this.id = id;
return this;
}
- @CheckForNull
- public String deprecatedKey() {
- return deprecatedKey;
+ public String uuid() {
+ return uuid;
}
- public ComponentDto setDeprecatedKey(@Nullable String deprecatedKey) {
- this.deprecatedKey = deprecatedKey;
+ public ComponentDto setUuid(String uuid) {
+ this.uuid = uuid;
return this;
}
- @Override
+ public String key() {
+ return kee;
+ }
+
public ComponentDto setKey(String key) {
- super.setKey(key);
+ this.kee = key;
return this;
}
- public ComponentDto setUuid(String uuid) {
- super.setAuthorizedUuid(uuid);
+ public String scope() {
+ return scope;
+ }
+
+ public ComponentDto setScope(String scope) {
+ this.scope = scope;
+ return this;
+ }
+
+ public String qualifier() {
+ return qualifier;
+ }
+
+ public ComponentDto setQualifier(String qualifier) {
+ this.qualifier = qualifier;
+ return this;
+ }
+
+ @CheckForNull
+ public String deprecatedKey() {
+ return deprecatedKey;
+ }
+
+ public ComponentDto setDeprecatedKey(@Nullable String deprecatedKey) {
+ this.deprecatedKey = deprecatedKey;
return this;
}
@@ -137,16 +173,6 @@ public class ComponentDto extends AuthorizedComponentDto implements Component {
return this;
}
- public ComponentDto setQualifier(String qualifier) {
- super.setAuthorizedQualifier(qualifier);
- return this;
- }
-
- public ComponentDto setScope(String scope) {
- super.setAuthorizedScope(scope);
- return this;
- }
-
@CheckForNull
public String language() {
return language;
@@ -188,4 +214,32 @@ public class ComponentDto extends AuthorizedComponentDto implements Component {
this.authorizationUpdatedAt = authorizationUpdatedAt;
return this;
}
+
+ @Override
+ public String getKey() {
+ return kee;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ ComponentDto that = (ComponentDto) o;
+
+ if (!id.equals(that.id)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
index 054e5f69508..2f3ed28c008 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java
@@ -20,7 +20,6 @@
package org.sonar.core.component.db;
import org.apache.ibatis.annotations.Param;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import javax.annotation.CheckForNull;
@@ -76,11 +75,6 @@ public interface ComponentMapper {
long countById(long id);
- @CheckForNull
- AuthorizedComponentDto selectAuthorizedComponentById(long id);
-
- AuthorizedComponentDto selectAuthorizedComponentByKey(String key);
-
void insert(ComponentDto rule);
void deleteByKey(String key);
diff --git a/sonar-core/src/main/java/org/sonar/core/computation/db/AnalysisReportDto.java b/sonar-core/src/main/java/org/sonar/core/computation/db/AnalysisReportDto.java
index a058966a2e2..725a87f81a5 100644
--- a/sonar-core/src/main/java/org/sonar/core/computation/db/AnalysisReportDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/computation/db/AnalysisReportDto.java
@@ -22,7 +22,6 @@ package org.sonar.core.computation.db;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.Dto;
@@ -169,7 +168,7 @@ public class AnalysisReportDto extends Dto<String> {
return this;
}
- public AuthorizedComponentDto getProject() {
+ public ComponentDto getProject() {
return checkNotNull(project);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index fba96a99c1b..ad721c7bf0b 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -34,7 +34,6 @@ import org.sonar.api.database.model.MeasureModel;
import org.sonar.core.activity.db.ActivityDto;
import org.sonar.core.activity.db.ActivityMapper;
import org.sonar.core.cluster.WorkQueue;
-import org.sonar.core.component.AuthorizedComponentDto;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.SnapshotDto;
import org.sonar.core.component.db.ComponentMapper;
@@ -111,7 +110,6 @@ public class MyBatis implements BatchComponent, ServerComponent {
loadAlias(conf, "ActiveDashboard", ActiveDashboardDto.class);
loadAlias(conf, "Author", AuthorDto.class);
loadAlias(conf, "Component", ComponentDto.class);
- loadAlias(conf, "AuthorizedComponent", AuthorizedComponentDto.class);
loadAlias(conf, "Dashboard", DashboardDto.class);
loadAlias(conf, "Dependency", DependencyDto.class);
loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class);
diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
index 4556df577a5..d51c13b7c88 100644
--- a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml
@@ -65,8 +65,7 @@
<select id="selectRootProjectByKey" parameterType="String" resultType="Component">
SELECT rootProject.*
FROM projects p
- INNER JOIN snapshots s ON s.project_id=p.id AND s.islast=${_true}
- INNER JOIN projects rootProject ON rootProject.id=s.root_project_id
+ INNER JOIN projects rootProject ON rootProject.uuid=p.project_uuid
<where>
AND p.kee=#{componentKey}
</where>
@@ -133,24 +132,6 @@
</where>
</select>
- <select id="selectAuthorizedComponentById" parameterType="long" resultType="AuthorizedComponent">
- SELECT <include refid="authorizedComponentColumns"/>
- FROM projects p
- <where>
- AND p.enabled=${_true}
- AND p.id=#{id}
- </where>
- </select>
-
- <select id="selectAuthorizedComponentByKey" parameterType="String" resultType="AuthorizedComponent">
- SELECT <include refid="authorizedComponentColumns"/>
- FROM projects p
- <where>
- AND p.enabled=${_true}
- AND p.kee=#{key}
- </where>
- </select>
-
<sql id="insertColumns">
(kee, deprecated_kee, uuid, project_uuid, module_uuid, module_uuid_path, name, long_name, qualifier, scope, language, root_id, path, enabled, created_at, authorization_updated_at)
</sql>