From e0a940902f37156757e84544d0a876f47f69040f Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 24 Oct 2024 10:54:15 +0200 Subject: [PATCH] SONAR-23427 Stop relying on Qualifiers, Scopes and ResourceType from the plugin API --- gradle.properties | 2 +- .../main/java/org/sonar/xoo/XooPlugin.java | 12 +- .../step/ViewsPersistComponentsStepIT.java | 20 +- .../analysis/ExportAnalysesStepIT.java | 16 +- .../component/ExportComponentsStepIT.java | 16 +- .../steps/ExportEventsStepIT.java | 8 +- .../steps/ExportNewCodePeriodsStepIT.java | 4 +- .../steps/ExportSettingsStepIT.java | 4 +- .../steps/LoadProjectStepIT.java | 4 +- .../component/BranchPersisterImpl.java | 4 +- .../component/ProjectPersister.java | 4 +- .../component/ViewAttributes.java | 4 +- .../step/PersistComponentsStep.java | 24 +- .../component/ComponentRepository.java | 3 +- .../component/ExportComponentsStep.java | 4 +- .../component/ViewAttributesTest.java | 12 +- ...ailureNotificationExecutionListenerIT.java | 4 +- .../container/ComputeEngineContainerImpl.java | 8 +- ...sFailureNotificationExecutionListener.java | 4 +- server/sonar-db-dao/build.gradle | 2 +- .../sonar/db/component/ComponentDaoIT.java | 28 ++- .../ScrollForFileMoveComponentDaoIT.java | 4 +- .../org/sonar/db/measure/MeasureDaoIT.java | 6 +- .../org/sonar/db/project/ProjectDaoIT.java | 4 +- .../sonar/db/property/PropertiesDaoIT.java | 6 +- .../PropertiesDaoWithPersisterIT.java | 16 +- .../java/org/sonar/db/purge/PurgeDaoIT.java | 8 +- .../it/java/org/sonar/db/user/RoleDaoIT.java | 4 +- .../org/sonar/db/audit/model/NewValue.java | 6 +- .../org/sonar/db/component/ComponentDao.java | 3 +- .../org/sonar/db/component/ComponentDto.java | 3 +- .../db/component/ComponentKeyUpdaterDao.java | 5 +- .../db/component/ComponentQualifiers.java | 36 +++ .../sonar/db/component/ComponentScopes.java | 30 +++ .../java/org/sonar/db/entity/EntityDto.java | 10 +- .../java/org/sonar/db/issue/IssueTesting.java | 4 +- .../ProjectMeasuresIndexerIterator.java | 6 +- .../org/sonar/db/portfolio/PortfolioDao.java | 4 +- .../org/sonar/db/portfolio/PortfolioDto.java | 6 +- .../sonar/db/component/ComponentDtoTest.java | 5 +- .../db/component/ComponentQueryTest.java | 2 +- .../org/sonar/db/entity/EntityDtoTest.java | 12 +- .../sonar/db/portfolio/PortfolioDtoTest.java | 6 +- .../sonar/db/component/ComponentDbTester.java | 9 +- .../sonar/db/component/ComponentTesting.java | 40 ++-- .../sonar/db/component/ProjectTesting.java | 3 +- .../java/org/sonar/db/user/UserDbTester.java | 4 +- .../FixDifferentUuidsForSubportfoliosIT.java | 11 +- .../index/EntityDefinitionIndexerIT.java | 2 +- .../server/issue/index/IssueIndexerIT.java | 6 +- .../index/ProjectMeasuresIndexerIT.java | 10 +- .../server/view/index/ViewIndexerIT.java | 2 +- .../sonar/server/component/ComponentType.java | 206 ++++++++++++++++++ .../server/component/ComponentTypeTree.java | 115 ++++++++++ .../server/component/ComponentTypes.java | 94 ++++++++ .../component/DefaultComponentTypes.java | 30 ++- .../server/issue/index/IssueIndexer.java | 4 +- .../index/IssueIteratorForSingleChunk.java | 10 +- .../measure/index/ProjectMeasuresIndexer.java | 4 +- .../permission/PermissionServiceImpl.java | 14 +- .../server/component/ComponentTypeTest.java | 99 +++++++++ .../component/ComponentTypeTreeTest.java | 79 +++++++ .../server/component/ComponentTypesTest.java | 102 +++++++++ .../component/DefaultComponentTypesTest.java | 11 +- .../permission/PermissionServiceImplTest.java | 4 +- .../index/PermissionIndexerDaoIT.java | 6 +- .../index/PermissionIndexerTest.java | 2 +- .../server/component/ComponentTypesRule.java} | 55 +++-- .../sonar/server/issue/IssueDocTesting.java | 6 +- .../server/user/AbstractUserSession.java | 2 +- .../sonar/server/user/ServerUserSession.java | 18 +- .../user/ThreadLocalUserSessionTest.java | 14 +- .../common/component/ComponentUpdaterIT.java | 18 +- .../DefaultTemplatesResolverImplIT.java | 14 +- .../permission/GroupPermissionChangerIT.java | 13 +- .../PermissionTemplateServiceIT.java | 10 +- .../permission/UserPermissionChangerIT.java | 10 +- .../common/component/ComponentUpdater.java | 10 +- .../server/common/component/NewComponent.java | 2 +- .../DefaultTemplatesResolverImpl.java | 32 +-- .../permission/PermissionTemplateService.java | 10 +- .../server/common/project/ProjectCreator.java | 2 +- .../DefaultDevOpsProjectCreatorTest.java | 4 +- .../index/IssueIndexSyncProgressChecker.java | 6 +- .../server/issue/index/IssueQueryFactory.java | 16 +- .../measure/index/ProjectMeasuresIndex.java | 6 +- .../index/ComponentIndexCombinationTest.java | 10 +- .../index/ComponentIndexFeatureExactTest.java | 2 +- .../ComponentIndexFeatureFavoriteTest.java | 2 +- ...ponentIndexFeatureRecentlyBrowsedTest.java | 2 +- .../index/ComponentIndexHighlightTest.java | 4 +- .../index/ComponentIndexScoreTest.java | 2 +- .../index/ComponentIndexSearchTest.java | 4 +- .../component/index/ComponentIndexTest.java | 4 +- .../issue/index/IssueIndexFiltersTest.java | 2 +- .../issue/index/IssueIndexTestCommon.java | 2 +- .../issue/index/IssueQueryFactoryTest.java | 6 +- .../index/ProjectMeasuresIndexTest.java | 4 +- .../ProjectMeasuresIndexTextSearchTest.java | 2 +- .../index/PermissionIndexerTester.java | 5 +- server/sonar-webserver-webapi/build.gradle | 3 +- .../github/ImportGithubProjectActionIT.java | 6 +- .../gitlab/ImportGitLabProjectActionIT.java | 6 +- .../almsettings/ws/CreateGithubActionIT.java | 4 +- .../server/almsettings/ws/ListActionIT.java | 4 +- .../ws/UpdateBitbucketCloudActionIT.java | 4 +- .../almsettings/ws/UpdateGithubActionIT.java | 4 +- .../almsettings/ws/ValidateActionIT.java | 4 +- .../server/batch/ProjectDataLoaderIT.java | 10 +- .../sonar/server/branch/ws/ListActionIT.java | 10 +- .../server/branch/ws/RenameActionIT.java | 10 +- ...etAutomaticDeletionProtectionActionIT.java | 10 +- .../server/component/ws/SearchActionIT.java | 12 +- .../component/ws/SearchProjectsActionIT.java | 12 +- .../server/component/ws/ShowActionIT.java | 8 +- .../component/ws/SuggestionsActionIT.java | 20 +- .../server/component/ws/TreeActionIT.java | 22 +- .../server/favorite/ws/SearchActionIT.java | 2 +- .../sonar/server/hotspot/ws/PullActionIT.java | 6 +- .../sonar/server/issue/ws/PullActionIT.java | 6 +- .../server/issue/ws/PullTaintActionIT.java | 6 +- .../issue/ws/SearchActionComponentsIT.java | 6 +- .../sonar/server/issue/ws/SearchActionIT.java | 2 +- .../sonar/server/issue/ws/TagsActionIT.java | 6 +- .../AnticipatedTransitionsActionIT.java | 8 +- .../live/LiveMeasureComputerImplIT.java | 4 +- .../measure/ws/ComponentTreeActionIT.java | 24 +- .../permission/ws/AddGroupActionIT.java | 10 +- .../server/permission/ws/AddUserActionIT.java | 10 +- .../permission/ws/BasePermissionWsIT.java | 8 +- .../server/permission/ws/GroupsActionIT.java | 10 +- .../permission/ws/RemoveGroupActionIT.java | 10 +- .../permission/ws/RemoveUserActionIT.java | 10 +- .../server/permission/ws/UsersActionIT.java | 10 +- .../template/AddGroupToTemplateActionIT.java | 10 +- .../AddProjectCreatorToTemplateActionIT.java | 10 +- .../template/AddUserToTemplateActionIT.java | 10 +- .../ws/template/ApplyTemplateActionIT.java | 10 +- .../template/BulkApplyTemplateActionIT.java | 14 +- .../ws/template/DeleteTemplateActionIT.java | 10 +- .../RemoveGroupFromTemplateActionIT.java | 10 +- ...oveProjectCreatorFromTemplateActionIT.java | 10 +- .../RemoveUserFromTemplateActionIT.java | 10 +- .../ws/template/SearchTemplatesActionIT.java | 8 +- .../template/SetDefaultTemplateActionIT.java | 12 +- .../ws/template/TemplateGroupsActionIT.java | 10 +- .../ws/template/TemplateUsersActionIT.java | 10 +- .../server/project/ws/BulkDeleteActionIT.java | 4 +- .../project/ws/UpdateVisibilityActionIT.java | 10 +- .../server/projectdump/ws/ExportActionIT.java | 6 +- .../server/projectdump/ws/StatusActionIT.java | 6 +- .../server/projecttag/ws/SearchActionIT.java | 2 +- .../ws/RemoveProjectActionIT.java | 6 +- .../setting/ws/ListDefinitionsActionIT.java | 4 +- .../server/setting/ws/ResetActionIT.java | 4 +- .../sonar/server/setting/ws/SetActionIT.java | 15 +- .../server/setting/ws/ValuesActionIT.java | 2 +- .../sonar/server/source/ws/RawActionIT.java | 6 +- .../sonar/server/source/ws/ShowActionIT.java | 6 +- .../sonar/server/ui/ws/ComponentActionIT.java | 32 +-- .../user/ws/CurrentActionHomepageIT.java | 12 +- .../sonar/server/user/ws/CurrentActionIT.java | 16 +- .../server/usertoken/ws/GenerateActionIT.java | 4 +- .../server/webhook/ws/CreateActionIT.java | 6 +- .../sonar/server/webhook/ws/ListActionIT.java | 6 +- .../server/webhook/ws/UpdateActionIT.java | 6 +- .../server/ce/queue/ReportSubmitter.java | 6 +- .../sonar/server/ce/ws/ActivityAction.java | 4 +- .../component/ComponentCleanerService.java | 6 +- .../server/component/ComponentFinder.java | 26 +-- .../ws/ComponentDtoToWsComponent.java | 6 +- .../ws/ProjectMeasuresQueryFactory.java | 4 +- .../server/component/ws/SearchAction.java | 18 +- .../component/ws/SearchProjectsAction.java | 12 +- .../sonar/server/component/ws/ShowAction.java | 10 +- .../component/ws/SuggestionCategory.java | 10 +- .../component/ws/SuggestionsAction.java | 14 +- .../sonar/server/component/ws/TreeAction.java | 16 +- .../sonar/server/favorite/ws/AddAction.java | 8 +- .../sonar/server/hotspot/ws/SearchAction.java | 6 +- .../sonar/server/issue/ws/AuthorsAction.java | 10 +- .../server/issue/ws/SearchResponseFormat.java | 2 +- .../org/sonar/server/issue/ws/TagsAction.java | 10 +- .../server/measure/ws/ComponentAction.java | 4 +- .../measure/ws/ComponentTreeAction.java | 24 +- .../measure/ws/MetricDtoWithBestValue.java | 4 +- .../sonar/server/measure/ws/SearchAction.java | 8 +- .../measure/ws/SearchHistoryAction.java | 6 +- .../server/permission/RequestValidator.java | 10 +- .../permission/ws/PermissionWsSupport.java | 4 +- .../ws/template/ApplyTemplateAction.java | 4 +- .../ws/template/BulkApplyTemplateAction.java | 16 +- .../ws/template/SearchTemplatesAction.java | 8 +- .../ws/template/SetDefaultTemplateAction.java | 22 +- .../server/project/ws/BulkDeleteAction.java | 6 +- .../sonar/server/project/ws/CreateAction.java | 2 +- .../sonar/server/project/ws/SearchAction.java | 6 +- .../project/ws/SearchMyProjectsAction.java | 4 +- .../server/project/ws/SearchRequest.java | 4 +- .../projectanalysis/ws/CreateEventAction.java | 4 +- .../projectanalysis/ws/SearchAction.java | 10 +- .../server/setting/ws/SettingValidations.java | 4 +- .../sonar/server/ui/ws/ComponentAction.java | 32 +-- .../org/sonar/server/ui/ws/GlobalAction.java | 12 +- .../server/component/NewComponentTest.java | 2 +- ...archResponseFormatFormatOperationTest.java | 2 +- .../measure/ws/ComponentTreeSortTest.java | 16 +- .../sonar/server/ui/PageRepositoryTest.java | 4 +- .../sonar/server/ui/ws/GlobalActionTest.java | 42 ++-- .../server/component/TestComponentFinder.java | 10 +- .../sonar/server/ws/WsParameterBuilder.java | 36 +-- .../server/ws/WsParameterBuilderTest.java | 40 ++-- .../platformlevel/PlatformLevel4.java | 8 +- .../core/config/CorePropertyDefinitions.java | 14 +- .../core/config/ExclusionProperties.java | 12 +- .../core/config/IssueExclusionProperties.java | 10 +- .../sonar/core/config/PurgeProperties.java | 16 +- .../sonar/core/config/ScannerProperties.java | 6 +- .../scanner/bootstrap/BatchComponents.java | 2 - .../ExternalIssuesImportSensor.java | 4 +- .../sarif/SarifIssuesImportSensor.java | 4 +- .../GenericCoverageSensor.java | 8 +- .../GenericTestExecutionSensor.java | 8 +- .../scan/SpringProjectScanContainer.java | 3 - 224 files changed, 1725 insertions(+), 997 deletions(-) create mode 100644 server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentQualifiers.java create mode 100644 server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentScopes.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentType.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypeTree.java create mode 100644 server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypes.java rename sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java => server/sonar-server-common/src/main/java/org/sonar/server/component/DefaultComponentTypes.java (67%) create mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTest.java create mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTreeTest.java create mode 100644 server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypesTest.java rename sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java => server/sonar-server-common/src/test/java/org/sonar/server/component/DefaultComponentTypesTest.java (76%) rename server/{sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ResourceTypesRule.java => sonar-server-common/src/testFixtures/java/org/sonar/server/component/ComponentTypesRule.java} (54%) diff --git a/gradle.properties b/gradle.properties index 0794fc47a86..40c3ad21e07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ version=10.8 # 30 months from the release date for LTA versions # No change required for patch versions versionEOL=2025-05-27 -pluginApiVersion=10.11.0.2468 +pluginApiVersion=10.13.0.2551 description=Open source platform for continuous inspection of code quality projectTitle=SonarQube org.gradle.jvmargs=-Xmx2048m diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index ab762def0c4..c2897767552 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -23,7 +23,7 @@ import org.sonar.api.Plugin; import org.sonar.api.PropertyType; import org.sonar.api.SonarProduct; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.xoo.coverage.ItCoverageSensor; import org.sonar.xoo.coverage.OverallCoverageSensor; import org.sonar.xoo.coverage.UtCoverageSensor; @@ -31,7 +31,6 @@ import org.sonar.xoo.extensions.XooExcludeFileFilter; import org.sonar.xoo.extensions.XooIssueFilter; import org.sonar.xoo.extensions.XooPostJob; import org.sonar.xoo.extensions.XooProjectBuilder; -import org.sonar.xoo.rule.telemetry.SensorMetrics; import org.sonar.xoo.global.DeprecatedGlobalSensor; import org.sonar.xoo.global.GlobalProjectSensor; import org.sonar.xoo.lang.CpdTokenizerSensor; @@ -87,6 +86,7 @@ import org.sonar.xoo.rule.hotspot.HotspotWithContextsSensor; import org.sonar.xoo.rule.hotspot.HotspotWithSingleContextSensor; import org.sonar.xoo.rule.hotspot.HotspotWithoutContextSensor; import org.sonar.xoo.rule.telemetry.OneIssuePerUninitializedVariableForTelemetrySensor; +import org.sonar.xoo.rule.telemetry.SensorMetrics; import org.sonar.xoo.rule.variant.HotspotWithCodeVariantsSensor; import org.sonar.xoo.rule.variant.IssueWithCodeVariantsSensor; import org.sonar.xoo.scm.XooBlameCommand; @@ -106,7 +106,7 @@ public class XooPlugin implements Plugin { .name("File suffixes") .description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.") .subCategory("General") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .multiValues(true) .build(), PropertyDefinition.builder(Xoo2.FILE_SUFFIXES_KEY) @@ -114,15 +114,15 @@ public class XooPlugin implements Plugin { .name("File suffixes") .description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.") .subCategory("General") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build(), // Used by DuplicationsTest and IssueFilterOnCommonRulesTest. If not declared it is not returned by api/settings PropertyDefinition.builder("sonar.cpd.xoo.minimumTokens") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .type(PropertyType.INTEGER) .build(), PropertyDefinition.builder("sonar.cpd.xoo.minimumLines") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .type(PropertyType.INTEGER) .build(), Xoo.class, diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java index 1215f3d873f..03fe0f434c0 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java @@ -27,8 +27,8 @@ import javax.annotation.Nullable; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectanalysis.component.BranchPersister; import org.sonar.ce.task.projectanalysis.component.Component; @@ -512,8 +512,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { assertThat(dto.path()).isNull(); assertThat(dto.uuid()).isEqualTo(VIEW_UUID); assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID); - assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW); - assertThat(dto.scope()).isEqualTo(Scopes.PROJECT); + assertThat(dto.qualifier()).isEqualTo(ComponentQualifiers.VIEW); + assertThat(dto.scope()).isEqualTo(ComponentScopes.PROJECT); assertThat(dto.getCopyComponentUuid()).isNull(); assertThat(dto.getCreatedAt()).isEqualTo(now); } @@ -528,8 +528,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { assertThat(dto.path()).isNull(); assertThat(dto.uuid()).isEqualTo(VIEW_UUID); assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID); - assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP); - assertThat(dto.scope()).isEqualTo(Scopes.PROJECT); + assertThat(dto.qualifier()).isEqualTo(ComponentQualifiers.APP); + assertThat(dto.scope()).isEqualTo(ComponentScopes.PROJECT); assertThat(dto.getCopyComponentUuid()).isNull(); assertThat(dto.getCreatedAt()).isEqualTo(now); } @@ -544,8 +544,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { assertThat(sv1Dto.path()).isNull(); assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID); assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid()); - assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW); - assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT); + assertThat(sv1Dto.qualifier()).isEqualTo(ComponentQualifiers.SUBVIEW); + assertThat(sv1Dto.scope()).isEqualTo(ComponentScopes.PROJECT); assertThat(sv1Dto.getCopyComponentUuid()).isNull(); assertThat(sv1Dto.getCreatedAt()).isEqualTo(now); } @@ -557,8 +557,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { assertThat(pv1Dto.path()).isNull(); assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID); assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid()); - assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT); - assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE); + assertThat(pv1Dto.qualifier()).isEqualTo(ComponentQualifiers.PROJECT); + assertThat(pv1Dto.scope()).isEqualTo(ComponentScopes.FILE); assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid()); assertThat(pv1Dto.getCreatedAt()).isEqualTo(now); } diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java index 808091735f0..35cd86f06c4 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java @@ -31,8 +31,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.event.Level; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl; @@ -59,8 +59,8 @@ public class ExportAnalysesStepIT { private static final String PROJECT_UUID = "PROJECT_UUID"; private static final ComponentDto PROJECT = new ComponentDto() // no id yet - .setScope(Scopes.PROJECT) - .setQualifier(Qualifiers.PROJECT) + .setScope(ComponentScopes.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setKey("the_project") .setName("The Project") .setDescription("The project description") @@ -73,8 +73,8 @@ public class ExportAnalysesStepIT { private static final String UUID_PATH = UUID_PATH_OF_ROOT + UUID_PATH_SEPARATOR + DIR_UUID; private static final ComponentDto DIR = new ComponentDto() // no id yet - .setScope(Scopes.PROJECT) - .setQualifier(Qualifiers.DIRECTORY) + .setScope(ComponentScopes.PROJECT) + .setQualifier(ComponentQualifiers.DIRECTORY) .setKey("the_dir") .setName("The Dir") .setDescription("description of dir") @@ -86,8 +86,8 @@ public class ExportAnalysesStepIT { private static final String FILE_UUID = "FILE_UUID"; private static final ComponentDto FILE = new ComponentDto() // no id yet - .setScope(Scopes.FILE) - .setQualifier(Qualifiers.FILE) + .setScope(ComponentScopes.FILE) + .setQualifier(ComponentQualifiers.FILE) .setKey("the_file") .setName("The File") .setUuid(FILE_UUID) diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java index feff1fc7794..8240de0c652 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java @@ -28,8 +28,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectexport.steps.DumpElement; @@ -52,8 +52,8 @@ public class ExportComponentsStepIT { private static final String PROJECT_UUID = "PROJECT_UUID"; private static final ComponentDto PROJECT = new ComponentDto() // no id yet - .setScope(Scopes.PROJECT) - .setQualifier(Qualifiers.PROJECT) + .setScope(ComponentScopes.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setKey("the_project") .setName("The Project") .setDescription("The project description") @@ -67,8 +67,8 @@ public class ExportComponentsStepIT { private static final String FILE_UUID_PATH = PROJECT_UUID + FILE_UUID + UUID_PATH_SEPARATOR; private static final ComponentDto FILE = new ComponentDto() // no id yet - .setScope(Scopes.FILE) - .setQualifier(Qualifiers.FILE) + .setScope(ComponentScopes.FILE) + .setQualifier(ComponentQualifiers.FILE) .setKey("the_file") .setName("The File") .setUuid(FILE_UUID) @@ -110,8 +110,8 @@ public class ExportComponentsStepIT { List components = dumpWriter.getWrittenMessagesOf(DumpElement.COMPONENTS); assertThat(components).extracting(ProjectDump.Component::getQualifier, ProjectDump.Component::getUuid, ProjectDump.Component::getUuidPath) .containsExactlyInAnyOrder( - tuple(Qualifiers.FILE, FILE_UUID, FILE_UUID_PATH), - tuple(Qualifiers.PROJECT, PROJECT_UUID, UUID_PATH_OF_ROOT)); + tuple(ComponentQualifiers.FILE, FILE_UUID, FILE_UUID_PATH), + tuple(ComponentQualifiers.PROJECT, PROJECT_UUID, UUID_PATH_OF_ROOT)); } @Test diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java index 90aced92047..4f8fc259ba3 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java @@ -25,8 +25,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl; @@ -51,8 +51,8 @@ public class ExportEventsStepIT { .setUuid(PROJECT_UUID) .setUuidPath(UUID_PATH_OF_ROOT) .setBranchUuid(PROJECT_UUID) - .setScope(Scopes.PROJECT) - .setQualifier(Qualifiers.PROJECT) + .setScope(ComponentScopes.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setKey("the_project") .setEnabled(true); diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java index 15a6526ea3e..09ede9a7f07 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.System2; import org.sonar.ce.task.step.TestComputationStepContext; @@ -55,7 +55,7 @@ public class ExportNewCodePeriodsStepIT { .setUuid(ANOTHER_PROJECT_UUID) .setUuidPath(UUID_PATH_OF_ROOT) .setBranchUuid(ANOTHER_PROJECT_UUID) - .setQualifier(Qualifiers.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setName("another_project") .setKey("another_project"); diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java index 2ddd1ed7f9b..bea0ef4cdd0 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java @@ -26,7 +26,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.System2; import org.sonar.ce.task.step.TestComputationStepContext; @@ -159,7 +159,7 @@ public class ExportSettingsStepIT { private void insertProperties(@Nullable String entityKey, @Nullable String entityName, PropertyDto... dtos) { for (PropertyDto dto : dtos) { - dbTester.getDbClient().propertiesDao().saveProperty(dbTester.getSession(), dto, null, entityKey, entityName, Qualifiers.VIEW); + dbTester.getDbClient().propertiesDao().saveProperty(dbTester.getSession(), dto, null, entityKey, entityName, ComponentQualifiers.VIEW); } dbTester.commit(); } diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java index a63e3216cc6..39d9dc36b45 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java @@ -21,7 +21,7 @@ package org.sonar.ce.task.projectexport.steps; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectexport.taskprocessor.ProjectDescriptor; @@ -56,7 +56,7 @@ public class LoadProjectStepIT { // insert a module, but not a project dbTester.executeInsert("projects", "kee", PROJECT_KEY, - "qualifier", Qualifiers.APP, + "qualifier", ComponentQualifiers.APP, "uuid", "not_used", "private", false, "creation_method", CreationMethod.LOCAL_API.name(), diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java index 02b5e1e7524..b0bc14401b0 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java @@ -22,7 +22,7 @@ package org.sonar.ce.task.projectanalysis.component; import java.util.Arrays; import java.util.regex.Pattern; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder; import org.sonar.ce.task.projectanalysis.analysis.Branch; import org.sonar.db.DbClient; @@ -88,7 +88,7 @@ public class BranchPersisterImpl implements BranchPersister { dto.setExcludeFromPurge(excludeFromPurge); // merge branch is only present if it's not a main branch and not an application - if (!branch.isMain() && !Qualifiers.APP.equals(componentDto.qualifier())) { + if (!branch.isMain() && !ComponentQualifiers.APP.equals(componentDto.qualifier())) { dto.setMergeBranchUuid(branch.getReferenceBranchUuid()); } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java index ff151d68f42..ecff782131d 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java @@ -20,7 +20,7 @@ package org.sonar.ce.task.projectanalysis.component; import org.apache.commons.lang3.StringUtils; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -72,7 +72,7 @@ public class ProjectPersister { projectDto.setDescription(root.getDescription()); projectDto.setUpdatedAt(system2.now()); projectDto.setKey(root.getKey()); - projectDto.setQualifier(root.getType().equals(Component.Type.PROJECT) ? Qualifiers.PROJECT : Qualifiers.APP); + projectDto.setQualifier(root.getType().equals(Component.Type.PROJECT) ? ComponentQualifiers.PROJECT : ComponentQualifiers.APP); return projectDto; } } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java index 333640658a9..b3736cca32c 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java @@ -21,7 +21,7 @@ package org.sonar.ce.task.projectanalysis.component; import java.util.Arrays; import javax.annotation.concurrent.Immutable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import static java.util.Objects.requireNonNull; @@ -29,7 +29,7 @@ import static java.util.Objects.requireNonNull; public class ViewAttributes { public enum Type { - PORTFOLIO(Qualifiers.VIEW), APPLICATION(Qualifiers.APP); + PORTFOLIO(ComponentQualifiers.VIEW), APPLICATION(ComponentQualifiers.APP); private final String qualifier; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java index fd8af1dacfd..0c9d8313300 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java @@ -27,8 +27,8 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.utils.System2; import org.sonar.ce.task.projectanalysis.component.BranchPersister; import org.sonar.ce.task.projectanalysis.component.Component; @@ -48,7 +48,7 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentUpdateDto; import static java.util.Optional.ofNullable; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER; import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT; import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR; @@ -254,7 +254,7 @@ public class PersistComponentsStep implements ComputationStep { public ComponentDto createForProject(Component project) { ComponentDto res = createBase(project); - res.setScope(Scopes.PROJECT); + res.setScope(ComponentScopes.PROJECT); res.setQualifier(PROJECT); res.setName(project.getName()); res.setLongName(res.name()); @@ -269,8 +269,8 @@ public class PersistComponentsStep implements ComputationStep { public ComponentDto createForDirectory(Component directory, PathAwareVisitor.Path path) { ComponentDto res = createBase(directory); - res.setScope(Scopes.DIRECTORY); - res.setQualifier(Qualifiers.DIRECTORY); + res.setScope(ComponentScopes.DIRECTORY); + res.setQualifier(ComponentQualifiers.DIRECTORY); res.setName(directory.getShortName()); res.setLongName(directory.getName()); res.setPath(directory.getName()); @@ -283,7 +283,7 @@ public class PersistComponentsStep implements ComputationStep { public ComponentDto createForFile(Component file, PathAwareVisitor.Path path) { ComponentDto res = createBase(file); - res.setScope(Scopes.FILE); + res.setScope(ComponentScopes.FILE); res.setQualifier(getFileQualifier(file)); res.setName(file.getShortName()); res.setLongName(file.getName()); @@ -298,7 +298,7 @@ public class PersistComponentsStep implements ComputationStep { private ComponentDto createForView(Component view) { ComponentDto res = createBase(view); - res.setScope(Scopes.PROJECT); + res.setScope(ComponentScopes.PROJECT); res.setQualifier(view.getViewAttributes().getType().getQualifier()); res.setName(view.getName()); res.setDescription(view.getDescription()); @@ -313,8 +313,8 @@ public class PersistComponentsStep implements ComputationStep { private ComponentDto createForSubView(Component subView, PathAwareVisitor.Path path) { ComponentDto res = createBase(subView); - res.setScope(Scopes.PROJECT); - res.setQualifier(Qualifiers.SUBVIEW); + res.setScope(ComponentScopes.PROJECT); + res.setQualifier(ComponentQualifiers.SUBVIEW); res.setName(subView.getName()); res.setDescription(subView.getDescription()); res.setLongName(res.name()); @@ -328,7 +328,7 @@ public class PersistComponentsStep implements ComputationStep { private ComponentDto createForProjectView(Component projectView, PathAwareVisitor.Path path) { ComponentDto res = createBase(projectView); - res.setScope(Scopes.FILE); + res.setScope(ComponentScopes.FILE); res.setQualifier(PROJECT); res.setName(projectView.getName()); res.setLongName(res.name()); @@ -415,7 +415,7 @@ public class PersistComponentsStep implements ComputationStep { } private static String getFileQualifier(Component component) { - return component.getFileAttributes().isUnitTest() ? Qualifiers.UNIT_TEST_FILE : Qualifiers.FILE; + return component.getFileAttributes().isUnitTest() ? ComponentQualifiers.UNIT_TEST_FILE : ComponentQualifiers.FILE; } private static class ComponentDtoHolder { diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java index 338ac71c110..2394328b5a9 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java @@ -20,6 +20,7 @@ package org.sonar.ce.task.projectexport.component; import java.util.Set; +import org.sonar.db.component.ComponentQualifiers; /** * Holds the references of components which are present in the dump. @@ -32,7 +33,7 @@ public interface ComponentRepository { long getRef(String uuid); /** - * Uuids of the components of type FILE (ie. Qualifiers = {@link org.sonar.api.resources.Qualifiers#FILE}) known to + * Uuids of the components of type FILE (ie. Qualifiers = {@link ComponentQualifiers#FILE}) known to * the repository. */ Set getFileUuids(); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java index 562c9a8c088..ea73e622dfd 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java @@ -24,7 +24,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import org.slf4j.LoggerFactory; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.ce.task.projectexport.steps.DumpElement; import org.sonar.ce.task.projectexport.steps.DumpWriter; import org.sonar.ce.task.projectexport.steps.ProjectHolder; @@ -77,7 +77,7 @@ public class ExportComponentsStep implements ComputationStep { String qualifier = getString(rs, 2); String uuidPath = getString(rs, 3); componentBuilder.clear(); - componentRepository.register(ref, uuid, Qualifiers.FILE.equals(qualifier)); + componentRepository.register(ref, uuid, ComponentQualifiers.FILE.equals(qualifier)); ProjectDump.Component component = componentBuilder .setRef(ref) .setUuid(uuid) diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java index 5ea223634c5..9b81fadfbf2 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java @@ -20,7 +20,7 @@ package org.sonar.ce.task.projectanalysis.component; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,7 +36,7 @@ public class ViewAttributesTest { underTest = new ViewAttributes(PORTFOLIO); assertThat(underTest.getType()).isEqualTo(PORTFOLIO); - assertThat(underTest.getType().getQualifier()).isEqualTo(Qualifiers.VIEW); + assertThat(underTest.getType().getQualifier()).isEqualTo(ComponentQualifiers.VIEW); } @Test @@ -44,18 +44,18 @@ public class ViewAttributesTest { underTest = new ViewAttributes(APPLICATION); assertThat(underTest.getType()).isEqualTo(APPLICATION); - assertThat(underTest.getType().getQualifier()).isEqualTo(Qualifiers.APP); + assertThat(underTest.getType().getQualifier()).isEqualTo(ComponentQualifiers.APP); } @Test public void type_from_qualifier() { - assertThat(ViewAttributes.Type.fromQualifier(Qualifiers.VIEW)).isEqualTo(PORTFOLIO); - assertThat(ViewAttributes.Type.fromQualifier(Qualifiers.APP)).isEqualTo(APPLICATION); + assertThat(ViewAttributes.Type.fromQualifier(ComponentQualifiers.VIEW)).isEqualTo(PORTFOLIO); + assertThat(ViewAttributes.Type.fromQualifier(ComponentQualifiers.APP)).isEqualTo(APPLICATION); } @Test public void fail_if_unknown_view_qualifier() { - assertThatThrownBy(() -> ViewAttributes.Type.fromQualifier(Qualifiers.PROJECT)) + assertThatThrownBy(() -> ViewAttributes.Type.fromQualifier(ComponentQualifiers.PROJECT)) .isInstanceOf(IllegalStateException.class) .hasMessage("Qualifier 'TRK' is not supported"); } diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java index a462fe431f0..7c15abdeeae 100644 --- a/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java +++ b/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java @@ -29,7 +29,7 @@ import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonar.api.notifications.Notification; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.ce.task.CeTask; import org.sonar.ce.task.CeTaskResult; @@ -146,7 +146,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT { @Test public void onEnd_fails_with_ISE_if_branch_does_not_exist_in_DB() { String componentUuid = secure().nextAlphanumeric(6); - ProjectDto project = new ProjectDto().setUuid(componentUuid).setKey(secure().nextAlphanumeric(5)).setQualifier(Qualifiers.PROJECT).setCreationMethod(CreationMethod.LOCAL_API); + ProjectDto project = new ProjectDto().setUuid(componentUuid).setKey(secure().nextAlphanumeric(5)).setQualifier(ComponentQualifiers.PROJECT).setCreationMethod(CreationMethod.LOCAL_API); dbTester.getDbClient().projectDao().insert(dbTester.getSession(), project); dbTester.getSession().commit(); when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT); diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 64bd491940b..177eb1fb7cd 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -29,7 +29,7 @@ import org.sonar.api.SonarQubeSide; import org.sonar.api.config.EmailSettings; import org.sonar.api.internal.MetadataLoader; import org.sonar.api.internal.SonarRuntimeImpl; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.profile.BuiltInQualityProfileAnnotationLoader; import org.sonar.api.server.rule.RulesDefinitionXmlLoader; import org.sonar.api.utils.Durations; @@ -60,7 +60,7 @@ import org.sonar.ce.task.projectanalysis.taskprocessor.AuditPurgeTaskModule; import org.sonar.ce.task.projectanalysis.taskprocessor.IssueSyncTaskModule; import org.sonar.ce.taskprocessor.CeProcessingScheduler; import org.sonar.ce.taskprocessor.CeTaskProcessorModule; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.core.documentation.DefaultDocumentationLinkGenerator; import org.sonar.core.extension.CoreExtensionRepositoryImpl; @@ -350,8 +350,8 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { private static void populateLevel4(Container container, Props props) { container.add( RuleDescriptionFormatter.class, - ResourceTypes.class, - DefaultResourceTypes.get(), + ComponentTypes.class, + DefaultComponentTypes.get(), // quality profile ActiveRuleIndexer.class, diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListener.java b/server/sonar-ce/src/main/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListener.java index b00f856f1cd..1373bb08d44 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListener.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListener.java @@ -21,7 +21,7 @@ package org.sonar.ce.notification; import java.time.Duration; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.ce.task.CeTask; import org.sonar.ce.task.CeTaskResult; @@ -97,7 +97,7 @@ public class ReportAnalysisFailureNotificationExecutionListener implements CeWor */ private static void checkQualifier(ProjectDto projectDto) { String qualifier = projectDto.getQualifier(); - checkArgument(qualifier.equals(Qualifiers.PROJECT), "Component %s must be a project (qualifier=%s)", projectDto.getUuid(), qualifier); + checkArgument(qualifier.equals(ComponentQualifiers.PROJECT), "Component %s must be a project (qualifier=%s)", projectDto.getUuid(), qualifier); } private ReportAnalysisFailureNotificationBuilder buildNotification(CeActivityDto ceActivityDto, ProjectDto projectDto, BranchDto branchDto, diff --git a/server/sonar-db-dao/build.gradle b/server/sonar-db-dao/build.gradle index 85c4221c4d2..e2785bd783d 100644 --- a/server/sonar-db-dao/build.gradle +++ b/server/sonar-db-dao/build.gradle @@ -44,7 +44,7 @@ dependencies { testFixturesApi 'org.junit.jupiter:junit-jupiter-api' testFixturesApi testFixtures(project(':server:sonar-db-core')) - testFixturesApi testFixtures(project(':server:sonar-db-migration')) + testFixturesApi testFixtures(project(':server:sonar-db-migration')) testFixturesImplementation 'com.h2database:h2' diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java index 3d43a6e6810..9da57afcc8c 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ComponentDaoIT.java @@ -37,8 +37,6 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -72,10 +70,10 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.sonar.api.issue.Issue.STATUS_CLOSED; import static org.sonar.api.issue.Issue.STATUS_CONFIRMED; import static org.sonar.api.issue.Issue.STATUS_OPEN; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.utils.DateUtils.parseDate; import static org.sonar.db.Pagination.forPage; import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; @@ -830,8 +828,8 @@ class ComponentDaoIT { static Object[][] portfolioOrApplicationRootViewQualifier() { return new Object[][]{ - {Qualifiers.VIEW}, - {Qualifiers.APP}, + {ComponentQualifiers.VIEW}, + {ComponentQualifiers.APP}, }; } @@ -850,7 +848,7 @@ class ComponentDaoIT { private ComponentDto insertView(String rootViewQualifier, Consumer dtoPopulators) { ComponentDbTester tester = db.components(); - if (rootViewQualifier.equals(Qualifiers.VIEW)) { + if (rootViewQualifier.equals(ComponentQualifiers.VIEW)) { return random.nextBoolean() ? tester.insertPublicPortfolio(dtoPopulators) : tester.insertPrivatePortfolio(dtoPopulators); } return random.nextBoolean() ? tester.insertPublicApplication(dtoPopulators).getMainBranchComponent() : @@ -945,7 +943,7 @@ class ComponentDaoIT { assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, "XXX").build(), forPage(1).andSize(10))) .extracting(ComponentDto::uuid) .containsOnly(provisionedProject.uuid()); - assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build(), forPage(1).andSize(10))) + assertThat(underTest.selectByQuery(dbSession, query.get().setQualifiers(PROJECT, ComponentQualifiers.VIEW).build(), forPage(1).andSize(10))) .extracting(ComponentDto::uuid) .containsOnly(provisionedProject.uuid(), provisionedPortfolio.uuid()); @@ -1026,8 +1024,8 @@ class ComponentDaoIT { Supplier query = () -> ComponentQuery.builder().setOnProvisionedOnly(true); assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT).build())).isOne(); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(Qualifiers.VIEW).build())).isZero(); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isOne(); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(ComponentQualifiers.VIEW).build())).isZero(); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, ComponentQualifiers.VIEW).build())).isOne(); } @Test @@ -1537,7 +1535,7 @@ class ComponentDaoIT { assertThat(children).extracting("uuid").containsOnly(FILE_1_UUID, DIR_UUID); // test children of root, filtered by qualifier - query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(Qualifiers.DIRECTORY)).build(); + query = newTreeQuery(PROJECT_UUID).setQualifiers(asList(ComponentQualifiers.DIRECTORY)).build(); children = underTest.selectDescendants(dbSession, query); assertThat(children).extracting("uuid").containsOnly(DIR_UUID); @@ -1582,11 +1580,11 @@ class ComponentDaoIT { assertThat(underTest.selectDescendants(dbSession, query)).isEmpty(); // test filtering by scope - query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.FILE)).build(); + query = newTreeQuery(project.uuid()).setScopes(asList(ComponentScopes.FILE)).build(); assertThat(underTest.selectDescendants(dbSession, query)) .extracting(ComponentDto::uuid) .containsExactlyInAnyOrder(fileInProject.uuid()); - query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.DIRECTORY)).build(); + query = newTreeQuery(project.uuid()).setScopes(asList(ComponentScopes.DIRECTORY)).build(); assertThat(underTest.selectDescendants(dbSession, query)) .extracting(ComponentDto::uuid) .containsExactlyInAnyOrder(dir.uuid()); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java index 9a509e8da57..32b04d67c27 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/component/ScrollForFileMoveComponentDaoIT.java @@ -40,8 +40,8 @@ import org.sonar.db.source.FileSourceDto; import static org.apache.commons.lang3.RandomStringUtils.secure; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; class ScrollForFileMoveComponentDaoIT { @RegisterExtension diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java index ed11ebf9183..86d14f5e0f8 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java @@ -30,7 +30,7 @@ import org.apache.ibatis.session.ResultHandler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -455,13 +455,13 @@ class MeasureDaoIT { newMeasureForMetrics(branch1, metric1, metric2); ComponentDto file = db.components().insertComponent(newFileDto(branch1)); - ComponentDto uts = db.components().insertComponent(newFileDto(branch1).setQualifier(Qualifiers.UNIT_TEST_FILE)); + ComponentDto uts = db.components().insertComponent(newFileDto(branch1).setQualifier(ComponentQualifiers.UNIT_TEST_FILE)); MeasureDto measureOnFile11 = newMeasureForMetrics(file, metric1, metric2); newMeasureForMetrics(uts, metric1, metric2); underTest.selectTreeByQuery(db.getSession(), branch1, MeasureTreeQuery.builder() - .setQualifiers(Collections.singletonList(Qualifiers.FILE)) + .setQualifiers(Collections.singletonList(ComponentQualifiers.FILE)) .setStrategy(MeasureTreeQuery.Strategy.LEAVES).build(), context -> results.add(context.getResultObject())); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java index 3befb795478..2ebe14fa96c 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/project/ProjectDaoIT.java @@ -35,7 +35,7 @@ import org.assertj.core.groups.Tuple; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.Pagination; @@ -434,7 +434,7 @@ class ProjectDaoIT { return new ProjectDto() .setName("projectName_" + name) .setKey("projectKee_" + org + "_" + name) - .setQualifier(Qualifiers.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setUuid("uuid_" + org + "_" + name) .setTags(Arrays.asList("tag1", "tag2")) .setDescription("desc_" + name) diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java index b136fd44817..67da5d6523a 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoIT.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -1049,7 +1049,7 @@ class PropertiesDaoIT { private void insertProperties(@Nullable String userLogin, @Nullable String projectKey, @Nullable String projectName, PropertyDto... properties) { for (PropertyDto propertyDto : properties) { - underTest.saveProperty(session, propertyDto, userLogin, projectKey, projectName, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, userLogin, projectKey, projectName, ComponentQualifiers.PROJECT); } session.commit(); } @@ -1062,7 +1062,7 @@ class PropertiesDaoIT { .setUserUuid(userUuid) .setValue(value); boolean isNew = session.getMapper(PropertiesMapper.class).selectByKey(dto) == null; - db.properties().insertProperty(dto, projectKey, projectName, Qualifiers.PROJECT, userLogin); + db.properties().insertProperty(dto, projectKey, projectName, ComponentQualifiers.PROJECT, userLogin); if (isNew) { verify(auditPersister).addProperty(any(), any(), anyBoolean()); } else { diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java index abf98c6f220..c3fd3e5b843 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/property/PropertiesDaoWithPersisterIT.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.ArgumentCaptor; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -102,7 +102,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -121,7 +121,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, "app-key", "app-name", Qualifiers.APP); + underTest.saveProperty(session, propertyDto, USER_LOGIN, "app-key", "app-name", ComponentQualifiers.APP); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -141,7 +141,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, "portfolio-key", "portfolio-name", Qualifiers.VIEW); + underTest.saveProperty(session, propertyDto, USER_LOGIN, "portfolio-key", "portfolio-name", ComponentQualifiers.VIEW); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -161,7 +161,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(SECURED_KEY)).thenReturn(true); PropertyDto propertyDto = getPropertyDto(SECURED_KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).addProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -180,7 +180,7 @@ class PropertiesDaoWithPersisterIT { when(auditPersister.isTrackedProperty(KEY)).thenReturn(true); PropertyQuery query = getPropertyQuery(KEY); PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.saveProperty(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); underTest.deleteByQuery(session, query); @@ -211,7 +211,7 @@ class PropertiesDaoWithPersisterIT { PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); underTest.saveProperty(session, propertyDto, USER_LOGIN, null, null, null); - underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verify(auditPersister).deleteProperty(any(), newValueCaptor.capture(), eq(false)); PropertyNewValue newValue = newValueCaptor.getValue(); @@ -229,7 +229,7 @@ class PropertiesDaoWithPersisterIT { void deleteTrackedPropertyWithoutAffectedRowsIsNotPersisted() { PropertyDto propertyDto = getPropertyDto(KEY, PROJECT_UUID, USER_UUID); - underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, Qualifiers.PROJECT); + underTest.delete(session, propertyDto, USER_LOGIN, PROJECT_KEY, PROJECT_NAME, ComponentQualifiers.PROJECT); verifyNoInteractions(auditPersister); } diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java index 506c3dfe4ee..4ed444fa907 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java @@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.slf4j.event.Level; import org.sonar.api.issue.Issue; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogAndArguments; import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.api.utils.System2; @@ -396,7 +396,7 @@ project.getProjectDto().getUuid()), PurgeListener.EMPTY, new PurgeProfiler()); ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); logTester.setLevel(Level.DEBUG); - underTest.deleteProject(db.getSession(), project.uuid(), Qualifiers.PROJECT, project.name(), project.getKey()); + underTest.deleteProject(db.getSession(), project.uuid(), ComponentQualifiers.PROJECT, project.name(), project.getKey()); assertThat(logTester.getLogs(LoggerLevel.DEBUG).stream() .map(LogAndArguments::getFormattedMsg) @@ -409,7 +409,7 @@ project.getProjectDto().getUuid()), PurgeListener.EMPTY, new PurgeProfiler()); ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); logTester.setLevel(Level.INFO); - underTest.deleteProject(db.getSession(), project.uuid(), Qualifiers.PROJECT, project.name(), project.getKey()); + underTest.deleteProject(db.getSession(), project.uuid(), ComponentQualifiers.PROJECT, project.name(), project.getKey()); assertThat(logTester.getLogs(LoggerLevel.DEBUG).stream() .map(LogAndArguments::getFormattedMsg) @@ -1611,7 +1611,7 @@ project.getProjectDto().getKey()); dbClient.scannerAnalysisCacheDao().insert(dbSession, branch.getUuid(), IOUtils.toInputStream("test1", UTF_8)); dbClient.scannerAnalysisCacheDao().insert(dbSession, project.getUuid(), IOUtils.toInputStream("test2", UTF_8)); - underTest.deleteProject(dbSession, project.getUuid(), Qualifiers.PROJECT, "project", "project"); + underTest.deleteProject(dbSession, project.getUuid(), ComponentQualifiers.PROJECT, "project", "project"); assertThat(dbClient.scannerAnalysisCacheDao().selectData(dbSession, project.getUuid())).isNull(); assertThat(dbClient.scannerAnalysisCacheDao().selectData(dbSession, branch.getUuid())).isNull(); diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java index 5c88f46f074..bc325265a3e 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/user/RoleDaoIT.java @@ -25,7 +25,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.Uuids; @@ -40,7 +40,7 @@ import static org.sonar.db.permission.GlobalPermission.ADMINISTER; class RoleDaoIT { - private static final Set PROJECT_QUALIFIER = Set.of(Qualifiers.PROJECT); + private static final Set PROJECT_QUALIFIER = Set.of(ComponentQualifiers.PROJECT); @RegisterExtension private final DbTester db = DbTester.create(System2.INSTANCE); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/NewValue.java b/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/NewValue.java index 58a061ff295..ae5908aa0f5 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/NewValue.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/NewValue.java @@ -23,9 +23,9 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import static com.google.common.base.Strings.isNullOrEmpty; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; public abstract class NewValue { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index 662e570945e..437961a5470 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -31,7 +31,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; import org.apache.ibatis.session.ResultHandler; -import org.sonar.api.resources.Qualifiers; import org.sonar.db.Dao; import org.sonar.db.DbSession; import org.sonar.db.Pagination; @@ -221,7 +220,7 @@ public class ComponentDao implements Dao { SELECT ALL */ public List selectAllViewsAndSubViews(DbSession session) { - return mapper(session).selectUuidsForQualifiers(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW); + return mapper(session).selectUuidsForQualifiers(ComponentQualifiers.APP, ComponentQualifiers.VIEW, ComponentQualifiers.SUBVIEW); } /** diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java index ef0ce834b1c..97dd10528ba 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java @@ -27,7 +27,6 @@ import java.util.Objects; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.sonar.api.resources.Scopes; import org.sonar.db.WildcardPosition; import static com.google.common.base.Preconditions.checkArgument; @@ -255,7 +254,7 @@ public class ComponentDto { } public boolean isRootProject() { - return uuid.equals(branchUuid) && Scopes.PROJECT.equals(scope); + return uuid.equals(branchUuid) && ComponentScopes.PROJECT.equals(scope); } public boolean isPrivate() { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java index cd424269410..228eea03ee7 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java @@ -26,8 +26,6 @@ import java.util.List; import java.util.function.BiConsumer; import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; import org.sonar.db.Dao; import org.sonar.db.DbSession; import org.sonar.db.audit.AuditPersister; @@ -81,7 +79,8 @@ public class ComponentKeyUpdaterDao implements Dao { resource.setDeprecatedKey(newResourceDeprecatedKey); } mapper.updateComponent(resource); - if (resource.getScope().equals(Scopes.PROJECT) && (resource.getQualifier().equals(Qualifiers.PROJECT) || resource.getQualifier().equals(Qualifiers.APP))) { + if (resource.getScope().equals(ComponentScopes.PROJECT) + && (resource.getQualifier().equals(ComponentQualifiers.PROJECT) || resource.getQualifier().equals(ComponentQualifiers.APP))) { auditPersister.componentKeyUpdate(dbSession, new ComponentKeyNewValue(resource.getUuid(), oldResourceKey, newResourceKey), resource.getQualifier()); mapper.updateProject(oldResourceKey, newResourceKey); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentQualifiers.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentQualifiers.java new file mode 100644 index 00000000000..680da96fd68 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentQualifiers.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.db.component; + +public final class ComponentQualifiers { + public static final String VIEW = "VW"; + public static final String SUBVIEW = "SVW"; + public static final String APP = "APP"; + public static final String PROJECT = "TRK"; + /** @deprecated */ + @Deprecated(since = "10.8", forRemoval = true) + public static final String MODULE = "BRC"; + public static final String DIRECTORY = "DIR"; + public static final String FILE = "FIL"; + public static final String UNIT_TEST_FILE = "UTS"; + + private ComponentQualifiers() { + } +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentScopes.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentScopes.java new file mode 100644 index 00000000000..ea5ef10f446 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentScopes.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.db.component; + +public final class ComponentScopes { + public static final String PROJECT = "PRJ"; + public static final String DIRECTORY = "DIR"; + public static final String FILE = "FIL"; + + private ComponentScopes() { + } + +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/entity/EntityDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/entity/EntityDto.java index f46359010e2..aee72679499 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/entity/EntityDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/entity/EntityDto.java @@ -21,7 +21,7 @@ package org.sonar.db.entity; import java.util.Objects; import javax.annotation.CheckForNull; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; /** * Represents a project, an application, a portfolio or a sub-portfolio. @@ -40,7 +40,7 @@ public class EntityDto { protected String authUuid; public String getAuthUuid() { - if (Qualifiers.SUBVIEW.equals(qualifier)) { + if (ComponentQualifiers.SUBVIEW.equals(qualifier)) { return authUuid; } return uuid; @@ -79,15 +79,15 @@ public class EntityDto { } public boolean isPortfolio() { - return Qualifiers.VIEW.equals(qualifier) || Qualifiers.SUBVIEW.equals(qualifier); + return ComponentQualifiers.VIEW.equals(qualifier) || ComponentQualifiers.SUBVIEW.equals(qualifier); } public boolean isProject() { - return Qualifiers.PROJECT.equals(qualifier); + return ComponentQualifiers.PROJECT.equals(qualifier); } public boolean isProjectOrApp() { - return Qualifiers.APP.equals(qualifier) || isProject(); + return ComponentQualifiers.APP.equals(qualifier) || isProject(); } @Override diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java index 76e6a7b551c..45163fecb06 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java @@ -27,7 +27,7 @@ import java.util.function.Function; import java.util.stream.Stream; import org.sonar.api.issue.Issue; import org.sonar.api.issue.impact.SoftwareQuality; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rule.Severity; import org.sonar.core.util.UuidFactoryFast; import org.sonar.core.util.Uuids; @@ -48,7 +48,7 @@ public class IssueTesting { } public static IssueDto newIssue(RuleDto rule, ComponentDto branch, ComponentDto file) { - checkArgument(branch.qualifier().equals(Qualifiers.PROJECT), "Second parameter should be a branch that belongs to a project"); + checkArgument(branch.qualifier().equals(ComponentQualifiers.PROJECT), "Second parameter should be a branch that belongs to a project"); return newIssue(rule, branch.uuid(), branch.getKey(), file); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java index fdff5b8d027..711aa311bcf 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java @@ -37,7 +37,7 @@ import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.core.metric.SoftwareQualitiesMetrics; import org.sonar.core.util.CloseableIterator; import org.sonar.db.DatabaseUtils; @@ -200,8 +200,8 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator map = new HashMap<>(); map.put("UUID", uuid); @@ -136,7 +134,6 @@ class FixDifferentUuidsForSubportfoliosIT { map.put("CREATED_AT", System.currentTimeMillis()); map.put("UPDATED_AT", System.currentTimeMillis()); - db.executeInsert("portfolios", map); return uuid; } diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/component/index/EntityDefinitionIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/component/index/EntityDefinitionIndexerIT.java index 384bdd99ad8..274563eda4d 100644 --- a/server/sonar-server-common/src/it/java/org/sonar/server/component/index/EntityDefinitionIndexerIT.java +++ b/server/sonar-server-common/src/it/java/org/sonar/server/component/index/EntityDefinitionIndexerIT.java @@ -43,7 +43,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME; import static org.sonar.server.component.index.ComponentIndexDefinition.TYPE_COMPONENT; import static org.sonar.server.es.Indexers.EntityEvent.CREATION; diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java index 76897cb5743..2bf01c9a5f8 100644 --- a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java +++ b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java @@ -38,7 +38,7 @@ import org.mockito.Mockito; import org.slf4j.event.Level; import org.sonar.api.issue.impact.Severity; import org.sonar.api.issue.impact.SoftwareQuality; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbSession; @@ -152,8 +152,8 @@ public class IssueIndexerIT { assertThat(scope.getIndexType().getType()).isEqualTo(TYPE_AUTHORIZATION); Predicate projectPredicate = scope.getEntityPredicate(); - IndexPermissions project = new IndexPermissions("P1", Qualifiers.PROJECT); - IndexPermissions file = new IndexPermissions("F1", Qualifiers.FILE); + IndexPermissions project = new IndexPermissions("P1", ComponentQualifiers.PROJECT); + IndexPermissions file = new IndexPermissions("F1", ComponentQualifiers.FILE); assertThat(projectPredicate.test(project)).isTrue(); assertThat(projectPredicate.test(file)).isFalse(); } diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/measure/index/ProjectMeasuresIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/measure/index/ProjectMeasuresIndexerIT.java index 862a0cae918..14f06724628 100644 --- a/server/sonar-server-common/src/it/java/org/sonar/server/measure/index/ProjectMeasuresIndexerIT.java +++ b/server/sonar-server-common/src/it/java/org/sonar/server/measure/index/ProjectMeasuresIndexerIT.java @@ -35,7 +35,7 @@ import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -95,9 +95,9 @@ public class ProjectMeasuresIndexerIT { assertThat(scope.getIndexType().getType()).isEqualTo(TYPE_AUTHORIZATION); Predicate projectPredicate = scope.getEntityPredicate(); - IndexPermissions project = new IndexPermissions("P1", Qualifiers.PROJECT); - IndexPermissions app = new IndexPermissions("P1", Qualifiers.APP); - IndexPermissions file = new IndexPermissions("F1", Qualifiers.FILE); + IndexPermissions project = new IndexPermissions("P1", ComponentQualifiers.PROJECT); + IndexPermissions app = new IndexPermissions("P1", ComponentQualifiers.APP); + IndexPermissions file = new IndexPermissions("F1", ComponentQualifiers.FILE); assertThat(projectPredicate.test(project)).isTrue(); assertThat(projectPredicate.test(app)).isTrue(); assertThat(projectPredicate.test(file)).isFalse(); @@ -286,7 +286,7 @@ public class ProjectMeasuresIndexerIT { indexProject(project, CREATION); assertThatIndexContainsOnly(project); - db.getDbClient().purgeDao().deleteProject(db.getSession(), project.getUuid(), Qualifiers.PROJECT, project.getName(), project.getKey()); + db.getDbClient().purgeDao().deleteProject(db.getSession(), project.getUuid(), ComponentQualifiers.PROJECT, project.getName(), project.getKey()); IndexingResult result = indexProject(project, DELETION); assertThat(es.countDocuments(TYPE_PROJECT_MEASURES)).isZero(); diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/view/index/ViewIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/view/index/ViewIndexerIT.java index b78c16b1227..211ab95d34d 100644 --- a/server/sonar-server-common/src/it/java/org/sonar/server/view/index/ViewIndexerIT.java +++ b/server/sonar-server-common/src/it/java/org/sonar/server/view/index/ViewIndexerIT.java @@ -39,7 +39,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptySet; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.api.resources.Qualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.db.component.ComponentTesting.newProjectCopy; import static org.sonar.db.component.ComponentTesting.newSubPortfolio; import static org.sonar.server.view.index.ViewIndexDefinition.TYPE_VIEW; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentType.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentType.java new file mode 100644 index 00000000000..48560e819eb --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentType.java @@ -0,0 +1,206 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; +import static org.apache.commons.lang3.StringUtils.isEmpty; + +/** + *

Extension to declare custom types of components. + *

+ * ComponentType object can declare properties that give information about the capabilities of the + * component type. Those properties may be used, of instance, to adapt the Web UI according to the type of + * the resource being displayed. + *
+ * Currently, the following properties can be defined: + *

    + *
  • "deletable": if set to "true", then this resource can be deleted/purged.
  • + *
  • "supportsMeasureFilters": if set to "true", then this resource can be displayed in measure filters
  • + *
  • "modifiable_history": if set to "true", then the history of this resource may be modified (deletion of snapshots, modification of events, ...)
  • + *
  • "updatable_key" (since 3.2): if set to "true", then it is possible to update the key of this resource
  • + *
  • "supportsGlobalDashboards" (since 3.2): if true, this resource can be displayed in global dashboards
  • + *
  • "hasRolePolicy" : if true, roles configuration is available in sidebar
  • + *
  • "comparable" (since 3.4) : if true, the resource can be compared to other resources
  • + *
  • "configurable" (since 3.6) : if true, the settings page can be displayed on the resource
  • + *
+ */ +public class ComponentType { + + private final String qualifier; + private final String iconPath; + private final boolean hasSourceCode; + private final Map properties; + + private ComponentType(Builder builder) { + this.qualifier = builder.qualifier; + this.iconPath = builder.iconPath; + this.hasSourceCode = builder.hasSourceCode; + this.properties = new HashMap<>(builder.properties); + } + + /** + * Qualifier is the unique key. + * + * @return the qualifier + */ + public String getQualifier() { + return qualifier; + } + + /** + * Returns the relative path of the icon used to represent the resource type + * + * @return the relative path. + */ + public String getIconPath() { + return iconPath; + } + + /** + * Tells whether resources of this type has source code or not. + * + * @return true if the type has source code + */ + public boolean hasSourceCode() { + return hasSourceCode; + } + + public boolean hasProperty(String key) { + requireNonNull(key); + return properties.containsKey(key); + } + + /** + * Returns the value of the property for this resource type. + * + * @return the String value of the property, or NULL if the property hasn't been set. + */ + public String getStringProperty(String key) { + requireNonNull(key); + return properties.get(key); + } + + /** + * Returns the value of the property for this resource type. + * + * @return the Boolean value of the property. If the property hasn't been set, False is returned. + */ + public boolean getBooleanProperty(String key) { + requireNonNull(key); + String value = properties.get(key); + return value != null && Boolean.parseBoolean(value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ComponentType that = (ComponentType) o; + return qualifier.equals(that.qualifier); + } + + @Override + public int hashCode() { + return qualifier.hashCode(); + } + + @Override + public String toString() { + return qualifier; + } + + /** + * Creates a new {@link Builder} + */ + public static Builder builder(String qualifier) { + requireNonNull(qualifier); + checkArgument(qualifier.length() <= 10, "Qualifier is limited to 10 characters"); + return new Builder(qualifier); + } + + /** + * Builder used to create {@link ComponentType} objects. + */ + public static class Builder { + private final String qualifier; + private String iconPath; + private boolean hasSourceCode = false; + private final Map properties = new HashMap<>(); + + /** + * Creates a new {@link Builder} + */ + public Builder(String qualifier) { + this.qualifier = qualifier; + } + + /** + * Relative path of the icon used to represent the resource type. + * + * @param iconPath path to icon, relative to context of web-application (e.g. "/images/q/DIR.png") + */ + public Builder setIconPath(@Nullable String iconPath) { + this.iconPath = iconPath; + return this; + } + + /** + * Tells that the resources of this type will have source code. + */ + public Builder hasSourceCode() { + this.hasSourceCode = true; + return this; + } + + /** + * Sets a property on the resource type. See the description of {@link ComponentType} class for more information. + */ + public Builder setProperty(String key, String value) { + requireNonNull(key); + requireNonNull(value); + properties.put(key, value); + return this; + } + + public Builder setProperty(String key, boolean value) { + return setProperty(key, String.valueOf(value)); + } + + /** + * Creates an instance of {@link ComponentType} based on all information given to the builder. + */ + public ComponentType build() { + if (isEmpty(iconPath)) { + iconPath = "/images/q/" + qualifier + ".png"; + } + return new ComponentType(this); + } + } +} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypeTree.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypeTree.java new file mode 100644 index 00000000000..a29db7f0eb6 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypeTree.java @@ -0,0 +1,115 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.server.ServerSide; + +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +@ServerSide +@ComputeEngineSide +public class ComponentTypeTree { + + private final List types; + private final Map> relations; + private final ComponentType root; + + private ComponentTypeTree(Builder builder) { + this.types = unmodifiableList(new ArrayList<>(builder.types)); + this.relations = Collections.unmodifiableMap(builder.relations); + this.root = builder.root; + } + + public List getTypes() { + return types; + } + + public List getChildren(String qualifier) { + return relations.getOrDefault(qualifier, Collections.emptyList()); + } + + public ComponentType getRootType() { + return root; + } + + public List getLeaves() { + return relations.values() + .stream() + .flatMap(Collection::stream) + .filter(qualifier -> !relations.containsKey(qualifier)) + .toList(); + } + + @Override + public String toString() { + return root.getQualifier(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private final List types = new ArrayList<>(); + private final Map> relations = new HashMap<>(); + private final List children = new ArrayList<>(); + private ComponentType root; + + private Builder() { + } + + public Builder addType(ComponentType type) { + requireNonNull(type); + checkArgument(!types.contains(type), String.format("%s is already registered", type.getQualifier())); + types.add(type); + return this; + } + + public Builder addRelations(String parentQualifier, String... childrenQualifiers) { + requireNonNull(parentQualifier); + requireNonNull(childrenQualifiers); + checkArgument(childrenQualifiers.length > 0, "childrenQualifiers can't be empty"); + relations.computeIfAbsent(parentQualifier, x -> new ArrayList<>()).addAll(Arrays.asList(childrenQualifiers)); + children.addAll(Arrays.asList(childrenQualifiers)); + return this; + } + + public ComponentTypeTree build() { + for (ComponentType type : types) { + if (!children.contains(type.getQualifier())) { + root = type; + break; + } + } + return new ComponentTypeTree(this); + } + } + +} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypes.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypes.java new file mode 100644 index 00000000000..174eb2f21f7 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/ComponentTypes.java @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.server.ServerSide; + +import static java.util.Collections.unmodifiableList; +import static java.util.Collections.unmodifiableMap; +import static java.util.Objects.requireNonNull; + +@ServerSide +@ComputeEngineSide +public class ComponentTypes { + + private final Map treeByQualifier; + private final Map typeByQualifier; + private final Collection rootTypes; + + public ComponentTypes(ComponentTypeTree[] trees) { + requireNonNull(trees); + + Map treeMap = new LinkedHashMap<>(); + Map typeMap = new LinkedHashMap<>(); + Collection rootsSet = new LinkedHashSet<>(); + + for (ComponentTypeTree tree : trees) { + rootsSet.add(tree.getRootType()); + for (ComponentType type : tree.getTypes()) { + if (treeMap.containsKey(type.getQualifier())) { + throw new IllegalStateException("Qualifier " + type.getQualifier() + " is defined in several trees"); + } + treeMap.put(type.getQualifier(), tree); + typeMap.put(type.getQualifier(), type); + } + } + treeByQualifier = unmodifiableMap(new LinkedHashMap<>(treeMap)); + typeByQualifier = unmodifiableMap(new LinkedHashMap<>(typeMap)); + rootTypes = unmodifiableList(new ArrayList<>(rootsSet)); + } + + public ComponentType get(String qualifier) { + ComponentType type = typeByQualifier.get(qualifier); + return type != null ? type : ComponentType.builder(qualifier).build(); + } + + public Collection getAll() { + return typeByQualifier.values(); + } + + public Collection getRoots() { + return rootTypes; + } + + public boolean isQualifierPresent(String qualifier) { + return typeByQualifier.get(qualifier) != null; + } + + public List getLeavesQualifiers(String qualifier) { + ComponentTypeTree tree = getTree(qualifier); + if (tree != null) { + return tree.getLeaves(); + } + return Collections.emptyList(); + } + + private ComponentTypeTree getTree(String qualifier) { + return treeByQualifier.get(qualifier); + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/DefaultComponentTypes.java similarity index 67% rename from sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java rename to server/sonar-server-common/src/main/java/org/sonar/server/component/DefaultComponentTypes.java index bcc1d1d4a15..e2eea720f74 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/DefaultComponentTypes.java @@ -17,31 +17,27 @@ * 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; +package org.sonar.server.component; import org.sonar.api.ce.ComputeEngineSide; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.scanner.ScannerSide; import org.sonar.api.server.ServerSide; +import org.sonar.db.component.ComponentQualifiers; -@ScannerSide @ServerSide @ComputeEngineSide -public final class DefaultResourceTypes { +public final class DefaultComponentTypes { private static final String CONFIGURABLE = "configurable"; private static final String UPDATABLE_KEY = "updatable_key"; public static final String IGNORED = "ignored"; - private DefaultResourceTypes() { + private DefaultComponentTypes() { // only static methods } - public static ResourceTypeTree get() { - return ResourceTypeTree.builder() - .addType(ResourceType.builder(Qualifiers.PROJECT) + public static ComponentTypeTree get() { + return ComponentTypeTree.builder() + .addType(ComponentType.builder(ComponentQualifiers.PROJECT) .setProperty("deletable", true) .setProperty("modifiable_history", true) .setProperty("hasRolePolicy", true) @@ -49,22 +45,22 @@ public final class DefaultResourceTypes { .setProperty("comparable", true) .setProperty(CONFIGURABLE, true) .build()) - .addType(ResourceType.builder(Qualifiers.MODULE) + .addType(ComponentType.builder(ComponentQualifiers.MODULE) .setProperty(UPDATABLE_KEY, true) .setProperty(CONFIGURABLE, true) .setProperty(IGNORED, true) .build()) - .addType(ResourceType.builder(Qualifiers.DIRECTORY) + .addType(ComponentType.builder(ComponentQualifiers.DIRECTORY) .build()) - .addType(ResourceType.builder(Qualifiers.FILE) + .addType(ComponentType.builder(ComponentQualifiers.FILE) .hasSourceCode() .build()) - .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE) + .addType(ComponentType.builder(ComponentQualifiers.UNIT_TEST_FILE) .hasSourceCode() .build()) - .addRelations(Qualifiers.PROJECT, Qualifiers.DIRECTORY) - .addRelations(Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE) + .addRelations(ComponentQualifiers.PROJECT, ComponentQualifiers.DIRECTORY) + .addRelations(ComponentQualifiers.DIRECTORY, ComponentQualifiers.FILE, ComponentQualifiers.UNIT_TEST_FILE) .build(); } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java index e971c5d313a..5d911d41d3a 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIndexer.java @@ -32,7 +32,7 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.BranchDto; @@ -80,7 +80,7 @@ public class IssueIndexer implements EventIndexer, AnalysisIndexer, NeedAuthoriz private static final String ID_TYPE_DELETE_PROJECT_UUID = "deleteProjectUuid"; private static final Logger LOGGER = LoggerFactory.getLogger(IssueIndexer.class); - private static final AuthorizationScope AUTHORIZATION_SCOPE = new AuthorizationScope(TYPE_ISSUE, entity -> Qualifiers.PROJECT.equals(entity.getQualifier())); + private static final AuthorizationScope AUTHORIZATION_SCOPE = new AuthorizationScope(TYPE_ISSUE, entity -> ComponentQualifiers.PROJECT.equals(entity.getQualifier())); private static final Set INDEX_TYPES = Set.of(TYPE_ISSUE); private final EsClient esClient; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java index 305d378e44c..ced84b1042e 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java @@ -31,8 +31,8 @@ import javax.annotation.Nullable; import org.apache.ibatis.cursor.Cursor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.rules.CleanCodeAttribute; import org.sonar.api.rules.RuleType; import org.sonar.api.server.rule.RulesDefinition.StigVersion; @@ -142,7 +142,7 @@ class IssueIteratorForSingleChunk implements IssueIterator { doc.setSonarSourceSecurityCategory(sqCategory); doc.setVulnerabilityProbability(sqCategory.getVulnerability()); - doc.setScope(Qualifiers.UNIT_TEST_FILE.equals(indexedIssueDto.getQualifier()) ? IssueScope.TEST : IssueScope.MAIN); + doc.setScope(ComponentQualifiers.UNIT_TEST_FILE.equals(indexedIssueDto.getQualifier()) ? IssueScope.TEST : IssueScope.MAIN); doc.setIsNewCodeReference(indexedIssueDto.isNewCodeReferenceIssue()); String codeVariants = indexedIssueDto.getCodeVariants(); doc.setCodeVariants(STRING_LIST_SPLITTER.splitToList(codeVariants == null ? "" : codeVariants)); @@ -154,7 +154,7 @@ class IssueIteratorForSingleChunk implements IssueIterator { @CheckForNull private static String extractDirPath(@Nullable String filePath, String scope) { if (filePath != null) { - if (Scopes.DIRECTORY.equals(scope)) { + if (ComponentScopes.DIRECTORY.equals(scope)) { return filePath; } int lastSlashIndex = CharMatcher.anyOf("/").lastIndexIn(filePath); @@ -172,7 +172,7 @@ class IssueIteratorForSingleChunk implements IssueIterator { // path // of files and directories. // That's why the file path should be null on modules and projects. - if (filePath != null && !Scopes.PROJECT.equals(scope)) { + if (filePath != null && !ComponentScopes.PROJECT.equals(scope)) { return filePath; } return null; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java index 6f5898c73c6..d57414dc24c 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java @@ -29,7 +29,7 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Nullable; import org.jetbrains.annotations.NotNull; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.BranchDto; @@ -60,7 +60,7 @@ import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.TYPE public class ProjectMeasuresIndexer implements EventIndexer, AnalysisIndexer, NeedAuthorizationIndexer { private static final AuthorizationScope AUTHORIZATION_SCOPE = new AuthorizationScope(TYPE_PROJECT_MEASURES, - entity -> Qualifiers.PROJECT.equals(entity.getQualifier()) || Qualifiers.APP.equals(entity.getQualifier())); + entity -> ComponentQualifiers.PROJECT.equals(entity.getQualifier()) || ComponentQualifiers.APP.equals(entity.getQualifier())); private static final Set INDEX_TYPES = Set.of(TYPE_PROJECT_MEASURES); private final DbClient dbClient; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java index 247f5495ba9..976d95db66d 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java @@ -24,8 +24,8 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.annotation.concurrent.Immutable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.web.UserRole; import org.sonar.db.permission.GlobalPermission; @@ -45,14 +45,14 @@ public class PermissionServiceImpl implements PermissionService { private final List globalPermissions; private final List projectPermissions; - public PermissionServiceImpl(ResourceTypes resourceTypes) { + public PermissionServiceImpl(ComponentTypes componentTypes) { globalPermissions = List.copyOf(ALL_GLOBAL_PERMISSIONS.stream() - .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.APP)) - .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.VIEW)) + .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR) || componentTypes.isQualifierPresent(ComponentQualifiers.APP)) + .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR) || componentTypes.isQualifierPresent(ComponentQualifiers.VIEW)) .toList()); projectPermissions = List.copyOf(ALL_PROJECT_PERMISSIONS.stream() - .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.APP)) - .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.VIEW)) + .filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR.getKey()) || componentTypes.isQualifierPresent(ComponentQualifiers.APP)) + .filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR.getKey()) || componentTypes.isQualifierPresent(ComponentQualifiers.VIEW)) .toList()); } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTest.java new file mode 100644 index 00000000000..734b7fcca02 --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTest.java @@ -0,0 +1,99 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ComponentTypeTest { + + @Test + public void shouldCreateWithDefaults() { + ComponentType def = ComponentType.builder("qualifier") + .build(); + assertThat(def.getQualifier()).isEqualTo("qualifier"); + assertThat(def.getIconPath()).isEqualTo("/images/q/qualifier.png"); + assertThat(def.hasSourceCode()).isFalse(); + } + + @Test + public void shouldCreate() { + ComponentType def = ComponentType.builder("qualifier") + .setIconPath("/custom-icon.png") + .hasSourceCode() + .setProperty("supportsMeasureFilters", "true") + .setProperty("anotherProperty", "foo") + .build(); + assertThat(def.getQualifier()).isEqualTo("qualifier"); + assertThat(def.getIconPath()).isEqualTo("/custom-icon.png"); + assertThat(def.hasSourceCode()).isTrue(); + assertThat(def.getStringProperty("anotherProperty")).isEqualTo("foo"); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldCheckQualifierLength() { + ComponentType.builder("qualifier bigger than 10 characters"); + } + + @Test + public void testEqualsAndHashCode() { + ComponentType foo1 = ComponentType.builder("FOO").build(); + ComponentType foo2 = ComponentType.builder("FOO").build(); + ComponentType bar = ComponentType.builder("BAR").build(); + + assertThat(foo1.equals(foo1)).isTrue(); + assertThat(foo1.equals(foo2)).isTrue(); + assertThat(foo1.equals(bar)).isFalse(); + + assertThat(foo1).hasSameHashCodeAs(foo1); + } + + @Test + public void getBooleanProperty_is_set() { + // set with boolean parameter + ComponentType def = ComponentType.builder("qualifier").setProperty("test", true).build(); + assertThat(def.getBooleanProperty("test")).isTrue(); + + def = ComponentType.builder("qualifier").setProperty("test", false).build(); + assertThat(def.getBooleanProperty("test")).isFalse(); + + def = ComponentType.builder("qualifier").setProperty("test", "true").build(); + assertThat(def.getBooleanProperty("test")).isTrue(); + + def = ComponentType.builder("qualifier").setProperty("test", "false").build(); + assertThat(def.getBooleanProperty("test")).isFalse(); + } + + @Test + public void getBooleanProperty_is_not_set() { + ComponentType def = ComponentType.builder("qualifier").build(); + assertThat(def.getBooleanProperty("test")).isFalse(); + } + + @Test + public void hasProperty() { + ComponentType def = ComponentType.builder("qualifier").build(); + assertThat(def.hasProperty("foo")).isFalse(); + + def = ComponentType.builder("qualifier").setProperty("foo", "bar").build(); + assertThat(def.hasProperty("foo")).isTrue(); + } +} diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTreeTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTreeTest.java new file mode 100644 index 00000000000..144ee8b4beb --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypeTreeTest.java @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.server.component.ComponentTypesTest.qualifiers; + +public class ComponentTypeTreeTest { + private final ComponentTypeTree tree = ComponentTypeTree.builder() + .addType(ComponentType.builder("TRK").build()) + .addType(ComponentType.builder("DIR").build()) + .addType(ComponentType.builder("FIL").build()) + .addType(ComponentType.builder("UTS").build()) + .addRelations("TRK", "DIR") + .addRelations("DIR", "FIL") + .addRelations("DIR", "UTS") + .build(); + + @Test + public void getTypes() { + assertThat(tree.getTypes()).hasSize(4); + assertThat(qualifiers(tree.getTypes())).containsOnly("TRK", "DIR", "FIL", "UTS"); + } + + @Test + public void getChildren() { + assertThat(tree.getChildren("TRK")).containsOnly("DIR"); + + assertThat(tree.getChildren("DIR")).containsOnly("FIL", "UTS"); + + assertThat(tree.getChildren("FIL")).isEmpty(); + } + + @Test + public void getRoot() { + assertThat(tree.getRootType()).isEqualTo(ComponentType.builder("TRK").build()); + } + + @Test + public void getLeaves() { + assertThat(tree.getLeaves()).containsOnly("FIL", "UTS"); + } + + @Test(expected = IllegalArgumentException.class) + public void forbidNullRelation() { + ComponentTypeTree.builder() + .addType(ComponentType.builder("TRK").build()) + .addType(ComponentType.builder("DIR").build()) + .addRelations("DIR" /* missing child */) + .build(); + } + + @Test(expected = IllegalArgumentException.class) + public void forbidDuplicatedType() { + ComponentTypeTree.builder() + .addType(ComponentType.builder("TRK").build()) + .addType(ComponentType.builder("TRK").build()) + .build(); + } +} diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypesTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypesTest.java new file mode 100644 index 00000000000..21f7ff6c8c3 --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/ComponentTypesTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.server.component; + +import com.google.common.collect.Collections2; +import java.util.Collection; +import org.junit.Test; +import org.sonar.db.component.ComponentQualifiers; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ComponentTypesTest { + + private ComponentTypeTree viewsTree = ComponentTypeTree.builder() + .addType(ComponentType.builder(ComponentQualifiers.VIEW).setProperty("supportsMeasureFilters", "true").build()) + .addType(ComponentType.builder(ComponentQualifiers.SUBVIEW).build()) + .addRelations(ComponentQualifiers.VIEW, ComponentQualifiers.SUBVIEW) + .addRelations(ComponentQualifiers.SUBVIEW, ComponentQualifiers.PROJECT) + .build(); + + private ComponentTypeTree applicationTree = ComponentTypeTree.builder() + .addType(ComponentType.builder(ComponentQualifiers.APP).setProperty("supportsMeasureFilters", "true").build()) + .addRelations(ComponentQualifiers.APP, ComponentQualifiers.PROJECT) + .build(); + + private ComponentTypeTree defaultTree = ComponentTypeTree.builder() + .addType(ComponentType.builder(ComponentQualifiers.PROJECT).setProperty("supportsMeasureFilters", "true").build()) + .addType(ComponentType.builder(ComponentQualifiers.DIRECTORY).build()) + .addType(ComponentType.builder(ComponentQualifiers.FILE).build()) + .addRelations(ComponentQualifiers.PROJECT, ComponentQualifiers.DIRECTORY) + .addRelations(ComponentQualifiers.DIRECTORY, ComponentQualifiers.FILE) + .build(); + + private ComponentTypes types = new ComponentTypes(new ComponentTypeTree[] {defaultTree, viewsTree, applicationTree}); + + @Test + public void get() { + assertThat(types.get(ComponentQualifiers.PROJECT).getQualifier()).isEqualTo(ComponentQualifiers.PROJECT); + + // does not return null + assertThat(types.get("xxx").getQualifier()).isEqualTo("xxx"); + } + + @Test + public void get_all() { + assertThat(qualifiers(types.getAll())).containsExactly(ComponentQualifiers.PROJECT, ComponentQualifiers.DIRECTORY, ComponentQualifiers.FILE, ComponentQualifiers.VIEW, ComponentQualifiers.SUBVIEW, ComponentQualifiers.APP); + } + + @Test + public void get_roots() { + assertThat(qualifiers(types.getRoots())).containsOnly(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW, ComponentQualifiers.APP); + } + + @Test + public void get_leaves_qualifiers() { + assertThat(types.getLeavesQualifiers(ComponentQualifiers.PROJECT)).containsExactly(ComponentQualifiers.FILE); + assertThat(types.getLeavesQualifiers(ComponentQualifiers.DIRECTORY)).containsExactly(ComponentQualifiers.FILE); + assertThat(types.getLeavesQualifiers(ComponentQualifiers.VIEW)).containsExactly(ComponentQualifiers.PROJECT); + assertThat(types.getLeavesQualifiers(ComponentQualifiers.APP)).containsExactly(ComponentQualifiers.PROJECT); + assertThat(types.getLeavesQualifiers("xxx")).isEmpty(); + } + + @Test(expected = IllegalStateException.class) + public void fail_on_duplicated_qualifier() { + ComponentTypeTree tree1 = ComponentTypeTree.builder() + .addType(ComponentType.builder("foo").build()) + .build(); + ComponentTypeTree tree2 = ComponentTypeTree.builder() + .addType(ComponentType.builder("foo").build()) + .build(); + + new ComponentTypes(new ComponentTypeTree[] {tree1, tree2}); + } + + @Test + public void isQualifierPresent() { + assertThat(types.isQualifierPresent(ComponentQualifiers.APP)).isTrue(); + assertThat(types.isQualifierPresent(ComponentQualifiers.VIEW)).isTrue(); + assertThat(types.isQualifierPresent("XXXX")).isFalse(); + } + + static Collection qualifiers(Collection types) { + return Collections2.transform(types, ComponentType::getQualifier); + } +} diff --git a/sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/DefaultComponentTypesTest.java similarity index 76% rename from sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java rename to server/sonar-server-common/src/test/java/org/sonar/server/component/DefaultComponentTypesTest.java index cfa542513ee..cfae180f073 100644 --- a/sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/DefaultComponentTypesTest.java @@ -17,20 +17,19 @@ * 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; +package org.sonar.server.component; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypeTree; +import org.sonar.db.component.ComponentQualifiers; import static org.assertj.core.api.Assertions.assertThat; -public class DefaultResourceTypesTest { +public class DefaultComponentTypesTest { @Test public void provide_types() { - ResourceTypeTree tree = DefaultResourceTypes.get(); + ComponentTypeTree tree = DefaultComponentTypes.get(); assertThat(tree.getTypes()).hasSize(5); - assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.DIRECTORY); + assertThat(tree.getChildren(ComponentQualifiers.PROJECT)).containsExactly(ComponentQualifiers.DIRECTORY); } } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java index e6d6993e974..011da0d7478 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/permission/PermissionServiceImplTest.java @@ -20,14 +20,14 @@ package org.sonar.server.permission; import org.junit.Test; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import static org.assertj.core.api.Assertions.assertThat; public class PermissionServiceImplTest { - private ResourceTypesRule resourceTypesRule = new ResourceTypesRule().setRootQualifiers("APP", "VW"); + private ComponentTypesRule resourceTypesRule = new ComponentTypesRule().setRootQualifiers("APP", "VW"); private PermissionServiceImpl underTest = new PermissionServiceImpl(resourceTypesRule); @Test diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoIT.java b/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoIT.java index b38bf7cc247..e7691869f3c 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoIT.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoIT.java @@ -45,9 +45,9 @@ import org.sonar.db.user.UserDto; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.web.UserRole.ADMIN; import static org.sonar.api.web.UserRole.USER; diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java index f8e061739c2..d69602373ec 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java @@ -42,7 +42,7 @@ import org.sonar.server.tester.UserSessionRule; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.api.web.UserRole.ADMIN; import static org.sonar.api.web.UserRole.USER; import static org.sonar.server.es.Indexers.EntityEvent.PERMISSION_CHANGE; diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ResourceTypesRule.java b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/component/ComponentTypesRule.java similarity index 54% rename from server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ResourceTypesRule.java rename to server/sonar-server-common/src/testFixtures/java/org/sonar/server/component/ComponentTypesRule.java index 648f83db35f..971a2f09afe 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ResourceTypesRule.java +++ b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/component/ComponentTypesRule.java @@ -17,7 +17,7 @@ * 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.db.component; +package org.sonar.server.component; import java.util.Arrays; import java.util.Collection; @@ -25,78 +25,75 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; -public class ResourceTypesRule extends ResourceTypes { - private Set allResourceTypes = emptySet(); - private Set rootResourceTypes = emptySet(); +public class ComponentTypesRule extends ComponentTypes { + private Set allComponentTypes = emptySet(); + private Set rootComponentTypes = emptySet(); private List leavesQualifiers = emptyList(); - public ResourceTypesRule() { - super(new ResourceTypeTree[0]); + public ComponentTypesRule() { + super(new ComponentTypeTree[0]); } @Override - public Collection getAll() { - return allResourceTypes; + public Collection getAll() { + return allComponentTypes; } @Override - public Collection getRoots() { - return rootResourceTypes; + public Collection getRoots() { + return rootComponentTypes; } - public ResourceTypesRule setRootQualifiers(Collection qualifiers) { - rootResourceTypes = Set.copyOf(qualifiers); + public ComponentTypesRule setRootQualifiers(Collection qualifiers) { + rootComponentTypes = Set.copyOf(qualifiers); return this; } - public ResourceTypesRule setRootQualifiers(String... qualifiers) { - Set resourceTypes = new LinkedHashSet<>(); + public ComponentTypesRule setRootQualifiers(String... qualifiers) { + Set componentTypes = new LinkedHashSet<>(); for (String qualifier : qualifiers) { - resourceTypes.add(ResourceType.builder(qualifier).setProperty("deletable", true).build()); + componentTypes.add(ComponentType.builder(qualifier).setProperty("deletable", true).build()); } - rootResourceTypes = Set.copyOf(resourceTypes); + rootComponentTypes = Set.copyOf(componentTypes); return this; } - public ResourceTypesRule setLeavesQualifiers(String... qualifiers) { + public ComponentTypesRule setLeavesQualifiers(String... qualifiers) { leavesQualifiers = List.copyOf(Arrays.asList(qualifiers)); return this; } - public ResourceTypesRule setAllQualifiers(String... qualifiers) { - Set resourceTypes = new HashSet<>(); + public ComponentTypesRule setAllQualifiers(String... qualifiers) { + Set componentTypes = new HashSet<>(); for (String qualifier : qualifiers) { - resourceTypes.add(ResourceType.builder(qualifier).setProperty("deletable", true).build()); + componentTypes.add(ComponentType.builder(qualifier).setProperty("deletable", true).build()); } - allResourceTypes = Set.copyOf(resourceTypes); + allComponentTypes = Set.copyOf(componentTypes); return this; } - public ResourceTypesRule setAllQualifiers(Collection qualifiers) { - allResourceTypes = Set.copyOf(qualifiers); + public ComponentTypesRule setAllQualifiers(Collection qualifiers) { + allComponentTypes = Set.copyOf(qualifiers); return this; } @Override - public ResourceType get(String qualifier) { - return allResourceTypes.stream() + public ComponentType get(String qualifier) { + return allComponentTypes.stream() .filter(resourceType -> qualifier.equals(resourceType.getQualifier())) .findAny().orElse(null); } @Override public boolean isQualifierPresent(String qualifier) { - return rootResourceTypes.stream() + return rootComponentTypes.stream() .anyMatch(resourceType -> qualifier.equals(resourceType.getQualifier())); } diff --git a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java index cecedee55b1..c9ea72ae780 100644 --- a/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java +++ b/server/sonar-server-common/src/testFixtures/java/org/sonar/server/issue/IssueDocTesting.java @@ -25,7 +25,7 @@ import java.time.ZoneOffset; import java.util.Date; import java.util.HashMap; import java.util.Random; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.core.util.Uuids; @@ -64,7 +64,7 @@ public class IssueDocTesting { .setComponentUuid(componentDto.uuid()) .setProjectUuid(projectUuid) // File path make no sens on modules and projects - .setFilePath(!componentDto.scope().equals(Scopes.PROJECT) ? componentDto.path() : null) + .setFilePath(!componentDto.scope().equals(ComponentScopes.PROJECT) ? componentDto.path() : null) .setIsMainBranch(isMainBranch) .setFuncCreationDate(Date.from(LocalDateTime.of(1970, 1, 1, 1, 1).toInstant(ZoneOffset.UTC))); } @@ -76,7 +76,7 @@ public class IssueDocTesting { .setComponentUuid(project.uuid()) .setProjectUuid(project.branchUuid()) // File path make no sens on modules and projects - .setFilePath(!project.scope().equals(Scopes.PROJECT) ? project.path() : null) + .setFilePath(!project.scope().equals(ComponentScopes.PROJECT) ? project.path() : null) .setIsMainBranch(true) .setFuncCreationDate(Date.from(LocalDateTime.of(1970, 1, 1, 1, 1).toInstant(ZoneOffset.UTC))); } diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java index a4ccfeef44d..aeb7a7264bd 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java @@ -34,7 +34,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.ResourceForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; -import static org.sonar.api.resources.Qualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.server.user.UserSession.IdentityProvider.SONARQUBE; public abstract class AbstractUserSession implements UserSession { diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java index 036529f7b91..d4c20ff8bc9 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java @@ -32,8 +32,8 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.BranchDto; @@ -49,8 +49,8 @@ import static java.util.Collections.singleton; import static java.util.Optional.of; import static java.util.Optional.ofNullable; import static java.util.stream.Collectors.toSet; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.web.UserRole.PUBLIC_PERMISSIONS; /** @@ -248,7 +248,7 @@ public class ServerUserSession extends AbstractUserSession { } private static boolean isTechnicalProject(ComponentDto componentDto) { - return Qualifiers.PROJECT.equals(componentDto.qualifier()) && Scopes.FILE.equals(componentDto.scope()); + return ComponentQualifiers.PROJECT.equals(componentDto.qualifier()) && ComponentScopes.FILE.equals(componentDto.scope()); } private static boolean isPortfolioOrSubPortfolio(ComponentDto componentDto) { @@ -283,8 +283,8 @@ public class ServerUserSession extends AbstractUserSession { Set projectBranchesUuid = dbClient.componentDao() .selectDescendants(dbSession, ComponentTreeQuery.builder() .setBaseUuid(branchDto.getUuid()) - .setQualifiers(singleton(Qualifiers.PROJECT)) - .setScopes(singleton(Scopes.FILE)) + .setQualifiers(singleton(ComponentQualifiers.PROJECT)) + .setScopes(singleton(ComponentScopes.FILE)) .setStrategy(Strategy.CHILDREN).build()) .stream() .map(ComponentDto::getCopyComponentUuid) @@ -301,7 +301,7 @@ public class ServerUserSession extends AbstractUserSession { try (DbSession dbSession = dbClient.openSession(false)) { return dbClient.componentDao().selectDescendants(dbSession, ComponentTreeQuery.builder() .setBaseUuid(portfolioUuid) - .setQualifiers(Arrays.asList(Qualifiers.PROJECT, Qualifiers.SUBVIEW)) + .setQualifiers(Arrays.asList(ComponentQualifiers.PROJECT, ComponentQualifiers.SUBVIEW)) .setStrategy(Strategy.CHILDREN).build()); } } @@ -324,7 +324,7 @@ public class ServerUserSession extends AbstractUserSession { hierarchyChildComponents.add(c); } - if (Qualifiers.SUBVIEW.equals(c.qualifier())) { + if (ComponentQualifiers.SUBVIEW.equals(c.qualifier())) { resolvePortfolioHierarchyComponents(c.uuid(), hierarchyChildComponents); } }); diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ThreadLocalUserSessionTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ThreadLocalUserSessionTest.java index 53c0269875c..f0766970b7d 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ThreadLocalUserSessionTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ThreadLocalUserSessionTest.java @@ -22,7 +22,7 @@ package org.sonar.server.user; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.component.ComponentDto; import org.sonar.db.entity.EntityDto; import org.sonar.db.project.ProjectDto; @@ -103,8 +103,8 @@ public class ThreadLocalUserSessionTest { public void checkEntityPermissionOrElseThrowResourceForbiddenException_returns_session_when_permission_to_entity() { MockUserSession expected = new MockUserSession("jean-michel"); - ProjectDto subProjectDto = new ProjectDto().setQualifier(Qualifiers.PROJECT).setUuid("subproject-uuid"); - ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("application-project-uuid"); + ProjectDto subProjectDto = new ProjectDto().setQualifier(ComponentQualifiers.PROJECT).setUuid("subproject-uuid"); + ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(ComponentQualifiers.APP).setUuid("application-project-uuid"); expected.registerProjects(subProjectDto); expected.registerApplication(applicationAsProjectDto, subProjectDto); @@ -133,8 +133,8 @@ public class ThreadLocalUserSessionTest { .setGroups(group); threadLocalUserSession.set(expected); - ComponentDto componentDto = new ComponentDto().setQualifier(Qualifiers.APP); - ProjectDto projectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("project-uuid"); + ComponentDto componentDto = new ComponentDto().setQualifier(ComponentQualifiers.APP); + ProjectDto projectDto = new ProjectDto().setQualifier(ComponentQualifiers.APP).setUuid("project-uuid"); assertThatThrownBy(() -> threadLocalUserSession.checkChildProjectsPermission(USER, componentDto)) .isInstanceOf(ForbiddenException.class); assertThatThrownBy(() -> threadLocalUserSession.checkChildProjectsPermission(USER, projectDto)) @@ -150,8 +150,8 @@ public class ThreadLocalUserSessionTest { .setLastSonarlintConnectionDate(1000L) .setGroups(group); - ProjectDto subProjectDto = new ProjectDto().setQualifier(Qualifiers.PROJECT).setUuid("subproject-uuid"); - ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(Qualifiers.APP).setUuid("application-project-uuid"); + ProjectDto subProjectDto = new ProjectDto().setQualifier(ComponentQualifiers.PROJECT).setUuid("subproject-uuid"); + ProjectDto applicationAsProjectDto = new ProjectDto().setQualifier(ComponentQualifiers.APP).setUuid("application-project-uuid"); expected.registerProjects(subProjectDto); expected.registerApplication(applicationAsProjectDto, subProjectDto); diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java index 3ac8d1490dc..03c0dea0122 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java @@ -26,8 +26,8 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.SequenceUuidFactory; @@ -37,7 +37,7 @@ import org.sonar.db.audit.AuditPersister; import org.sonar.db.component.BranchDto; import org.sonar.db.component.BranchType; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.CreationMethod; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; @@ -72,9 +72,9 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; public class ComponentUpdaterIT { @@ -110,7 +110,7 @@ public class ComponentUpdaterIT { new IndexersImpl(new PermissionIndexer(db.getDbClient(), es.client())), Set.of(new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()), new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory()))); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT)); private final ComponentUpdater underTest = new ComponentUpdater(db.getDbClient(), i18n, system2, permissionTemplateService, @@ -134,8 +134,8 @@ public class ComponentUpdaterIT { assertThat(loaded.getKey()).isEqualTo(DEFAULT_PROJECT_KEY); assertThat(loaded.name()).isEqualTo(DEFAULT_PROJECT_NAME); assertThat(loaded.longName()).isEqualTo(DEFAULT_PROJECT_NAME); - assertThat(loaded.qualifier()).isEqualTo(Qualifiers.PROJECT); - assertThat(loaded.scope()).isEqualTo(Scopes.PROJECT); + assertThat(loaded.qualifier()).isEqualTo(ComponentQualifiers.PROJECT); + assertThat(loaded.scope()).isEqualTo(ComponentScopes.PROJECT); assertThat(loaded.uuid()).isNotNull(); assertThat(loaded.branchUuid()).isEqualTo(loaded.uuid()); assertThat(loaded.isPrivate()).isEqualTo(PRIVATE_COMPONENT.isPrivate()); diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/DefaultTemplatesResolverImplIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/DefaultTemplatesResolverImplIT.java index 2a3716ab1af..0df5c81c8b1 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/DefaultTemplatesResolverImplIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/DefaultTemplatesResolverImplIT.java @@ -24,22 +24,22 @@ import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; public class DefaultTemplatesResolverImplIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private ResourceTypesRule resourceTypesWithPortfoliosInstalled = new ResourceTypesRule().setRootQualifiers(PROJECT, APP, VIEW); - private ResourceTypesRule resourceTypesWithApplicationInstalled = new ResourceTypesRule().setRootQualifiers(PROJECT, APP); - private ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); + private ComponentTypesRule resourceTypesWithPortfoliosInstalled = new ComponentTypesRule().setRootQualifiers(PROJECT, APP, VIEW); + private ComponentTypesRule resourceTypesWithApplicationInstalled = new ComponentTypesRule().setRootQualifiers(PROJECT, APP); + private ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); private DefaultTemplatesResolverImpl underTestWithPortfoliosInstalled = new DefaultTemplatesResolverImpl(db.getDbClient(), resourceTypesWithPortfoliosInstalled); private DefaultTemplatesResolverImpl underTestWithApplicationInstalled = new DefaultTemplatesResolverImpl(db.getDbClient(), resourceTypesWithApplicationInstalled); diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/GroupPermissionChangerIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/GroupPermissionChangerIT.java index 03e760bea6b..f33fa23f127 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/GroupPermissionChangerIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/GroupPermissionChangerIT.java @@ -24,23 +24,20 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.core.util.Uuids; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.permission.GroupPermissionDto; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; -import org.sonar.server.common.permission.GroupPermissionChange; -import org.sonar.server.common.permission.GroupPermissionChanger; -import org.sonar.server.common.permission.Operation; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.permission.PermissionService; import org.sonar.server.permission.PermissionServiceImpl; @@ -58,8 +55,8 @@ public class GroupPermissionChangerIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final GroupPermissionChanger underTest = new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory()); private GroupDto group; diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/PermissionTemplateServiceIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/PermissionTemplateServiceIT.java index d7095c13bcd..b275ea696a3 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/PermissionTemplateServiceIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/PermissionTemplateServiceIT.java @@ -29,7 +29,7 @@ import org.sonar.api.web.UserRole; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.permission.template.PermissionTemplateDbTester; import org.sonar.db.permission.template.PermissionTemplateDto; @@ -47,16 +47,16 @@ import org.sonar.server.tester.UserSessionRule; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; public class PermissionTemplateServiceIT { @Rule public DbTester dbTester = DbTester.create(); - private final ResourceTypesRule resourceTypesRule = new ResourceTypesRule().setRootQualifiers(PROJECT, VIEW, APP); + private final ComponentTypesRule resourceTypesRule = new ComponentTypesRule().setRootQualifiers(PROJECT, VIEW, APP); private final DefaultTemplatesResolver defaultTemplatesResolver = new DefaultTemplatesResolverImpl(dbTester.getDbClient(), resourceTypesRule); private final PermissionService permissionService = new PermissionServiceImpl(resourceTypesRule); private final UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/UserPermissionChangerIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/UserPermissionChangerIT.java index 479a28e81d4..ec722605fd7 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/UserPermissionChangerIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/permission/UserPermissionChangerIT.java @@ -24,14 +24,14 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.entity.EntityDto; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.user.GroupDto; @@ -52,8 +52,8 @@ public class UserPermissionChangerIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final UserPermissionChanger underTest = new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()); private UserDto user1; private UserDto user2; diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/ComponentUpdater.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/ComponentUpdater.java index e42e77a33e1..13d8d703b29 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/ComponentUpdater.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/ComponentUpdater.java @@ -26,8 +26,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.utils.System2; import org.sonar.core.i18n.I18n; import org.sonar.core.util.UuidFactory; @@ -61,7 +61,7 @@ import static org.sonar.server.exceptions.BadRequestException.throwBadRequestExc public class ComponentUpdater { - private static final Set PROJ_APP_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.APP); + private static final Set PROJ_APP_QUALIFIERS = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.APP); private static final String KEY_ALREADY_EXISTS_ERROR = "Could not create %s with key: \"%s\". A similar key already exists: \"%s\""; private static final String MALFORMED_KEY_ERROR = "Malformed key for %s: '%s'. %s."; private final DbClient dbClient; @@ -196,7 +196,7 @@ public class ComponentUpdater { .setName(newComponent.name()) .setDescription(newComponent.description()) .setLongName(newComponent.name()) - .setScope(Scopes.PROJECT) + .setScope(ComponentScopes.PROJECT) .setQualifier(newComponent.qualifier()) .setPrivate(newComponent.isPrivate()) .setCreatedAt(new Date(now)); @@ -236,7 +236,7 @@ public class ComponentUpdater { } private static boolean isPortfolio(ComponentDto componentDto) { - return Qualifiers.VIEW.contains(componentDto.qualifier()); + return ComponentQualifiers.VIEW.contains(componentDto.qualifier()); } private BranchDto createMainBranch(DbSession session, String componentUuid, String projectUuid, @Nullable String mainBranch) { diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/NewComponent.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/NewComponent.java index 8167bdae6ab..720c4942a5f 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/NewComponent.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/component/NewComponent.java @@ -23,7 +23,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.ComponentValidator.checkComponentKey; import static org.sonar.db.component.ComponentValidator.checkComponentName; import static org.sonar.db.component.ComponentValidator.checkComponentQualifier; diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/DefaultTemplatesResolverImpl.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/DefaultTemplatesResolverImpl.java index ec32b6d3cf6..ea5a9337af3 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/DefaultTemplatesResolverImpl.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/DefaultTemplatesResolverImpl.java @@ -19,9 +19,9 @@ */ package org.sonar.server.common.permission; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.server.property.InternalProperties; @@ -29,11 +29,11 @@ import org.sonar.server.property.InternalProperties; public class DefaultTemplatesResolverImpl implements DefaultTemplatesResolver { private final DbClient dbClient; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; - public DefaultTemplatesResolverImpl(DbClient dbClient, ResourceTypes resourceTypes) { + public DefaultTemplatesResolverImpl(DbClient dbClient, ComponentTypes componentTypes) { this.dbClient = dbClient; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; } @Override @@ -45,27 +45,27 @@ public class DefaultTemplatesResolverImpl implements DefaultTemplatesResolver { String defaultPortfolioTemplate = null; String defaultApplicationTemplate = null; - if (isPortfolioEnabled(resourceTypes)) { + if (isPortfolioEnabled(componentTypes)) { defaultPortfolioTemplate = dbClient.internalPropertiesDao().selectByKey(dbSession, InternalProperties.DEFAULT_PORTFOLIO_TEMPLATE).orElse(defaultProjectTemplate); } - if (isApplicationEnabled(resourceTypes)) { + if (isApplicationEnabled(componentTypes)) { defaultApplicationTemplate = dbClient.internalPropertiesDao().selectByKey(dbSession, InternalProperties.DEFAULT_APPLICATION_TEMPLATE).orElse(defaultProjectTemplate); } return new ResolvedDefaultTemplates(defaultProjectTemplate, defaultApplicationTemplate, defaultPortfolioTemplate); } - private static boolean isPortfolioEnabled(ResourceTypes resourceTypes) { - return resourceTypes.getRoots() + private static boolean isPortfolioEnabled(ComponentTypes componentTypes) { + return componentTypes.getRoots() .stream() - .map(ResourceType::getQualifier) - .anyMatch(Qualifiers.VIEW::equals); + .map(ComponentType::getQualifier) + .anyMatch(ComponentQualifiers.VIEW::equals); } - private static boolean isApplicationEnabled(ResourceTypes resourceTypes) { - return resourceTypes.getRoots() + private static boolean isApplicationEnabled(ComponentTypes componentTypes) { + return componentTypes.getRoots() .stream() - .map(ResourceType::getQualifier) - .anyMatch(Qualifiers.APP::equals); + .map(ComponentType::getQualifier) + .anyMatch(ComponentQualifiers.APP::equals); } } diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/PermissionTemplateService.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/PermissionTemplateService.java index 3857d0c3f9c..b5170a88709 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/PermissionTemplateService.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/permission/PermissionTemplateService.java @@ -30,7 +30,7 @@ import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ServerSide; import org.sonar.core.util.UuidFactory; import org.sonar.db.DbClient; @@ -79,7 +79,7 @@ public class PermissionTemplateService { return true; } - ProjectDto projectDto = new ProjectDto().setKey(projectKey).setQualifier(Qualifiers.PROJECT); + ProjectDto projectDto = new ProjectDto().setKey(projectKey).setQualifier(ComponentQualifiers.PROJECT); PermissionTemplateDto template = findTemplate(dbSession, projectDto); if (template == null) { return false; @@ -208,13 +208,13 @@ public class PermissionTemplateService { String qualifier = entityDto.getQualifier(); DefaultTemplatesResolver.ResolvedDefaultTemplates resolvedDefaultTemplates = defaultTemplatesResolver.resolve(dbSession); switch (qualifier) { - case Qualifiers.PROJECT: + case ComponentQualifiers.PROJECT: return dbClient.permissionTemplateDao().selectByUuid(dbSession, resolvedDefaultTemplates.getProject()); - case Qualifiers.VIEW: + case ComponentQualifiers.VIEW: String portDefaultTemplateUuid = resolvedDefaultTemplates.getPortfolio().orElseThrow( () -> new IllegalStateException("Failed to find default template for portfolios")); return dbClient.permissionTemplateDao().selectByUuid(dbSession, portDefaultTemplateUuid); - case Qualifiers.APP: + case ComponentQualifiers.APP: String appDefaultTemplateUuid = resolvedDefaultTemplates.getApplication().orElseThrow( () -> new IllegalStateException("Failed to find default template for applications")); return dbClient.permissionTemplateDao().selectByUuid(dbSession, appDefaultTemplateUuid); diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/project/ProjectCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/project/ProjectCreator.java index 22cf07233f4..d456a065757 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/project/ProjectCreator.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/project/ProjectCreator.java @@ -30,7 +30,7 @@ import org.sonar.server.component.ComponentCreationData; import org.sonar.server.project.ProjectDefaultVisibility; import org.sonar.server.user.UserSession; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; @ServerSide public class ProjectCreator { diff --git a/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/DefaultDevOpsProjectCreatorTest.java b/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/DefaultDevOpsProjectCreatorTest.java index cc4fb7ec19b..4c56fea19ef 100644 --- a/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/DefaultDevOpsProjectCreatorTest.java +++ b/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/DefaultDevOpsProjectCreatorTest.java @@ -29,7 +29,7 @@ import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.web.UserRole; import org.sonar.auth.DevOpsPlatformSettings; import org.sonar.db.DbClient; @@ -325,7 +325,7 @@ class DefaultDevOpsProjectCreatorTest { NewComponent newComponent = componentCreationParameters.newComponent(); assertThat(newComponent.isProject()).isTrue(); - assertThat(newComponent.qualifier()).isEqualTo(Qualifiers.PROJECT); + assertThat(newComponent.qualifier()).isEqualTo(ComponentQualifiers.PROJECT); assertThat(newComponent.key()).isEqualTo(expectedKey); assertThat(newComponent.name()).isEqualTo(REPOSITORY_NAME); } diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java index 3c2abb28299..7b9e9a83e55 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java @@ -28,9 +28,9 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.server.es.EsIndexSyncInProgressException; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; public class IssueIndexSyncProgressChecker { private static final ImmutableSet APP_VIEW_OR_SUBVIEW = ImmutableSet.builder().add(VIEW, SUBVIEW, APP).build(); diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index e22a90c4c62..3ab31f9827e 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -45,7 +45,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.RuleType; import org.sonar.api.server.ServerSide; @@ -103,8 +103,8 @@ public class IssueQueryFactory { .map(Enum::name) .collect(Collectors.toSet()); private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setBranchUuid(UNKNOWN); - private static final Set QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(Qualifiers.APP, Qualifiers.VIEW, - Qualifiers.SUBVIEW)); + private static final Set QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(ComponentQualifiers.APP, ComponentQualifiers.VIEW, + ComponentQualifiers.SUBVIEW)); private final DbClient dbClient; private final Clock clock; private final UserSession userSession; @@ -381,20 +381,20 @@ public class IssueQueryFactory { setBranch(builder, components.get(0), request.getBranch(), request.getPullRequest(), dbSession); String qualifier = qualifiers.iterator().next(); switch (qualifier) { - case Qualifiers.VIEW, Qualifiers.SUBVIEW: + case ComponentQualifiers.VIEW, ComponentQualifiers.SUBVIEW: addViewsOrSubViews(builder, components); break; - case Qualifiers.APP: + case ComponentQualifiers.APP: addApplications(builder, dbSession, components, request); addProjectUuidsForApplication(builder, dbSession, request); break; - case Qualifiers.PROJECT: + case ComponentQualifiers.PROJECT: builder.projectUuids(retrieveProjectUuidsFromComponents(dbSession, components)); break; - case Qualifiers.DIRECTORY: + case ComponentQualifiers.DIRECTORY: addDirectories(builder, components); break; - case Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE: + case ComponentQualifiers.FILE, ComponentQualifiers.UNIT_TEST_FILE: builder.componentUuids(components.stream().map(ComponentDto::uuid).toList()); break; default: diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java index eb678ce714d..63a2cb9fa72 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java @@ -55,7 +55,7 @@ import org.elasticsearch.search.aggregations.metrics.Sum; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.NestedSortBuilder; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; import org.sonar.server.es.EsClient; @@ -274,7 +274,7 @@ public class ProjectMeasuresIndex { BoolQueryBuilder esFilter = boolQuery() .filter(termQuery(FIELD_INDEX_TYPE, TYPE_PROJECT_MEASURES.getName())) - .filter(termQuery(FIELD_QUALIFIER, Qualifiers.PROJECT)); + .filter(termQuery(FIELD_QUALIFIER, ComponentQualifiers.PROJECT)); searchSourceBuilder.query(esFilter); searchSourceBuilder.aggregation(AggregationBuilders.terms(FIELD_LANGUAGES) .field(FIELD_LANGUAGES) @@ -387,7 +387,7 @@ public class ProjectMeasuresIndex { private static AbstractAggregationBuilder createQualifierFacet() { return filters( FILTER_QUALIFIER, - Stream.of(Qualifiers.APP, Qualifiers.PROJECT) + Stream.of(ComponentQualifiers.APP, ComponentQualifiers.PROJECT) .map(qualifier -> new KeyedFilter(qualifier, termQuery(FIELD_QUALIFIER, qualifier))) .toArray(KeyedFilter[]::new)); } diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexCombinationTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexCombinationTest.java index 8f4ed4dd776..469d17beb5d 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexCombinationTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexCombinationTest.java @@ -21,7 +21,7 @@ package org.sonar.server.component.index; import java.util.stream.IntStream; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.project.ProjectDto; import static java.util.Collections.singletonList; @@ -47,23 +47,23 @@ public class ComponentIndexCombinationTest extends ComponentIndexTest { public void index_whenQualifierMatchesWhatIsTheIndex_shouldReturnTheProject() { ProjectDto project = indexProject("struts", "Apache Struts"); - assertSearchResults(SuggestionQuery.builder().setQuery("struts").setQualifiers(singletonList(Qualifiers.PROJECT)).build(), project); + assertSearchResults(SuggestionQuery.builder().setQuery("struts").setQualifiers(singletonList(ComponentQualifiers.PROJECT)).build(), project); } @Test public void index_whenQualifierDoesNotMatchWhatIsTheIndex_shouldReturnTheProject() { ProjectDto project = indexProject("struts", "Apache Struts"); - SuggestionQuery query = SuggestionQuery.builder().setQuery("struts").setQualifiers(singletonList(Qualifiers.VIEW)).build(); + SuggestionQuery query = SuggestionQuery.builder().setQuery("struts").setQualifiers(singletonList(ComponentQualifiers.VIEW)).build(); - assertNoSearchResults(query.getQuery(), Qualifiers.VIEW); + assertNoSearchResults(query.getQuery(), ComponentQualifiers.VIEW); } @Test public void should_limit_the_number_of_results() { IntStream.rangeClosed(0, 10).forEach(i -> indexProject("sonarqube" + i, "SonarQube" + i)); - assertSearch(SuggestionQuery.builder().setQuery("sonarqube").setLimit(5).setQualifiers(singletonList(Qualifiers.PROJECT)).build()).hasSize(5); + assertSearch(SuggestionQuery.builder().setQuery("sonarqube").setLimit(5).setQualifiers(singletonList(ComponentQualifiers.PROJECT)).build()).hasSize(5); } @Test diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureExactTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureExactTest.java index 851f56bdb79..d7bdc3cb1a0 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureExactTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureExactTest.java @@ -26,7 +26,7 @@ import org.sonar.db.project.ProjectDto; import org.sonar.server.es.textsearch.ComponentTextSearchFeatureRepertoire; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public class ComponentIndexFeatureExactTest extends ComponentIndexTest { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java index d2630593511..91ac470788b 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java @@ -28,7 +28,7 @@ import static com.google.common.collect.ImmutableSet.of; import static java.util.Collections.singletonList; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_KEY; public class ComponentIndexFeatureFavoriteTest extends ComponentIndexTest { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java index 41f1f4b7cf9..a4984a5848c 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java @@ -27,7 +27,7 @@ import org.sonar.server.es.textsearch.ComponentTextSearchFeatureRepertoire; import static com.google.common.collect.ImmutableSet.of; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public class ComponentIndexFeatureRecentlyBrowsedTest extends ComponentIndexTest { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexHighlightTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexHighlightTest.java index 0c9e2051767..c7251c0a379 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexHighlightTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexHighlightTest.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.Optional; import java.util.stream.Stream; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import static org.assertj.core.api.Assertions.assertThat; @@ -64,7 +64,7 @@ public class ComponentIndexHighlightTest extends ComponentIndexTest { SuggestionQuery query = SuggestionQuery.builder() .setQuery(search) - .setQualifiers(Collections.singletonList(Qualifiers.PROJECT)) + .setQualifiers(Collections.singletonList(ComponentQualifiers.PROJECT)) .build(); Stream results = index.searchSuggestions(query, features.get()).getQualifiers(); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java index 69775da2415..d5baef0e7bf 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.sonar.db.project.ProjectDto; import org.sonar.server.es.textsearch.ComponentTextSearchFeatureRepertoire; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public class ComponentIndexScoreTest extends ComponentIndexTest { @Test diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java index 2d3378201d3..b920a74b835 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.stream.IntStream; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -86,7 +86,7 @@ public class ComponentIndexSearchTest { index(project.getProjectDto()); index(db.components().getPortfolioDto(portfolio)); - SearchIdResult result = underTest.search(ComponentQuery.builder().setQualifiers(singleton(Qualifiers.PROJECT)).build(), new SearchOptions()); + SearchIdResult result = underTest.search(ComponentQuery.builder().setQualifiers(singleton(ComponentQualifiers.PROJECT)).build(), new SearchOptions()); assertThat(result.getUuids()).containsExactlyInAnyOrder(project.projectUuid()); } diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java index d3b9cf79839..67454e9017c 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java @@ -36,8 +36,8 @@ import org.sonar.server.tester.UserSessionRule; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public abstract class ComponentIndexTest { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java index 1e1fa395751..75277fbfbc3 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.sonar.api.issue.impact.SoftwareQuality.MAINTAINABILITY; import static org.sonar.api.issue.impact.SoftwareQuality.RELIABILITY; import static org.sonar.api.issue.impact.SoftwareQuality.SECURITY; -import static org.sonar.api.resources.Qualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.api.rules.CleanCodeAttributeCategory.ADAPTABLE; import static org.sonar.api.rules.CleanCodeAttributeCategory.CONSISTENT; import static org.sonar.api.rules.CleanCodeAttributeCategory.INTENTIONAL; diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java index 8fe1e27dcc5..25a893b6f66 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java @@ -41,7 +41,7 @@ import static java.util.TimeZone.getTimeZone; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public class IssueIndexTestCommon { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java index 6197d35b9d9..eaaff79c859 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java @@ -28,7 +28,7 @@ import java.util.Date; import java.util.Map; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rule.RuleKey; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.db.DbTester; @@ -52,7 +52,7 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.api.measures.CoreMetrics.ANALYSIS_FROM_SONARQUBE_9_4_KEY; -import static org.sonar.api.resources.Qualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.api.utils.DateUtils.addDays; import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonar.api.web.UserRole.USER; @@ -510,7 +510,7 @@ public class IssueQueryFactoryTest { @Test public void param_componentUuids_enables_search_by_test_file() { ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto file = db.components().insertComponent(newFileDto(project).setQualifier(Qualifiers.UNIT_TEST_FILE)); + ComponentDto file = db.components().insertComponent(newFileDto(project).setQualifier(ComponentQualifiers.UNIT_TEST_FILE)); SearchRequest request = new SearchRequest() .setComponentUuids(asList(file.uuid())); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java index 8c2c0ad6af8..a158f893bb3 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java @@ -57,8 +57,8 @@ import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY; import static org.sonar.api.measures.CoreMetrics.COVERAGE_KEY; import static org.sonar.api.measures.Metric.Level.ERROR; import static org.sonar.api.measures.Metric.Level.OK; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.db.user.GroupTesting.newGroupDto; import static org.sonar.db.user.UserTesting.newUserDto; diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java index b4305a7d796..9610ed403c0 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java @@ -41,7 +41,7 @@ import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURES; import static org.sonar.server.measure.index.ProjectMeasuresQuery.Operator.GT; diff --git a/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java b/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java index e2bc7703ed0..ceb5c3b682b 100644 --- a/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java +++ b/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java @@ -22,8 +22,7 @@ package org.sonar.server.permission.index; import com.google.common.base.Preconditions; import java.util.List; import java.util.stream.Stream; -import org.assertj.core.api.Assertions; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.component.ComponentDto; import org.sonar.db.entity.EntityDto; import org.sonar.db.user.GroupDto; @@ -43,7 +42,7 @@ public class PermissionIndexerTester { public PermissionIndexerTester allowOnlyAnyone(ComponentDto... portfolios) { stream(portfolios) - .forEach(p -> Preconditions.checkArgument(p.qualifier().equals(Qualifiers.VIEW), "Permission should be applied on a portfolio")); + .forEach(p -> Preconditions.checkArgument(p.qualifier().equals(ComponentQualifiers.VIEW), "Permission should be applied on a portfolio")); return allow(stream(portfolios).map(project -> new IndexPermissions(project.uuid(), project.qualifier()).allowAnyone()).toList()); } diff --git a/server/sonar-webserver-webapi/build.gradle b/server/sonar-webserver-webapi/build.gradle index d532a1c888c..2ce5ac6dde7 100644 --- a/server/sonar-webserver-webapi/build.gradle +++ b/server/sonar-webserver-webapi/build.gradle @@ -50,8 +50,9 @@ dependencies { testImplementation testFixtures(project(':server:sonar-webserver-es')) testImplementation testFixtures(project(':server:sonar-webserver-ws')) testImplementation project(':sonar-testing-harness') - testFixturesApi testFixtures(project(':server:sonar-db-dao')) + testFixturesApi testFixtures(project(':server:sonar-db-dao')) + testFixturesImplementation testFixtures(project(':server:sonar-server-common')) testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api' diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java index becb7a2756c..b538edfe1e3 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonar.alm.client.github.GithubApplicationClientImpl; import org.sonar.alm.client.github.GithubPermissionConverter; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.auth.github.ExpiringAppInstallationToken; @@ -43,7 +43,7 @@ import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.alm.setting.AlmSettingDto; import org.sonar.db.component.BranchDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.entity.EntityDto; import org.sonar.db.newcodeperiod.NewCodePeriodDto; import org.sonar.db.permission.GlobalPermission; @@ -124,7 +124,7 @@ public class ImportGithubProjectActionIT { new IndexersImpl(new PermissionIndexer(db.getDbClient(), es.client())), Set.of(new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()), new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory()))); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT)); private final ComponentUpdater componentUpdater = new ComponentUpdater(db.getDbClient(), mock(I18n.class), System2.INSTANCE, permissionTemplateService, new FavoriteUpdater(db.getDbClient()), new TestIndexers(), new SequenceUuidFactory(), defaultBranchNameResolver, userPermissionUpdater, permissionService); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionIT.java index d571bcf5702..628fd98cbc8 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionIT.java @@ -29,7 +29,7 @@ import org.junit.Test; import org.sonar.alm.client.gitlab.GitLabBranch; import org.sonar.alm.client.gitlab.GitlabApplicationClient; import org.sonar.alm.client.gitlab.Project; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.auth.gitlab.GitLabSettings; @@ -40,7 +40,7 @@ import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbTester; import org.sonar.db.alm.setting.AlmSettingDto; import org.sonar.db.component.BranchDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.newcodeperiod.NewCodePeriodDto; import org.sonar.db.project.CreationMethod; import org.sonar.db.project.ProjectDto; @@ -126,7 +126,7 @@ public class ImportGitLabProjectActionIT { new IndexersImpl(new PermissionIndexer(db.getDbClient(), es.client())), Set.of(new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()), new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory()))); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT)); private final GitLabSettings gitlabSettings = mock(); private final ManagedProjectService managedProjectService = mock(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/CreateGithubActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/CreateGithubActionIT.java index 5d18612a52b..543aaf9164d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/CreateGithubActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/CreateGithubActionIT.java @@ -24,7 +24,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.internal.Encryption; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbTester; @@ -58,7 +58,7 @@ public class CreateGithubActionIT { private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class); private final WsActionTester ws = new WsActionTester(new CreateGithubAction(db.getDbClient(), userSession, - new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)), + new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ComponentTypes.class)), multipleAlmFeature))); @Before diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ListActionIT.java index 1be2ec9ff4d..489dc7aaa8d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ListActionIT.java @@ -21,7 +21,7 @@ package org.sonar.server.almsettings.ws; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbTester; import org.sonar.db.alm.setting.AlmSettingDto; @@ -53,7 +53,7 @@ public class ListActionIT { @Rule public DbTester db = DbTester.create(); - private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)); + private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ComponentTypes.class)); private final WsActionTester ws = new WsActionTester(new ListAction(db.getDbClient(), userSession, componentFinder)); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionIT.java index 8b370306133..669b552d5c2 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionIT.java @@ -22,7 +22,7 @@ package org.sonar.server.almsettings.ws; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.internal.Encryption; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbTester; import org.sonar.db.alm.setting.AlmSettingDto; @@ -54,7 +54,7 @@ public class UpdateBitbucketCloudActionIT { private final Encryption encryption = mock(Encryption.class); private final WsActionTester ws = new WsActionTester(new UpdateBitbucketCloudAction(db.getDbClient(), userSession, - new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)), + new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ComponentTypes.class)), mock(MultipleAlmFeature.class)))); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateGithubActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateGithubActionIT.java index 6222324e23f..af03c32590b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateGithubActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/UpdateGithubActionIT.java @@ -29,7 +29,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.sonar.api.config.internal.Encryption; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbSession; @@ -70,7 +70,7 @@ public class UpdateGithubActionIT { private final Encryption encryption = mock(Encryption.class); private final WsActionTester ws = new WsActionTester(new UpdateGithubAction(db.getDbClient(), userSession, - new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)), + new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ComponentTypes.class)), mock(MultipleAlmFeature.class)))); private AlmSettingDto almSettingDto; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ValidateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ValidateActionIT.java index 7d011f77966..8ba66546beb 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ValidateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almsettings/ws/ValidateActionIT.java @@ -29,7 +29,7 @@ import org.sonar.alm.client.bitbucket.bitbucketcloud.BitbucketCloudRestClient; import org.sonar.alm.client.bitbucket.bitbucketcloud.BitbucketCloudValidator; import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.internal.Settings; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbTester; import org.sonar.db.alm.setting.ALM; @@ -65,7 +65,7 @@ public class ValidateActionIT { public DbTester db = DbTester.create(); private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class); - private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)); + private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ComponentTypes.class)); private final AlmSettingsSupport almSettingsSupport = new AlmSettingsSupport(db.getDbClient(), userSession, componentFinder, multipleAlmFeature); private final AzureDevOpsHttpClient azureDevOpsHttpClient = mock(AzureDevOpsHttpClient.class); private final BitbucketCloudRestClient bitbucketCloudRestClient = mock(BitbucketCloudRestClient.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java index c71a2e55852..87819d52815 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java @@ -21,15 +21,15 @@ package org.sonar.server.batch; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.db.source.FileSourceDto; import org.sonar.scanner.protocol.input.FileData; @@ -54,7 +54,7 @@ public class ProjectDataLoaderIT { private final DbClient dbClient = db.getDbClient(); private final DbSession dbSession = db.getSession(); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); private final ProjectDataLoader underTest = new ProjectDataLoader(dbClient, userSession, new ComponentFinder(dbClient, resourceTypes)); @Test @@ -140,7 +140,7 @@ public class ProjectDataLoaderIT { .setUuid(uuid) .setUuidPath(uuid + ".") .setBranchUuid("branchUuid") - .setScope(Scopes.PROJECT) + .setScope(ComponentScopes.PROJECT) .setKey("key")); dbSession.commit(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/ListActionIT.java index d853e3a5e86..262173e6863 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/ListActionIT.java @@ -22,7 +22,7 @@ package org.sonar.server.branch.ws; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; @@ -30,7 +30,7 @@ import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.metric.MetricDto; import org.sonar.db.project.ProjectDto; import org.sonar.db.rule.RuleDto; @@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; import static org.mockito.Mockito.mock; import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.api.rules.RuleType.BUG; import static org.sonar.api.utils.DateUtils.dateToLong; import static org.sonar.api.utils.DateUtils.parseDateTime; @@ -75,13 +75,13 @@ public class ListActionIT { public UserSessionRule userSession = UserSessionRule.standalone(); private final AsyncIssueIndexing asyncIssueIndexing = mock(AsyncIssueIndexing.class); - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); private final IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()), asyncIssueIndexing); private final PermissionIndexerTester permissionIndexerTester = new PermissionIndexerTester(es, issueIndexer); private MetricDto qualityGateStatus; - public WsActionTester ws = new WsActionTester(new ListAction(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), resourceTypes))); + public WsActionTester ws = new WsActionTester(new ListAction(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), componentTypes))); @Before public void setUp() { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/RenameActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/RenameActionIT.java index 12dcfdb89c7..9a926c8b320 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/RenameActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/RenameActionIT.java @@ -22,14 +22,14 @@ package org.sonar.server.branch.ws; import java.util.Optional; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.newcodeperiod.NewCodePeriodDto; import org.sonar.db.newcodeperiod.NewCodePeriodType; import org.sonar.db.project.ProjectDto; @@ -42,7 +42,7 @@ import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; public class RenameActionIT { @Rule @@ -50,8 +50,8 @@ public class RenameActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); - private ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), resourceTypes); + private ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); + private ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), componentTypes); private WsActionTester tester = new WsActionTester(new RenameAction(db.getDbClient(), componentFinder, userSession)); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionIT.java index 755759a63f4..8c030de5692 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionIT.java @@ -22,13 +22,13 @@ package org.sonar.server.branch.ws; import java.util.Optional; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.ForbiddenException; @@ -39,7 +39,7 @@ import org.sonar.server.ws.WsActionTester; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; public class SetAutomaticDeletionProtectionActionIT { @@ -49,8 +49,8 @@ public class SetAutomaticDeletionProtectionActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); - private ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), resourceTypes); + private ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); + private ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), componentTypes); private WsActionTester tester = new WsActionTester(new SetAutomaticDeletionProtectionAction(db.getDbClient(), userSession, componentFinder)); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchActionIT.java index 8e61a68b57d..efce0fad609 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchActionIT.java @@ -31,7 +31,7 @@ import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; import org.sonar.server.component.index.ComponentIndex; @@ -54,10 +54,10 @@ import static java.util.Optional.ofNullable; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.DIRECTORY; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.DIRECTORY; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.api.server.ws.WebService.Param.PAGE; import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; @@ -75,7 +75,7 @@ public class SearchActionIT { public final EsTester es = EsTester.create(); private final I18nRule i18n = new I18nRule(); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule(); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule(); private final EntityDefinitionIndexer indexer = new EntityDefinitionIndexer(db.getDbClient(), es.client()); private final PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, indexer); private final ComponentIndex index = new ComponentIndex(es.client(), new WebAuthorizationTypeSupport(userSession), System2.INSTANCE); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java index ddfe67b4919..835742ee1b8 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java @@ -37,7 +37,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.sonar.api.measures.Metric; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; @@ -172,10 +172,10 @@ public class SearchProjectsActionIT { @DataProvider public static Object[][] component_qualifiers_for_valid_editions() { return new Object[][] { - {new String[] {Qualifiers.PROJECT}, Edition.COMMUNITY}, - {new String[] {Qualifiers.APP, Qualifiers.PROJECT}, Edition.DEVELOPER}, - {new String[] {Qualifiers.APP, Qualifiers.PROJECT}, Edition.ENTERPRISE}, - {new String[] {Qualifiers.APP, Qualifiers.PROJECT}, Edition.DATACENTER}, + {new String[] {ComponentQualifiers.PROJECT}, Edition.COMMUNITY}, + {new String[] {ComponentQualifiers.APP, ComponentQualifiers.PROJECT}, Edition.DEVELOPER}, + {new String[] {ComponentQualifiers.APP, ComponentQualifiers.PROJECT}, Edition.ENTERPRISE}, + {new String[] {ComponentQualifiers.APP, ComponentQualifiers.PROJECT}, Edition.DATACENTER}, }; } @@ -1503,7 +1503,7 @@ public class SearchProjectsActionIT { private void index() { projectMeasuresIndexer.indexAll(); ResultHandler rh = r -> { - if (!r.getResultObject().getQualifier().equals(Qualifiers.SUBVIEW)) { + if (!r.getResultObject().getQualifier().equals(ComponentQualifiers.SUBVIEW)) { authorizationIndexerTester.allowOnlyAnyone(r.getResultObject()); } }; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/ShowActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/ShowActionIT.java index 2c7db008865..13291397296 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/ShowActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/ShowActionIT.java @@ -24,7 +24,7 @@ import java.util.Optional; import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; @@ -477,7 +477,7 @@ public class ShowActionIT { .setKey("com.sonarsource:java-markdown") .setName("Java Markdown") .setDescription("Java Markdown Project") - .setQualifier(Qualifiers.PROJECT), + .setQualifier(ComponentQualifiers.PROJECT), p -> p.setTagsString("language, plugin")); ComponentDto mainBranch = projectData.getMainBranchComponent(); userSession.addProjectPermission(USER, projectData.getProjectDto()) @@ -489,7 +489,7 @@ public class ShowActionIT { ComponentDto directory = newDirectory(mainBranch, "AVIF-FfgA3Ax6PH2efPF", "src/main/java/com/sonarsource/markdown/impl") .setKey("com.sonarsource:java-markdown:src/main/java/com/sonarsource/markdown/impl") .setName("src/main/java/com/sonarsource/markdown/impl") - .setQualifier(Qualifiers.DIRECTORY); + .setQualifier(ComponentQualifiers.DIRECTORY); db.components().insertComponent(directory); db.components().insertComponent( newFileDto(directory, directory, "AVIF-FffA3Ax6PH2efPD") @@ -497,6 +497,6 @@ public class ShowActionIT { .setName("Rule.java") .setPath("src/main/java/com/sonarsource/markdown/impl/Rule.java") .setLanguage("java") - .setQualifier(Qualifiers.FILE)); + .setQualifier(ComponentQualifiers.FILE)); } } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java index 557b0a2271a..989fe11c164 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java @@ -25,7 +25,7 @@ import javax.annotation.Nullable; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; @@ -33,7 +33,7 @@ import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.index.ComponentIndex; import org.sonar.server.component.index.EntityDefinitionIndexer; @@ -60,12 +60,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.groups.Tuple.tuple; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.web.UserRole.USER; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.server.component.ws.SuggestionsAction.PARAM_MORE; @@ -85,7 +85,7 @@ public class SuggestionsActionIT { public final EsTester es = EsTester.create(); @Rule public final UserSessionRule userSessionRule = UserSessionRule.standalone(); - public final ResourceTypesRule resourceTypes = new ResourceTypesRule(); + public final ComponentTypesRule resourceTypes = new ComponentTypesRule(); private final EntityDefinitionIndexer entityDefinitionIndexer = new EntityDefinitionIndexer(db.getDbClient(), es.client()); private final FavoriteFinder favoriteFinder = mock(FavoriteFinder.class); @@ -269,7 +269,7 @@ public class SuggestionsActionIT { assertThat(response.getResultsList()) .filteredOn(q -> q.getItemsCount() > 0) .extracting(Category::getQ) - .containsExactly(Qualifiers.PROJECT); + .containsExactly(ComponentQualifiers.PROJECT); // assert correct id to be found assertThat(response.getResultsList()) diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java index cbd822d74ac..f62232f216c 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java @@ -30,21 +30,21 @@ import javax.annotation.Nullable; import org.apache.commons.io.IOUtils; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.core.i18n.I18n; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.ForbiddenException; @@ -62,9 +62,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; import static org.mockito.Mockito.mock; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; import static org.sonar.db.component.BranchType.PULL_REQUEST; import static org.sonar.db.component.ComponentTesting.newChildComponent; @@ -85,10 +85,10 @@ public class TreeActionIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); private final DbClient dbClient = db.getDbClient(); - private final ResourceTypes defaultResourceTypes = new ResourceTypes(new ResourceTypeTree[]{DefaultResourceTypes.get()}); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule() - .setRootQualifiers(defaultResourceTypes.getRoots()) - .setAllQualifiers(defaultResourceTypes.getAll()) + private final ComponentTypes defaultComponentTypes = new ComponentTypes(new ComponentTypeTree[]{DefaultComponentTypes.get()}); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule() + .setRootQualifiers(defaultComponentTypes.getRoots()) + .setAllQualifiers(defaultComponentTypes.getAll()) .setLeavesQualifiers(FILE, UNIT_TEST_FILE); private final WsActionTester ws = new WsActionTester(new TreeAction(dbClient, new ComponentFinder(dbClient, resourceTypes), resourceTypes, userSession, mock(I18n.class))); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/SearchActionIT.java index 8c3507b4b3f..9eac4a370fa 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/SearchActionIT.java @@ -44,7 +44,7 @@ import static java.util.Optional.ofNullable; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.client.WsRequest.Method.POST; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/PullActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/PullActionIT.java index d33af56ec7c..fc7e3582e45 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/PullActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/PullActionIT.java @@ -30,13 +30,13 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.issue.Issue; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.issue.IssueDbTester; import org.sonar.db.issue.IssueDto; import org.sonar.db.project.ProjectDto; @@ -80,7 +80,7 @@ public class PullActionIT { private final System2 system2 = mock(System2.class); private final PullHotspotsActionProtobufObjectGenerator pullActionProtobufObjectGenerator = new PullHotspotsActionProtobufObjectGenerator(); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), resourceTypes); private final IssueDbTester issueDbTester = new IssueDbTester(db); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullActionIT.java index 20e430b7caa..f7a292c1339 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullActionIT.java @@ -28,12 +28,12 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.issue.Issue; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.issue.IssueDbTester; import org.sonar.db.issue.IssueDto; import org.sonar.db.project.ProjectDto; @@ -79,7 +79,7 @@ public class PullActionIT { private final TaintChecker taintChecker = mock(TaintChecker.class); private final PullActionProtobufObjectGenerator pullActionProtobufObjectGenerator = new PullActionProtobufObjectGenerator(); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), resourceTypes); private final IssueDbTester issueDbTester = new IssueDbTester(db); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullTaintActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullTaintActionIT.java index 8d1155f7108..7ddec6f957a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullTaintActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/PullTaintActionIT.java @@ -30,13 +30,13 @@ import org.junit.Test; import org.sonar.api.issue.Issue; import org.sonar.api.issue.impact.Severity; import org.sonar.api.issue.impact.SoftwareQuality; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.core.rule.ImpactFormatter; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.issue.ImpactDto; import org.sonar.db.issue.IssueDbTester; import org.sonar.db.issue.IssueDto; @@ -87,7 +87,7 @@ public class PullTaintActionIT { private final System2 system2 = mock(System2.class); private final TaintChecker taintChecker = mock(TaintChecker.class); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), resourceTypes); private final IssueDbTester issueDbTester = new IssueDbTester(db); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java index 6d9040f36bd..cb268bf3942 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java @@ -25,7 +25,7 @@ import java.util.Date; import org.junit.Rule; import org.junit.Test; import org.sonar.api.resources.Languages; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.Durations; import org.sonar.api.utils.System2; @@ -62,7 +62,7 @@ import org.sonarqube.ws.Issues.SearchWsResponse; import static org.apache.commons.lang3.RandomStringUtils.secure; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; -import static org.sonar.api.resources.Qualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.api.utils.DateUtils.addDays; import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonar.api.web.UserRole.USER; @@ -201,7 +201,7 @@ public class SearchActionComponentsIT { ProjectData projectData = db.components().insertPublicProject(p -> p.setKey("PK1")); ComponentDto project = projectData.getMainBranchComponent(); ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1")); - ComponentDto unitTest = db.components().insertComponent(newFileDto(project, null, "F2").setQualifier(Qualifiers.UNIT_TEST_FILE).setKey("FK2")); + ComponentDto unitTest = db.components().insertComponent(newFileDto(project, null, "F2").setQualifier(ComponentQualifiers.UNIT_TEST_FILE).setKey("FK2")); RuleDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1"))); IssueDto issueOnFile = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); IssueDto issueOnTest = db.issues().insertIssue(rule, project, unitTest, i -> i.setKee("2bd4eac2-b650-4037-80bc-7b1182fd47d4")); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java index 5be14479c46..c2110e2a284 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java @@ -113,7 +113,7 @@ import static org.sonar.api.issue.Issue.STATUS_OPEN; import static org.sonar.api.issue.Issue.STATUS_REOPENED; import static org.sonar.api.issue.Issue.STATUS_RESOLVED; import static org.sonar.api.issue.Issue.STATUS_REVIEWED; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; import static org.sonar.api.rules.RuleType.CODE_SMELL; import static org.sonar.api.server.ws.WebService.Param.FACETS; import static org.sonar.api.utils.DateUtils.formatDateTime; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/TagsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/TagsActionIT.java index a74e6c921e4..154bf219aea 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/TagsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/TagsActionIT.java @@ -29,7 +29,7 @@ import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.issue.IssueDto; import org.sonar.db.rule.RuleDto; import org.sonar.server.component.ComponentFinder; @@ -57,7 +57,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newProjectCopy; import static org.sonar.test.JsonAssert.assertJson; @@ -76,7 +76,7 @@ public class TagsActionIT { private final IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()), null); private final ViewIndexer viewIndexer = new ViewIndexer(db.getDbClient(), es.client()); private final PermissionIndexerTester permissionIndexer = new PermissionIndexerTester(es, issueIndexer); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); private final WsActionTester ws = new WsActionTester(new TagsAction(issueIndex, issueIndexSyncProgressChecker, db.getDbClient(), new ComponentFinder(db.getDbClient(), resourceTypes))); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/anticipatedtransition/AnticipatedTransitionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/anticipatedtransition/AnticipatedTransitionsActionIT.java index d1d0f428daa..47a870efc20 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/anticipatedtransition/AnticipatedTransitionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/anticipatedtransition/AnticipatedTransitionsActionIT.java @@ -24,10 +24,10 @@ import java.nio.file.Files; import java.nio.file.Path; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.core.util.UuidFactory; import org.sonar.db.DbTester; @@ -57,7 +57,7 @@ public class AnticipatedTransitionsActionIT { @Rule public DbTester db = DbTester.create(); - private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), new ResourceTypes(new ResourceTypeTree[]{DefaultResourceTypes.get()})); + private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), new ComponentTypes(new ComponentTypeTree[]{DefaultComponentTypes.get()})); private final AnticipatedTransitionsActionValidator validator = new AnticipatedTransitionsActionValidator(db.getDbClient(), componentFinder, userSession); private final UuidFactory uuidFactory = new SequenceUuidFactory(); private final AnticipatedTransitionDao anticipatedTransitionDao = db.getDbClient().anticipatedTransitionDao(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/live/LiveMeasureComputerImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/live/LiveMeasureComputerImplIT.java index 3b207a0c902..4ad47139b46 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/live/LiveMeasureComputerImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/live/LiveMeasureComputerImplIT.java @@ -31,7 +31,7 @@ import org.sonar.api.config.Configuration; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.measures.Metric; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.db.DbSession; @@ -158,7 +158,7 @@ public class LiveMeasureComputerImplIT { } private SnapshotDto markProjectAsAnalyzed(ComponentDto p, @Nullable Long periodDate) { - assertThat(p.qualifier()).isEqualTo(Qualifiers.PROJECT); + assertThat(p.qualifier()).isEqualTo(ComponentQualifiers.PROJECT); return db.components().insertSnapshot(p, s -> s.setPeriodDate(periodDate)); } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java index f4b4539d257..3e4dba53513 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java @@ -25,11 +25,11 @@ import java.util.stream.IntStream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.measures.Metric; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -37,7 +37,7 @@ import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; @@ -71,10 +71,10 @@ import static org.sonar.api.measures.Metric.ValueType.DISTRIB; import static org.sonar.api.measures.Metric.ValueType.FLOAT; import static org.sonar.api.measures.Metric.ValueType.INT; import static org.sonar.api.measures.Metric.ValueType.RATING; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.DIRECTORY; -import static org.sonar.api.resources.Qualifiers.FILE; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.DIRECTORY; +import static org.sonar.db.component.ComponentQualifiers.FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; import static org.sonar.api.server.ws.WebService.Param.SORT; import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonar.api.web.UserRole.USER; @@ -112,10 +112,10 @@ class ComponentTreeActionIT { private final I18nRule i18n = new I18nRule(); - private final ResourceTypes defaultResourceTypes = new ResourceTypes(new ResourceTypeTree[]{DefaultResourceTypes.get()}); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule() - .setRootQualifiers(defaultResourceTypes.getRoots()) - .setAllQualifiers(defaultResourceTypes.getAll()) + private final ComponentTypes defaultComponentTypes = new ComponentTypes(new ComponentTypeTree[]{DefaultComponentTypes.get()}); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule() + .setRootQualifiers(defaultComponentTypes.getRoots()) + .setAllQualifiers(defaultComponentTypes.getAll()) .setLeavesQualifiers(FILE, UNIT_TEST_FILE); private final DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java index ae818cd2a1d..e8ccaf28303 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java @@ -20,14 +20,14 @@ package org.sonar.server.permission.ws; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService.Action; import org.sonar.api.web.UserRole; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.portfolio.PortfolioDto; import org.sonar.db.project.ProjectDto; @@ -62,8 +62,8 @@ public class AddGroupActionIT extends BasePermissionWsIT { private static final String A_PROJECT_UUID = "project-uuid"; private static final String A_PROJECT_KEY = "project-key"; - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final ManagedInstanceChecker managedInstanceChecker = mock(ManagedInstanceChecker.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddUserActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddUserActionIT.java index f6f1a93a493..a954c229dde 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddUserActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddUserActionIT.java @@ -22,11 +22,11 @@ package org.sonar.server.permission.ws; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.web.UserRole; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.portfolio.PortfolioDto; import org.sonar.db.project.ProjectDto; @@ -58,8 +58,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_U public class AddUserActionIT extends BasePermissionWsIT { private UserDto user; - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final Configuration configuration = mock(Configuration.class); private final ManagedInstanceChecker managedInstanceChecker = mock(ManagedInstanceChecker.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/BasePermissionWsIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/BasePermissionWsIT.java index 70687fc68b2..ad2d5c66cbc 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/BasePermissionWsIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/BasePermissionWsIT.java @@ -24,11 +24,11 @@ import org.junit.Before; import org.junit.Rule; import org.sonar.api.config.Configuration; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.template.PermissionTemplateDto; import org.sonar.server.es.EsTester; import org.sonar.server.es.IndexersImpl; @@ -75,8 +75,8 @@ public abstract class BasePermissionWsIT { return new PermissionWsSupport(dbClient, configuration, newGroupWsSupport()); } - protected ResourceTypesRule newRootResourceTypes() { - return new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP); + protected ComponentTypesRule newRootResourceTypes() { + return new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW, ComponentQualifiers.APP); } protected PermissionUpdater newPermissionUpdater() { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/GroupsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/GroupsActionIT.java index fae9e5acfdb..d333314cb51 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/GroupsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/GroupsActionIT.java @@ -22,14 +22,14 @@ package org.sonar.server.permission.ws; import java.util.Set; import org.junit.Before; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.security.DefaultGroups; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService.Action; import org.sonar.api.web.UserRole; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.portfolio.PortfolioDto; import org.sonar.db.project.ProjectDto; @@ -63,8 +63,8 @@ public class GroupsActionIT extends BasePermissionWsIT { private GroupDto group1; private GroupDto group2; - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final ManagedInstanceService managedInstanceService = mock(ManagedInstanceService.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveGroupActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveGroupActionIT.java index 43742c94574..bf6bbdcebf0 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveGroupActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveGroupActionIT.java @@ -23,14 +23,14 @@ import com.tngtech.java.junit.dataprovider.DataProviderRunner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService.Action; import org.sonar.api.web.UserRole; import org.sonar.core.util.Uuids; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.entity.EntityDto; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.permission.GroupPermissionDto; @@ -64,8 +64,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_P public class RemoveGroupActionIT extends BasePermissionWsIT { private GroupDto aGroup; - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final ManagedInstanceChecker managedInstanceChecker = mock(ManagedInstanceChecker.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveUserActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveUserActionIT.java index a621a1370b9..3286818177c 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveUserActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/RemoveUserActionIT.java @@ -21,11 +21,11 @@ package org.sonar.server.permission.ws; import org.junit.Before; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.web.UserRole; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; @@ -58,8 +58,8 @@ public class RemoveUserActionIT extends BasePermissionWsIT { private static final String A_LOGIN = "ray.bradbury"; private UserDto user; - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final ManagedInstanceChecker managedInstanceChecker = mock(ManagedInstanceChecker.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/UsersActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/UsersActionIT.java index 2f06dfb3795..d675080919e 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/UsersActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/UsersActionIT.java @@ -21,15 +21,15 @@ package org.sonar.server.permission.ws; import java.util.Set; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.server.ws.WebService.SelectionMode; import org.sonar.api.web.UserRole; import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; @@ -63,8 +63,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_U public class UsersActionIT extends BasePermissionWsIT { - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final RequestValidator requestValidator = new RequestValidator(permissionService); private final ManagedInstanceService managedInstanceService = mock(ManagedInstanceService.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionIT.java index 4242900dbbe..a4b238f8b2b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionIT.java @@ -23,12 +23,12 @@ import java.util.List; import javax.annotation.Nullable; import org.junit.Before; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService.Action; import org.sonar.api.web.UserRole; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.PermissionQuery; import org.sonar.db.permission.template.PermissionTemplateDto; import org.sonar.db.user.GroupDto; @@ -58,8 +58,8 @@ public class AddGroupToTemplateActionIT extends BasePermissionWsIT { - newRequest(template.getUuid(), Qualifiers.FILE); + newRequest(template.getUuid(), ComponentQualifiers.FILE); }) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Value of parameter 'qualifier' (FIL) must be one of: [APP, TRK, VW]"); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateGroupsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateGroupsActionIT.java index 74e6d75f674..a33223022e0 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateGroupsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateGroupsActionIT.java @@ -22,11 +22,11 @@ package org.sonar.server.permission.ws.template; import java.util.stream.IntStream; import javax.annotation.Nullable; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.template.PermissionTemplateDto; import org.sonar.db.permission.template.PermissionTemplateGroupDto; import org.sonar.db.user.GroupDto; @@ -61,8 +61,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_T public class TemplateGroupsActionIT extends BasePermissionWsIT { - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final RequestValidator requestValidator = new RequestValidator(permissionService); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateUsersActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateUsersActionIT.java index 763cdb4ca9c..28df9b5a4a4 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateUsersActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/template/TemplateUsersActionIT.java @@ -22,11 +22,11 @@ package org.sonar.server.permission.ws.template; import java.util.stream.IntStream; import javax.annotation.Nullable; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.permission.template.PermissionTemplateDto; import org.sonar.db.permission.template.PermissionTemplateUserDto; @@ -61,8 +61,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_T public class TemplateUsersActionIT extends BasePermissionWsIT { - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final WsParameters wsParameters = new WsParameters(permissionService); private final RequestValidator requestValidator = new RequestValidator(permissionService); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/BulkDeleteActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/BulkDeleteActionIT.java index bc0e669f2ad..134d1f8bd11 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/BulkDeleteActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/BulkDeleteActionIT.java @@ -36,7 +36,7 @@ import org.joda.time.DateTime; import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.db.DbClient; @@ -212,7 +212,7 @@ public class BulkDeleteActionIT { ws.newRequest() .setParam(PARAM_PROJECTS, project.getProjectDto().getKey() + "," + view.getKey()) - .setParam(PARAM_QUALIFIERS, String.join(",", Qualifiers.PROJECT, Qualifiers.VIEW)) + .setParam(PARAM_QUALIFIERS, String.join(",", ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW)) .execute(); verifyEntityDeleted(project.getProjectDto(), portfolioDto); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java index 99097501d5e..29e67796454 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java @@ -28,8 +28,8 @@ import java.util.stream.Stream; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; @@ -45,7 +45,7 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.PortfolioData; import org.sonar.db.component.ProjectData; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.permission.GroupPermissionDto; import org.sonar.db.permission.UserPermissionDto; @@ -100,8 +100,8 @@ public class UpdateVisibilityActionIT { @Rule public final UserSessionRule userSessionRule = UserSessionRule.standalone().logIn(); - private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); + private final ComponentTypes componentTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); + private final PermissionService permissionService = new PermissionServiceImpl(componentTypes); private final Set PROJECT_PERMISSIONS_BUT_USER_AND_CODEVIEWER = permissionService.getAllProjectPermissions().stream() .filter(perm -> !perm.equals(UserRole.USER) && !perm.equals(UserRole.CODEVIEWER)) .collect(Collectors.toSet()); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java index ae201ddf81e..92c80ddd5ca 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java @@ -22,12 +22,12 @@ package org.sonar.server.projectdump.ws; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.web.UserRole; import org.sonar.ce.task.CeTask; import org.sonar.db.DbTester; import org.sonar.db.ce.CeTaskTypes; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; import org.sonar.server.ce.projectdump.ExportSubmitter; @@ -57,7 +57,7 @@ public class ExportActionIT { public DbTester db = DbTester.create(); private final ExportSubmitter exportSubmitter = mock(ExportSubmitter.class); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT, Qualifiers.VIEW); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW); private final ProjectDumpWsSupport projectDumpWsSupport = new ProjectDumpWsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), resourceTypes)); private final ExportAction underTest = new ExportAction(projectDumpWsSupport, userSession, exportSubmitter); private final WsActionTester actionTester = new WsActionTester(underTest); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java index ad46b0c92b9..de936669139 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java @@ -38,7 +38,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.BadRequestException; @@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.test.JsonAssert.assertJson; public class StatusActionIT { @@ -67,7 +67,7 @@ public class StatusActionIT { private final DbClient dbClient = db.getDbClient(); private final DbSession dbSession = db.getSession(); - private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT); + private final ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(PROJECT); private final static String projectDumpsDirectoryPathname = "data/governance/project_dumps/"; private final static String importDirectoryPathname = Paths.get(projectDumpsDirectoryPathname, "import").toString(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projecttag/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projecttag/ws/SearchActionIT.java index f68b613f4c6..ac1f360fea7 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projecttag/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projecttag/ws/SearchActionIT.java @@ -43,7 +43,7 @@ import static java.util.Arrays.stream; import static java.util.Optional.ofNullable; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.TYPE_PROJECT_MEASURES; import static org.sonar.test.JsonAssert.assertJson; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionIT.java index 74805a4181e..2125fdc894d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionIT.java @@ -24,13 +24,13 @@ import org.junit.Rule; import org.junit.Test; import org.mockito.Mockito; import org.sonar.api.resources.Languages; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.project.ProjectDto; import org.sonar.db.qualityprofile.QProfileDto; @@ -66,7 +66,7 @@ public class RemoveProjectActionIT { private final QualityProfileChangeEventService qualityProfileChangeEventService = Mockito.mock(QualityProfileChangeEventService.class); private final RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages, - new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport, qualityProfileChangeEventService); + new ComponentFinder(dbClient, new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT)), wsSupport, qualityProfileChangeEventService); private final WsActionTester ws = new WsActionTester(underTest); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java index 033e60989e0..e1de2f8b480 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java @@ -48,8 +48,7 @@ import org.sonarqube.ws.Settings.ListDefinitionsWsResponse; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.groups.Tuple.tuple; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonarqube.ws.MediaTypes.JSON; import static org.sonarqube.ws.Settings.Definition.CategoryOneOfCase.CATEGORYONEOF_NOT_SET; import static org.sonarqube.ws.Settings.Definition.DefaultValueOneOfCase.DEFAULTVALUEONEOF_NOT_SET; @@ -57,7 +56,6 @@ import static org.sonarqube.ws.Settings.Definition.DeprecatedKeyOneOfCase.DEPREC import static org.sonarqube.ws.Settings.Definition.NameOneOfCase.NAMEONEOF_NOT_SET; import static org.sonarqube.ws.Settings.Definition.SubCategoryOneOfCase.SUBCATEGORYONEOF_NOT_SET; import static org.sonarqube.ws.Settings.Type.BOOLEAN; -import static org.sonarqube.ws.Settings.Type.LICENSE; import static org.sonarqube.ws.Settings.Type.PROPERTY_SET; import static org.sonarqube.ws.Settings.Type.SINGLE_SELECT_LIST; import static org.sonarqube.ws.Settings.Type.STRING; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java index b915db2f9f0..6824bee5de7 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java @@ -54,8 +54,8 @@ import static java.lang.String.format; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.web.UserRole.ADMIN; import static org.sonar.api.web.UserRole.USER; import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java index dfd2961d6b6..0a07dcd89e8 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java @@ -34,9 +34,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.PropertyFieldDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; @@ -306,7 +307,7 @@ public class SetActionIT { .subCategory("subCat") .type(PropertyType.PROPERTY_SET) .defaultValue("default") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .fields(List.of( PropertyFieldDefinition.build("firstField") .name("First Field") @@ -734,7 +735,7 @@ public class SetActionIT { .subCategory("subCat") .type(PropertyType.INTEGER) .defaultValue("default") - .onlyOnQualifiers(Qualifiers.PROJECT) + .onlyOnConfigScopes(ConfigScope.PROJECT) .build()); assertThatThrownBy(() -> callForGlobalSetting("my.key", "42")) @@ -752,10 +753,10 @@ public class SetActionIT { .subCategory("subCat") .type(PropertyType.STRING) .defaultValue("default") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build()); ComponentDto view = db.components().insertPublicPortfolio(); - i18n.put("qualifier." + Qualifiers.VIEW, "View"); + i18n.put("qualifier." + ComponentQualifiers.VIEW, "View"); assertThatThrownBy(() -> { logInAsPortfolioAdministrator(db.components().getPortfolioDto(view)); @@ -776,7 +777,7 @@ public class SetActionIT { .subCategory("subCat") .type(PropertyType.STRING) .defaultValue("default") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build()); i18n.put("qualifier." + portfolio.getQualifier(), "CptLabel"); logInAsPortfolioAdministrator(portfolio); @@ -1095,7 +1096,7 @@ public class SetActionIT { .defaultValue("default") .fields(List.of(PropertyFieldDefinition.build("firstField").name("First Field").type(PropertyType.STRING).build())) .build()); - i18n.put("qualifier." + Qualifiers.PROJECT, "Project"); + i18n.put("qualifier." + ComponentQualifiers.PROJECT, "Project"); ProjectDto project = db.components().insertPrivateProject().getProjectDto(); logInAsProjectAdministrator(project); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java index 59aeb09426b..7eea7a3c732 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java @@ -56,7 +56,7 @@ import static java.util.Comparator.comparing; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.groups.Tuple.tuple; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.api.web.UserRole.ADMIN; import static org.sonar.api.web.UserRole.CODEVIEWER; import static org.sonar.api.web.UserRole.USER; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java index 04909d0c278..c9b64f591cf 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java @@ -21,12 +21,12 @@ package org.sonar.server.source.ws; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -49,7 +49,7 @@ public class RawActionIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private ComponentTypesRule resourceTypes = new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT); private WsActionTester ws = new WsActionTester(new RawAction(db.getDbClient(), new SourceService(db.getDbClient(), null), userSession, diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/ShowActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/ShowActionIT.java index f9fa4009305..e984039d428 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/ShowActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/ShowActionIT.java @@ -23,7 +23,7 @@ import java.util.Optional; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -31,7 +31,7 @@ import org.sonar.db.component.BranchDao; import org.sonar.db.component.ComponentDao; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.ForbiddenException; @@ -61,7 +61,7 @@ public class ShowActionIT { private ComponentDto mainBranchComponentDto = ComponentTesting.newBranchComponent(project, ComponentTesting.newMainBranchDto(project.getUuid())); private ComponentDto file = ComponentTesting.newFileDto(mainBranchComponentDto); private ShowAction underTest = new ShowAction(sourceService, dbClient, userSessionRule, - new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT))); + new ComponentFinder(dbClient, new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT))); private WsActionTester tester = new WsActionTester(underTest); @Before diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java index 41c16adab86..78b52883d9f 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java @@ -28,10 +28,10 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.CoreProperties; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; @@ -39,7 +39,7 @@ import org.sonar.api.web.UserRole; import org.sonar.api.web.page.Page; import org.sonar.api.web.page.Page.Qualifier; import org.sonar.api.web.page.PageDefinition; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.core.extension.CoreExtensionRepository; import org.sonar.core.platform.PluginInfo; import org.sonar.core.platform.PluginRepository; @@ -104,16 +104,16 @@ public class ComponentActionIT { private final DbClient dbClient = db.getDbClient(); private final ComponentDbTester componentDbTester = db.components(); private final PropertyDbTester propertyDbTester = new PropertyDbTester(db); - private final ResourceTypes resourceTypes = mock(ResourceTypes.class); + private final ComponentTypes componentTypes = mock(ComponentTypes.class); private final Configuration config = mock(Configuration.class); private WsActionTester ws; @Before public void setup() { - ResourceType resourceType = mock(ResourceType.class); - when(resourceType.getBooleanProperty(any())).thenReturn(true); - when(resourceTypes.get(any())).thenReturn(resourceType); + ComponentType componentType = mock(ComponentType.class); + when(componentType.getBooleanProperty(any())).thenReturn(true); + when(componentTypes.get(any())).thenReturn(componentType); } @Test @@ -516,7 +516,7 @@ public class ComponentActionIT { .addProjectPermission(UserRole.USER, project.getProjectDto()) .addProjectPermission(UserRole.ADMIN, project.getProjectDto()) .registerBranches(project.getMainBranchDto()); - ResourceType projectResourceType = ResourceType.builder(project.getProjectDto().getQualifier()) + ComponentType projectComponentType = ComponentType.builder(project.getProjectDto().getQualifier()) .setProperty("comparable", true) .setProperty("configurable", true) .setProperty("hasRolePolicy", true) @@ -524,8 +524,8 @@ public class ComponentActionIT { .setProperty("updatable_key", true) .setProperty("deletable", true) .build(); - when(resourceTypes.get(project.getProjectDto().getQualifier())) - .thenReturn(projectResourceType); + when(componentTypes.get(project.getProjectDto().getQualifier())) + .thenReturn(projectComponentType); init(); executeAndVerify(project.projectKey(), "return_configuration_with_all_properties.json"); @@ -749,7 +749,7 @@ public class ComponentActionIT { .setProjectVersion("6.3") .setLast(true); componentDbTester.insertSnapshot(analysis); - when(resourceTypes.get(projectDto.getQualifier())).thenReturn(DefaultResourceTypes.get().getRootType()); + when(componentTypes.get(projectDto.getQualifier())).thenReturn(DefaultComponentTypes.get().getRootType()); UserDto user = db.users().insertUser("obiwan"); propertyDbTester.insertProperty(new PropertyDto().setKey("favourite").setEntityUuid(projectDto.getUuid()).setUserUuid(user.getUuid()), projectDto.getKey(), projectDto.getName(), projectDto.getQualifier(), user.getLogin()); @@ -808,8 +808,8 @@ public class ComponentActionIT { .setBranchUuid("abcd") .setName("Polop") .setDescription("test project") - .setQualifier(Qualifiers.PROJECT) - .setScope(Scopes.PROJECT)); + .setQualifier(ComponentQualifiers.PROJECT) + .setScope(ComponentScopes.PROJECT)); } private void init(Page... pages) { @@ -825,7 +825,7 @@ public class ComponentActionIT { }}); pageRepository.start(); ws = new WsActionTester( - new ComponentAction(dbClient, pageRepository, resourceTypes, userSession, new ComponentFinder(dbClient, resourceTypes), + new ComponentAction(dbClient, pageRepository, componentTypes, userSession, new ComponentFinder(dbClient, componentTypes), new QualityGateFinder(dbClient), config)); } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionHomepageIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionHomepageIT.java index 78714e541de..bc19bffd666 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionHomepageIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionHomepageIT.java @@ -27,10 +27,10 @@ import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.utils.System2; import org.sonar.core.platform.EditionProvider; import org.sonar.core.platform.PlatformEditionProvider; @@ -64,8 +64,8 @@ public class CurrentActionHomepageIT { private final PlatformEditionProvider platformEditionProvider = mock(PlatformEditionProvider.class); private final HomepageTypesImpl homepageTypes = new HomepageTypesImpl(); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypes(new ResourceTypeTree[] { - ResourceTypeTree.builder().addType(ResourceType.builder(Qualifiers.PROJECT).build()).build()})); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypes(new ComponentTypeTree[] { + ComponentTypeTree.builder().addType(ComponentType.builder(ComponentQualifiers.PROJECT).build()).build()})); private final WsActionTester ws = new WsActionTester( new CurrentAction(userSessionRule, dbClient, new AvatarResolverImpl(), homepageTypes, platformEditionProvider, permissionService)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionIT.java index 9f3bcbd6b5b..ab09877bb4a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CurrentActionIT.java @@ -27,10 +27,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Suite; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.core.platform.PlatformEditionProvider; @@ -72,8 +72,8 @@ public class CurrentActionIT { private final PlatformEditionProvider platformEditionProvider = mock(PlatformEditionProvider.class); private final HomepageTypesImpl homepageTypes = new HomepageTypesImpl(); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypes(new ResourceTypeTree[] { - ResourceTypeTree.builder().addType(ResourceType.builder(Qualifiers.PROJECT).build()).build()})); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypes(new ComponentTypeTree[] { + ComponentTypeTree.builder().addType(ComponentType.builder(ComponentQualifiers.PROJECT).build()).build()})); private final WsActionTester ws = new WsActionTester( new CurrentAction(userSession, db.getDbClient(), new AvatarResolverImpl(), homepageTypes, platformEditionProvider, permissionService)); @@ -251,8 +251,8 @@ public class CurrentActionIT { private final PlatformEditionProvider platformEditionProvider = mock(PlatformEditionProvider.class); private final HomepageTypesImpl homepageTypes = new HomepageTypesImpl(); - private final PermissionService permissionService = new PermissionServiceImpl(new ResourceTypes(new ResourceTypeTree[] { - ResourceTypeTree.builder().addType(ResourceType.builder(Qualifiers.PROJECT).build()).build()})); + private final PermissionService permissionService = new PermissionServiceImpl(new ComponentTypes(new ComponentTypeTree[] { + ComponentTypeTree.builder().addType(ComponentType.builder(ComponentQualifiers.PROJECT).build()).build()})); private final WsActionTester ws = new WsActionTester( new CurrentAction(userSession, db.getDbClient(), new AvatarResolverImpl(), homepageTypes, platformEditionProvider, permissionService)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java index fa50e3572a6..43d7e6c6193 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java @@ -34,7 +34,7 @@ import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.TokenType; import org.sonar.db.user.UserDto; @@ -90,7 +90,7 @@ public class GenerateActionIT { private final MapSettings mapSettings = new MapSettings(); private final Configuration configuration = mapSettings.asConfig(); private final GenerateActionValidation validation = new GenerateActionValidation(configuration, runtime); - private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), new ResourceTypesRule()); + private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), new ComponentTypesRule()); private final WsActionTester ws = new WsActionTester( new GenerateAction(db.getDbClient(), System2.INSTANCE, componentFinder, tokenGenerator, new UserTokenSupport(db.getDbClient(), userSession), validation)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/CreateActionIT.java index d6bcb1a716e..4716a9ec5e5 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/CreateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/CreateActionIT.java @@ -22,7 +22,7 @@ package org.sonar.server.webhook.ws; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; import org.sonar.core.util.UuidFactory; @@ -72,8 +72,8 @@ public class CreateActionIT { private final Configuration configuration = mock(Configuration.class); private final NetworkInterfaceProvider networkInterfaceProvider = mock(NetworkInterfaceProvider.class); private final WebhookSupport webhookSupport = new WebhookSupport(userSession, configuration, networkInterfaceProvider); - private final ResourceTypes resourceTypes = mock(ResourceTypes.class); - private final ComponentFinder componentFinder = new ComponentFinder(dbClient, resourceTypes); + private final ComponentTypes componentTypes = mock(ComponentTypes.class); + private final ComponentFinder componentFinder = new ComponentFinder(dbClient, componentTypes); private final CreateAction underTest = new CreateAction(dbClient, userSession, uuidFactory, webhookSupport, componentFinder); private final WsActionTester wsActionTester = new WsActionTester(underTest); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/ListActionIT.java index 6d4324cd0de..5416dde2f00 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/ListActionIT.java @@ -23,7 +23,7 @@ import java.util.List; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.web.UserRole; @@ -72,8 +72,8 @@ public class ListActionIT { private final Configuration configuration = mock(Configuration.class); private final NetworkInterfaceProvider networkInterfaceProvider = mock(NetworkInterfaceProvider.class); private final WebhookSupport webhookSupport = new WebhookSupport(userSession, configuration, networkInterfaceProvider); - private final ResourceTypes resourceTypes = mock(ResourceTypes.class); - private final ComponentFinder componentFinder = new ComponentFinder(dbClient, resourceTypes); + private final ComponentTypes componentTypes = mock(ComponentTypes.class); + private final ComponentFinder componentFinder = new ComponentFinder(dbClient, componentTypes); private final ListAction underTest = new ListAction(dbClient, userSession, webhookSupport, componentFinder); private final ComponentDbTester componentDbTester = db.components(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/UpdateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/UpdateActionIT.java index b6ef5454bde..83f855d0eeb 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/UpdateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/webhook/ws/UpdateActionIT.java @@ -23,7 +23,7 @@ import java.util.Optional; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; @@ -67,8 +67,8 @@ public class UpdateActionIT { private final Configuration configuration = mock(Configuration.class); private final NetworkInterfaceProvider networkInterfaceProvider = mock(NetworkInterfaceProvider.class); private final WebhookSupport webhookSupport = new WebhookSupport(userSession, configuration, networkInterfaceProvider); - private final ResourceTypes resourceTypes = mock(ResourceTypes.class); - private final ComponentFinder componentFinder = new ComponentFinder(dbClient, resourceTypes); + private final ComponentTypes componentTypes = mock(ComponentTypes.class); + private final ComponentFinder componentFinder = new ComponentFinder(dbClient, componentTypes); private final UpdateAction underTest = new UpdateAction(dbClient, userSession, webhookSupport, componentFinder); private final WsActionTester wsActionTester = new WsActionTester(underTest); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java index 7a86d12ee74..79f0bc6e7c7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java @@ -25,8 +25,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ServerSide; import org.sonar.api.web.UserRole; import org.sonar.ce.queue.CeQueue; @@ -146,7 +146,7 @@ public class ReportSubmitter { private void validateProject(DbSession dbSession, ComponentDto component, String rawProjectKey) { List errors = new ArrayList<>(); - if (!Qualifiers.PROJECT.equals(component.qualifier()) || !Scopes.PROJECT.equals(component.scope())) { + if (!ComponentQualifiers.PROJECT.equals(component.qualifier()) || !ComponentScopes.PROJECT.equals(component.scope())) { errors.add(format("Component '%s' is not a project", rawProjectKey)); } if (!component.branchUuid().equals(component.uuid())) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java index ea589bf0a37..ff5eafe123f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java @@ -31,7 +31,7 @@ import java.util.stream.StreamSupport; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.jetbrains.annotations.NotNull; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -77,7 +77,7 @@ import static org.sonar.server.ws.WsUtils.writeProtobuf; public class ActivityAction implements CeWsAction { private static final int MAX_PAGE_SIZE = 1000; - private static final String[] POSSIBLE_QUALIFIERS = new String[]{Qualifiers.PROJECT, Qualifiers.APP, Qualifiers.VIEW}; + private static final String[] POSSIBLE_QUALIFIERS = new String[]{ComponentQualifiers.PROJECT, ComponentQualifiers.APP, ComponentQualifiers.VIEW}; private static final String INVALID_QUERY_PARAM_ERROR_MESSAGE = "%s and %s must not be set at the same time"; private final UserSession userSession; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentCleanerService.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentCleanerService.java index 7b407c46931..c77132ec2a8 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentCleanerService.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentCleanerService.java @@ -20,7 +20,7 @@ package org.sonar.server.component; import java.util.List; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ServerSide; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -66,10 +66,10 @@ public class ComponentCleanerService { } public void deleteEntity(DbSession dbSession, EntityDto entity) { - checkArgument(!entity.getQualifier().equals(Qualifiers.SUBVIEW), "Qualifier can't be subview"); + checkArgument(!entity.getQualifier().equals(ComponentQualifiers.SUBVIEW), "Qualifier can't be subview"); dbClient.purgeDao().deleteProject(dbSession, entity.getUuid(), entity.getQualifier(), entity.getName(), entity.getKey()); dbClient.userDao().cleanHomepage(dbSession, entity); - if (Qualifiers.PROJECT.equals(entity.getQualifier())) { + if (ComponentQualifiers.PROJECT.equals(entity.getQualifier())) { dbClient.userTokenDao().deleteByProjectUuid(dbSession, entity.getKey(), entity.getUuid()); } // Note that we do not send an event for each individual branch being deleted with the project diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java index f782a641208..9b54679b2fe 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java @@ -24,10 +24,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.BranchDto; @@ -49,11 +47,11 @@ public class ComponentFinder { private static final String LABEL_ENTITY_NOT_FOUND = "Component '%s' not found"; private final DbClient dbClient; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; - public ComponentFinder(DbClient dbClient, ResourceTypes resourceTypes) { + public ComponentFinder(DbClient dbClient, ComponentTypes componentTypes) { this.dbClient = dbClient; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; } public ComponentDto getByUuidOrKey(DbSession dbSession, @Nullable String componentUuid, @Nullable String componentKey, ParamNames parameterNames) { @@ -102,7 +100,7 @@ public class ComponentFinder { public ProjectDto getProjectByUuid(DbSession dbSession, String projectUuid) { return dbClient.projectDao().selectByUuid(dbSession, projectUuid) - .filter(p -> Qualifiers.PROJECT.equals(p.getQualifier())) + .filter(p -> ComponentQualifiers.PROJECT.equals(p.getQualifier())) .orElseThrow(() -> new NotFoundException(String.format(LABEL_PROJECT_NOT_FOUND, projectUuid))); } @@ -219,22 +217,22 @@ public class ComponentFinder { } private ComponentDto checkIsProject(ComponentDto component) { - Set rootQualifiers = getRootQualifiers(resourceTypes); + Set rootQualifiers = getRootQualifiers(componentTypes); - checkRequest(component.scope().equals(Scopes.PROJECT) && rootQualifiers.contains(component.qualifier()), + checkRequest(component.scope().equals(ComponentScopes.PROJECT) && rootQualifiers.contains(component.qualifier()), format( "Component '%s' (id: %s) must be a project%s.", component.getKey(), component.uuid(), - rootQualifiers.contains(Qualifiers.VIEW) ? " or a view" : "")); + rootQualifiers.contains(ComponentQualifiers.VIEW) ? " or a view" : "")); return component; } - private static Set getRootQualifiers(ResourceTypes resourceTypes) { - Collection rootTypes = resourceTypes.getRoots(); + private static Set getRootQualifiers(ComponentTypes componentTypes) { + Collection rootTypes = componentTypes.getRoots(); return rootTypes .stream() - .map(ResourceType::getQualifier) + .map(ComponentType::getQualifier) .collect(Collectors.toSet()); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java index 45b5781a91a..3daa11d4f54 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ComponentDtoToWsComponent.java @@ -22,7 +22,7 @@ package org.sonar.server.component.ws; import java.util.Arrays; import java.util.Set; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; import org.sonar.db.project.ProjectDto; @@ -38,7 +38,7 @@ class ComponentDtoToWsComponent { /** * The concept of "visibility" will only be configured for these qualifiers. */ - private static final Set QUALIFIERS_WITH_VISIBILITY = Set.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP); + private static final Set QUALIFIERS_WITH_VISIBILITY = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW, ComponentQualifiers.APP); private ComponentDtoToWsComponent() { // prevent instantiation @@ -84,7 +84,7 @@ class ComponentDtoToWsComponent { }); if (QUALIFIERS_WITH_VISIBILITY.contains(dto.qualifier())) { wsComponent.setVisibility(Visibility.getLabel(dto.isPrivate())); - if (Arrays.asList(Qualifiers.PROJECT, Qualifiers.APP).contains(dto.qualifier()) && parentProjectDto != null && isMainBranch) { + if (Arrays.asList(ComponentQualifiers.PROJECT, ComponentQualifiers.APP).contains(dto.qualifier()) && parentProjectDto != null && isMainBranch) { wsComponent.getTagsBuilder().addAllTags(parentProjectDto.getTags()); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactory.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactory.java index 3d0a394ebe2..f0118eb457e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactory.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactory.java @@ -31,7 +31,7 @@ import java.util.function.BiConsumer; import java.util.stream.Stream; import javax.annotation.Nullable; import org.sonar.api.measures.Metric.Level; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.server.component.ws.FilterParser.Criterion; import org.sonar.server.measure.index.ProjectMeasuresQuery; import org.sonar.server.measure.index.ProjectMeasuresQuery.Operator; @@ -121,7 +121,7 @@ class ProjectMeasuresQueryFactory { Operator operator = criterion.getOperator(); String value = criterion.getValue(); checkArgument(EQ.equals(operator), "Only equals operator is available for qualifier criteria"); - String qualifier = Stream.of(Qualifiers.APP, Qualifiers.PROJECT).filter(q -> q.equalsIgnoreCase(value)).findFirst() + String qualifier = Stream.of(ComponentQualifiers.APP, ComponentQualifiers.PROJECT).filter(q -> q.equalsIgnoreCase(value)).findFirst() .orElseThrow(() -> new IllegalArgumentException(format("Unknown qualifier : '%s'", value))); query.setQualifiers(Sets.newHashSet(qualifier)); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java index c5ab1572ebd..1828184c36d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java @@ -26,7 +26,7 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -46,10 +46,10 @@ import org.sonarqube.ws.Components.SearchWsResponse; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toMap; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.server.es.SearchOptions.MAX_PAGE_SIZE; import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter; import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext; @@ -63,13 +63,13 @@ public class SearchAction implements ComponentsWsAction { .build(); private final ComponentIndex componentIndex; private final DbClient dbClient; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final I18n i18n; - public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ResourceTypes resourceTypes, I18n i18n) { + public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ComponentTypes componentTypes, I18n i18n) { this.componentIndex = componentIndex; this.dbClient = dbClient; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.i18n = i18n; } @@ -96,7 +96,7 @@ public class SearchAction implements ComponentsWsAction { DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH + " (inclusive) characters. In case longer value is provided it will be truncated.") .setExampleValue("sonar"); - createQualifiersParameter(action, newQualifierParameterContext(i18n, resourceTypes), VALID_QUALIFIERS) + createQualifiersParameter(action, newQualifierParameterContext(i18n, componentTypes), VALID_QUALIFIERS) .setRequired(true); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java index 149524ee287..9afdc59ebeb 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java @@ -40,7 +40,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -292,12 +292,12 @@ public class SearchProjectsAction implements ComponentsWsAction { Optional edition = editionProvider.get(); if (edition.isEmpty()) { - return Sets.newHashSet(Qualifiers.PROJECT); + return Sets.newHashSet(ComponentQualifiers.PROJECT); } return switch (edition.get()) { - case ENTERPRISE, DATACENTER, DEVELOPER -> Sets.newHashSet(Qualifiers.PROJECT, Qualifiers.APP); - default -> Sets.newHashSet(Qualifiers.PROJECT); + case ENTERPRISE, DATACENTER, DEVELOPER -> Sets.newHashSet(ComponentQualifiers.PROJECT, ComponentQualifiers.APP); + default -> Sets.newHashSet(ComponentQualifiers.PROJECT); }; } @@ -337,7 +337,7 @@ public class SearchProjectsAction implements ComponentsWsAction { } private Map getApplicationsLeakPeriod(DbSession dbSession, SearchProjectsRequest request, Set qualifiers, Collection mainBranchUuids) { - if (qualifiers.contains(Qualifiers.APP) && request.getAdditionalFields().contains(LEAK_PERIOD_DATE)) { + if (qualifiers.contains(ComponentQualifiers.APP) && request.getAdditionalFields().contains(LEAK_PERIOD_DATE)) { return dbClient.measureDao().selectByComponentUuidsAndMetricKeys(dbSession, mainBranchUuids, Collections.singleton(METRIC_LEAK_PROJECTS_KEY)) .stream() .filter(m -> !Objects.isNull(m.getString(METRIC_LEAK_PROJECTS_KEY))) @@ -498,7 +498,7 @@ public class SearchProjectsAction implements ComponentsWsAction { wsComponent.setAnalysisDate(formatDateTime(snapshotDto.getCreatedAt())); } if (request.getAdditionalFields().contains(LEAK_PERIOD_DATE)) { - if (Qualifiers.APP.equals(dbProject.getQualifier())) { + if (ComponentQualifiers.APP.equals(dbProject.getQualifier())) { ofNullable(applicationsLeakPeriod.get(dbProject.getUuid())).ifPresent(leakPeriodDate -> wsComponent.setLeakPeriodDate(formatDateTime(leakPeriodDate))); } else { ofNullable(snapshotDto.getPeriodDate()).ifPresent(leakPeriodDate -> wsComponent.setLeakPeriodDate(formatDateTime(leakPeriodDate))); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ShowAction.java index e41cfe1ca00..a273f0155c4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/ShowAction.java @@ -25,8 +25,8 @@ import java.util.Set; import java.util.stream.IntStream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -55,8 +55,8 @@ import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SH import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT; public class ShowAction implements ComponentsWsAction { - private static final Set PROJECT_OR_APP_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.APP); - private static final Set APP_VIEW_OR_SUBVIEW_QUALIFIERS = Set.of(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW); + private static final Set PROJECT_OR_APP_QUALIFIERS = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.APP); + private static final Set APP_VIEW_OR_SUBVIEW_QUALIFIERS = Set.of(ComponentQualifiers.APP, ComponentQualifiers.VIEW, ComponentQualifiers.SUBVIEW); private final UserSession userSession; private final DbClient dbClient; private final ComponentFinder componentFinder; @@ -178,7 +178,7 @@ public class ShowAction implements ComponentsWsAction { } private boolean isMainBranchOfProjectOrApp(ComponentDto component, DbSession dbSession) { - if (!PROJECT_OR_APP_QUALIFIERS.contains(component.qualifier()) || !Scopes.PROJECT.equals(component.scope())) { + if (!PROJECT_OR_APP_QUALIFIERS.contains(component.qualifier()) || !ComponentScopes.PROJECT.equals(component.scope())) { return false; } Optional branchDto = dbClient.branchDao().selectByUuid(dbSession, component.branchUuid()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionCategory.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionCategory.java index d7c5a12a949..4d26425a1b8 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionCategory.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionCategory.java @@ -19,15 +19,15 @@ */ package org.sonar.server.component.ws; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import static java.util.Arrays.stream; public enum SuggestionCategory { - VIEW(Qualifiers.VIEW), - SUBVIEW(Qualifiers.SUBVIEW), - APP(Qualifiers.APP), - PROJECT(Qualifiers.PROJECT); + VIEW(ComponentQualifiers.VIEW), + SUBVIEW(ComponentQualifiers.SUBVIEW), + APP(ComponentQualifiers.APP), + PROJECT(ComponentQualifiers.PROJECT); private final String qualifier; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java index 8e1693e444c..70acd28adda 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java @@ -34,8 +34,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -79,16 +79,16 @@ public class SuggestionsAction implements ComponentsWsAction { private final ComponentIndex index; private final FavoriteFinder favoriteFinder; private final UserSession userSession; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final DbClient dbClient; - public SuggestionsAction(DbClient dbClient, ComponentIndex index, FavoriteFinder favoriteFinder, UserSession userSession, ResourceTypes resourceTypes) { + public SuggestionsAction(DbClient dbClient, ComponentIndex index, FavoriteFinder favoriteFinder, UserSession userSession, ComponentTypes componentTypes) { this.dbClient = dbClient; this.index = index; this.favoriteFinder = favoriteFinder; this.userSession = userSession; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; } @Override @@ -246,8 +246,8 @@ public class SuggestionsAction implements ComponentsWsAction { } private List getQualifiers(@Nullable String more) { - Set availableQualifiers = resourceTypes.getAll().stream() - .map(ResourceType::getQualifier) + Set availableQualifiers = componentTypes.getAll().stream() + .map(ComponentType::getQualifier) .collect(Collectors.toSet()); if (more == null) { return stream(SuggestionCategory.values()) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java index 6f3b7e6e754..22532c41d6d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -33,8 +33,8 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -91,18 +91,18 @@ public class TreeAction implements ComponentsWsAction { private static final String PATH_SORT = "path"; private static final String QUALIFIER_SORT = "qualifier"; private static final Set SORTS = ImmutableSortedSet.of(NAME_SORT, PATH_SORT, QUALIFIER_SORT); - private static final Set PROJECT_OR_APP_QUALIFIERS = ImmutableSortedSet.of(Qualifiers.PROJECT, Qualifiers.APP); + private static final Set PROJECT_OR_APP_QUALIFIERS = ImmutableSortedSet.of(ComponentQualifiers.PROJECT, ComponentQualifiers.APP); private final DbClient dbClient; private final ComponentFinder componentFinder; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final UserSession userSession; private final I18n i18n; - public TreeAction(DbClient dbClient, ComponentFinder componentFinder, ResourceTypes resourceTypes, UserSession userSession, I18n i18n) { + public TreeAction(DbClient dbClient, ComponentFinder componentFinder, ComponentTypes componentTypes, UserSession userSession, I18n i18n) { this.dbClient = dbClient; this.componentFinder = componentFinder; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.userSession = userSession; this.i18n = i18n; } @@ -151,7 +151,7 @@ public class TreeAction implements ComponentsWsAction { .setMinimumLength(QUERY_MINIMUM_LENGTH) .setExampleValue("FILE_NAM"); - createQualifiersParameter(action, newQualifierParameterContext(i18n, resourceTypes)); + createQualifiersParameter(action, newQualifierParameterContext(i18n, componentTypes)); action.createParam(PARAM_STRATEGY) .setDescription("Strategy to search for base component descendants:" + @@ -290,7 +290,7 @@ public class TreeAction implements ComponentsWsAction { List requestQualifiers = request.getQualifiers(); List childrenQualifiers = null; if (LEAVES_STRATEGY.equals(request.getStrategy())) { - childrenQualifiers = resourceTypes.getLeavesQualifiers(baseQualifier); + childrenQualifiers = componentTypes.getLeavesQualifiers(baseQualifier); } if (requestQualifiers == null) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/AddAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/AddAction.java index c90224487c5..5ce68d0995c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/AddAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/AddAction.java @@ -37,10 +37,10 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static java.lang.String.join; import static java.util.Arrays.asList; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.web.UserRole.USER; import static org.sonar.server.favorite.ws.FavoritesWsParameters.PARAM_COMPONENT; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java index 9ccf68d9498..5d1374d6e19 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.TotalHits; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.SearchHit; import org.jetbrains.annotations.NotNull; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; @@ -94,7 +94,7 @@ import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class SearchAction implements HotspotsWsAction { - private static final Set SUPPORTED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.APP); + private static final Set SUPPORTED_QUALIFIERS = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.APP); private static final String PARAM_PROJECT = "project"; private static final String PARAM_PROJECT_KEY = "projectKey"; private static final String PARAM_STATUS = "status"; @@ -393,7 +393,7 @@ public class SearchAction implements HotspotsWsAction { ProjectDto projectOrApp = projectOrAppAndBranch.getProject(); BranchDto projectOrAppBranch = projectOrAppAndBranch.getBranch(); - if (Qualifiers.APP.equals(projectOrApp.getQualifier())) { + if (ComponentQualifiers.APP.equals(projectOrApp.getQualifier())) { builder.viewUuids(singletonList(projectOrAppBranch.getUuid())); if (wsRequest.isInNewCodePeriod() && wsRequest.getPullRequest().isEmpty()) { addInNewCodePeriodFilterByProjects(builder, dbSession, projectOrAppBranch); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java index 3866a43dbdd..ff185975e6d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; @@ -113,7 +113,7 @@ public class AuthorsAction implements IssuesWsAction { return Optional.empty(); } return Optional.of(dbClient.entityDao().selectByKey(dbSession, projectKey) - .filter(e -> !e.getQualifier().equals(Qualifiers.SUBVIEW)) + .filter(e -> !e.getQualifier().equals(ComponentQualifiers.SUBVIEW)) .orElseThrow(() -> new NotFoundException("Entity not found: " + projectKey))); } @@ -121,9 +121,9 @@ public class AuthorsAction implements IssuesWsAction { IssueQuery.Builder issueQueryBuilder = IssueQuery.builder(); ofNullable(entity).ifPresent(p -> { switch (p.getQualifier()) { - case Qualifiers.PROJECT -> issueQueryBuilder.projectUuids(Set.of(p.getUuid())); - case Qualifiers.VIEW -> issueQueryBuilder.viewUuids(Set.of(p.getUuid())); - case Qualifiers.APP -> { + case ComponentQualifiers.PROJECT -> issueQueryBuilder.projectUuids(Set.of(p.getUuid())); + case ComponentQualifiers.VIEW -> issueQueryBuilder.viewUuids(Set.of(p.getUuid())); + case ComponentQualifiers.APP -> { BranchDto appMainBranch = dbClient.branchDao().selectMainBranchByProjectUuid(session, entity.getUuid()) .orElseThrow(() -> new IllegalStateException("Couldn't find main branch for APP " + entity.getUuid())); issueQueryBuilder.viewUuids(Set.of(appMainBranch.getUuid())); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index 19309c3f288..71ef8fdf198 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -75,7 +75,7 @@ import static java.lang.String.format; import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; import static java.util.Optional.ofNullable; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; import static org.sonar.api.rule.RuleKey.EXTERNAL_RULE_REPO_PREFIX; import static org.sonar.server.issue.index.IssueIndex.FACET_ASSIGNED_TO_ME; import static org.sonar.server.issue.index.IssueIndex.FACET_PROJECTS; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/TagsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/TagsAction.java index eee9c6f47e2..36e16e15693 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/TagsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/TagsAction.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -121,7 +121,7 @@ public class TagsAction implements IssuesWsAction { return Optional.empty(); } return Optional.of(componentFinder.getEntityByKey(dbSession, entityKey)) - .filter(e -> !e.getQualifier().equals(Qualifiers.SUBVIEW)); + .filter(e -> !e.getQualifier().equals(ComponentQualifiers.SUBVIEW)); } private void checkIfAnyComponentsNeedIssueSync(DbSession session, @Nullable String projectKey) { @@ -137,15 +137,15 @@ public class TagsAction implements IssuesWsAction { .types(ISSUE_TYPE_NAMES); if (entity != null) { switch (entity.getQualifier()) { - case Qualifiers.PROJECT -> issueQueryBuilder.projectUuids(Set.of(entity.getUuid())); - case Qualifiers.VIEW, Qualifiers.APP -> issueQueryBuilder.viewUuids(Set.of(entity.getUuid())); + case ComponentQualifiers.PROJECT -> issueQueryBuilder.projectUuids(Set.of(entity.getUuid())); + case ComponentQualifiers.VIEW, ComponentQualifiers.APP -> issueQueryBuilder.viewUuids(Set.of(entity.getUuid())); default -> throw new IllegalArgumentException(String.format("Entity of type '%s' is not supported", entity.getQualifier())); } if (branch != null && !branch.isMain()) { issueQueryBuilder.branchUuid(branch.getUuid()); issueQueryBuilder.mainBranch(false); - } else if (Qualifiers.APP.equals(entity.getQualifier())) { + } else if (ComponentQualifiers.APP.equals(entity.getQualifier())) { dbClient.branchDao().selectMainBranchByProjectUuid(dbSession, entity.getUuid()) .ifPresent(b -> issueQueryBuilder.branchUuid(b.getUuid())); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index e05fee40672..a3cf37b30b3 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -28,7 +28,7 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -72,7 +72,7 @@ import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class ComponentAction implements MeasuresWsAction { - private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE); + private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(ComponentQualifiers.FILE, ComponentQualifiers.UNIT_TEST_FILE); private final DbClient dbClient; private final ComponentFinder componentFinder; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java index 235ac6088a3..770adfcdf9b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java @@ -43,9 +43,9 @@ import java.util.stream.Stream; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -153,21 +153,21 @@ public class ComponentTreeAction implements MeasuresWsAction { static final Set METRIC_SORT_FILTERS = ImmutableSortedSet.of(ALL_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER); private static final int MAX_METRIC_KEYS = 25; private static final String COMMA_JOIN_SEPARATOR = ", "; - private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = Set.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE); + private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = Set.of(ComponentQualifiers.FILE, ComponentQualifiers.UNIT_TEST_FILE); private final DbClient dbClient; private final ComponentFinder componentFinder; private final UserSession userSession; private final I18n i18n; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; public ComponentTreeAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, I18n i18n, - ResourceTypes resourceTypes) { + ComponentTypes componentTypes) { this.dbClient = dbClient; this.componentFinder = componentFinder; this.userSession = userSession; this.i18n = i18n; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; } @Override @@ -280,7 +280,7 @@ public class ComponentTreeAction implements MeasuresWsAction { join(COMMA_JOIN_SEPARATOR, UnsupportedMetrics.PARTIALLY_SUPPORTED_METRICS.get(DATA.name()))) .setMaxValuesAllowed(MAX_METRIC_KEYS); createAdditionalFieldsParameter(action); - createQualifiersParameter(action, newQualifierParameterContext(i18n, resourceTypes)); + createQualifiersParameter(action, newQualifierParameterContext(i18n, componentTypes)); action.createParam(PARAM_STRATEGY) .setDescription("Strategy to search for base component descendants:" + @@ -445,8 +445,8 @@ public class ComponentTreeAction implements MeasuresWsAction { // show them as apps, not sub-portfolios private static String getDisplayQualifier(ComponentDto component, ComponentDto referenceComponent) { String qualifier = component.qualifier(); - if (qualifier.equals(Qualifiers.SUBVIEW) && referenceComponent.qualifier().equals(Qualifiers.APP)) { - return Qualifiers.APP; + if (qualifier.equals(ComponentQualifiers.SUBVIEW) && referenceComponent.qualifier().equals(ComponentQualifiers.APP)) { + return ComponentQualifiers.APP; } return qualifier; } @@ -657,7 +657,7 @@ public class ComponentTreeAction implements MeasuresWsAction { List requestQualifiers = request.getQualifiers(); List childrenQualifiers = null; if (LEAVES_STRATEGY.equals(request.getStrategy())) { - childrenQualifiers = resourceTypes.getLeavesQualifiers(baseQualifier); + childrenQualifiers = componentTypes.getLeavesQualifiers(baseQualifier); } if (requestQualifiers == null) { @@ -693,7 +693,7 @@ public class ComponentTreeAction implements MeasuresWsAction { private void checkPermissions(ComponentDto baseComponent) { userSession.checkComponentPermission(UserRole.USER, baseComponent); - if (Scopes.PROJECT.equals(baseComponent.scope()) && Qualifiers.APP.equals(baseComponent.qualifier())) { + if (ComponentScopes.PROJECT.equals(baseComponent.scope()) && ComponentQualifiers.APP.equals(baseComponent.qualifier())) { userSession.checkChildProjectsPermission(UserRole.USER, baseComponent); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MetricDtoWithBestValue.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MetricDtoWithBestValue.java index 28f60996bad..944d8f9eea1 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MetricDtoWithBestValue.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MetricDtoWithBestValue.java @@ -22,12 +22,12 @@ package org.sonar.server.measure.ws; import com.google.common.collect.ImmutableSortedSet; import java.util.Set; import java.util.function.Predicate; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.db.component.ComponentDto; import org.sonar.db.metric.MetricDto; public class MetricDtoWithBestValue { - private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE); + private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(ComponentQualifiers.FILE, ComponentQualifiers.UNIT_TEST_FILE); private final MetricDto metric; private final Double bestValue; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java index 35c7fd89aca..50d8ed92b93 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java @@ -47,10 +47,10 @@ import static java.lang.String.format; import static java.util.Comparator.comparing; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toMap; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.SUBVIEW; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.SUBVIEW; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.db.metric.RemovedMetricConverter.DEPRECATED_METRIC_REPLACEMENT; import static org.sonar.db.metric.RemovedMetricConverter.REMOVED_METRIC; import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java index 578432f2784..4519ffb796f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java @@ -29,8 +29,8 @@ import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -190,7 +190,7 @@ public class SearchHistoryAction implements MeasuresWsAction { private ComponentDto searchComponent(SearchHistoryRequest request, DbSession dbSession) { ComponentDto component = loadComponent(dbSession, request); userSession.checkComponentPermission(UserRole.USER, component); - if (Scopes.PROJECT.equals(component.scope()) && Qualifiers.APP.equals(component.qualifier())) { + if (ComponentScopes.PROJECT.equals(component.scope()) && ComponentQualifiers.APP.equals(component.qualifier())) { userSession.checkChildProjectsPermission(UserRole.USER, component); } return component; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/RequestValidator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/RequestValidator.java index b96e294068c..f3d991a11f1 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/RequestValidator.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/RequestValidator.java @@ -25,8 +25,8 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.db.permission.GlobalPermission; import org.sonar.server.exceptions.BadRequestException; @@ -59,12 +59,12 @@ public class RequestValidator { format("The '%s' parameter for global permissions must be one of %s. '%s' was passed.", PARAM_PERMISSION, GlobalPermission.ALL_ON_ONE_LINE, permission)); } - public static void validateQualifier(@Nullable String qualifier, ResourceTypes resourceTypes) { + public static void validateQualifier(@Nullable String qualifier, ComponentTypes componentTypes) { if (qualifier == null) { return; } - Set rootQualifiers = resourceTypes.getRoots().stream() - .map(ResourceType::getQualifier) + Set rootQualifiers = componentTypes.getRoots().stream() + .map(ComponentType::getQualifier) .collect(Collectors.toSet()); checkRequest(rootQualifiers.contains(qualifier), format("The '%s' parameter must be one of %s. '%s' was passed.", PARAM_QUALIFIER, rootQualifiers, qualifier)); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java index d49eb4acddb..7ff45b10a83 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java @@ -24,7 +24,7 @@ import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Request; import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; @@ -77,7 +77,7 @@ public class PermissionWsSupport { if (uuid != null || key != null) { ProjectWsRef.validateUuidAndKeyPair(uuid, key); Optional entityDto = uuid != null ? dbClient.entityDao().selectByUuid(dbSession, uuid) : dbClient.entityDao().selectByKey(dbSession, key); - if (entityDto.isPresent() && !Qualifiers.SUBVIEW.equals(entityDto.get().getQualifier())) { + if (entityDto.isPresent() && !ComponentQualifiers.SUBVIEW.equals(entityDto.get().getQualifier())) { return entityDto.get(); } else { throw new NotFoundException("Entity not found"); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java index dcd4325dc70..483787f1ef4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.Optional; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -112,7 +112,7 @@ public class ApplyTemplateAction implements PermissionsWsAction { private EntityDto getEntityByKeyOrUuid(@Nullable String uuid, @Nullable String key, DbSession dbSession) { Optional entityDto = uuid != null ? dbClient.entityDao().selectByUuid(dbSession, uuid) : dbClient.entityDao().selectByKey(dbSession, key); - if (entityDto.isPresent() && !Qualifiers.SUBVIEW.equals(entityDto.get().getQualifier())) { + if (entityDto.isPresent() && !ComponentQualifiers.SUBVIEW.equals(entityDto.get().getQualifier())) { return entityDto.get(); } else { throw new NotFoundException("Entity not found"); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/BulkApplyTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/BulkApplyTemplateAction.java index e5270df26aa..0d2e4ba9f80 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/BulkApplyTemplateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/BulkApplyTemplateAction.java @@ -26,8 +26,8 @@ import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -77,17 +77,17 @@ public class BulkApplyTemplateAction implements PermissionsWsAction { private final PermissionTemplateService permissionTemplateService; private final PermissionWsSupport wsSupport; private final I18n i18n; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final ManagedProjectService managedProjectService; public BulkApplyTemplateAction(DbClient dbClient, UserSession userSession, PermissionTemplateService permissionTemplateService, PermissionWsSupport wsSupport, I18n i18n, - ResourceTypes resourceTypes, ManagedProjectService managedProjectService) { + ComponentTypes componentTypes, ManagedProjectService managedProjectService) { this.dbClient = dbClient; this.userSession = userSession; this.permissionTemplateService = permissionTemplateService; this.wsSupport = wsSupport; this.i18n = i18n; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.managedProjectService = managedProjectService; } @@ -109,8 +109,8 @@ public class BulkApplyTemplateAction implements PermissionsWsAction { "") .setExampleValue("apac"); - createRootQualifiersParameter(action, newQualifierParameterContext(i18n, resourceTypes)) - .setDefaultValue(Qualifiers.PROJECT); + createRootQualifiersParameter(action, newQualifierParameterContext(i18n, componentTypes)) + .setDefaultValue(ComponentQualifiers.PROJECT); WsParameters.createTemplateParameters(action); @@ -204,7 +204,7 @@ public class BulkApplyTemplateAction implements PermissionsWsAction { private String templateId; private String templateName; private String query; - private Collection qualifiers = singleton(Qualifiers.PROJECT); + private Collection qualifiers = singleton(ComponentQualifiers.PROJECT); private String visibility; private String analyzedBefore; private boolean onProvisionedOnly = false; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java index e71c075ccfc..2b439172727 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Locale; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -99,21 +99,21 @@ public class SearchTemplatesAction implements PermissionsWsAction { ResolvedDefaultTemplates resolvedDefaultTemplates = data.defaultTemplates(); response.addDefaultTemplates(templateUuidQualifierBuilder - .setQualifier(Qualifiers.PROJECT) + .setQualifier(ComponentQualifiers.PROJECT) .setTemplateId(resolvedDefaultTemplates.getProject())); resolvedDefaultTemplates.getApplication() .ifPresent(viewDefaultTemplate -> response.addDefaultTemplates( templateUuidQualifierBuilder .clear() - .setQualifier(Qualifiers.APP) + .setQualifier(ComponentQualifiers.APP) .setTemplateId(viewDefaultTemplate))); resolvedDefaultTemplates.getPortfolio() .ifPresent(viewDefaultTemplate -> response.addDefaultTemplates( templateUuidQualifierBuilder .clear() - .setQualifier(Qualifiers.VIEW) + .setQualifier(ComponentQualifiers.VIEW) .setTemplateId(viewDefaultTemplate))); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java index 02b98445977..50cdf0024a4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java @@ -21,8 +21,8 @@ package org.sonar.server.permission.ws.template; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -49,15 +49,15 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_T public class SetDefaultTemplateAction implements PermissionsWsAction { private final DbClient dbClient; private final PermissionWsSupport wsSupport; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final UserSession userSession; private final I18n i18n; - public SetDefaultTemplateAction(DbClient dbClient, PermissionWsSupport wsSupport, ResourceTypes resourceTypes, + public SetDefaultTemplateAction(DbClient dbClient, PermissionWsSupport wsSupport, ComponentTypes componentTypes, UserSession userSession, I18n i18n) { this.dbClient = dbClient; this.wsSupport = wsSupport; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.userSession = userSession; this.i18n = i18n; } @@ -79,8 +79,8 @@ public class SetDefaultTemplateAction implements PermissionsWsAction { .setHandler(this); WsParameters.createTemplateParameters(action); - createDefaultTemplateQualifierParameter(action, newQualifierParameterContext(i18n, resourceTypes)) - .setDefaultValue(Qualifiers.PROJECT); + createDefaultTemplateQualifierParameter(action, newQualifierParameterContext(i18n, componentTypes)) + .setDefaultValue(ComponentQualifiers.PROJECT); } @Override @@ -94,7 +94,7 @@ public class SetDefaultTemplateAction implements PermissionsWsAction { String qualifier = request.getQualifier(); PermissionTemplateDto template = findTemplate(dbSession, request); checkGlobalAdmin(userSession); - RequestValidator.validateQualifier(qualifier, resourceTypes); + RequestValidator.validateQualifier(qualifier, componentTypes); setDefaultTemplateUuid(dbSession, template, qualifier); dbSession.commit(); } @@ -106,13 +106,13 @@ public class SetDefaultTemplateAction implements PermissionsWsAction { private void setDefaultTemplateUuid(DbSession dbSession, PermissionTemplateDto permissionTemplateDto, String qualifier) { switch (qualifier) { - case Qualifiers.PROJECT: + case ComponentQualifiers.PROJECT: dbClient.internalPropertiesDao().save(dbSession, InternalProperties.DEFAULT_PROJECT_TEMPLATE, permissionTemplateDto.getUuid()); break; - case Qualifiers.VIEW: + case ComponentQualifiers.VIEW: dbClient.internalPropertiesDao().save(dbSession, InternalProperties.DEFAULT_PORTFOLIO_TEMPLATE, permissionTemplateDto.getUuid()); break; - case Qualifiers.APP: + case ComponentQualifiers.APP: dbClient.internalPropertiesDao().save(dbSession, InternalProperties.DEFAULT_APPLICATION_TEMPLATE, permissionTemplateDto.getUuid()); break; default: diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java index 7344511d809..47ef9714f07 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java @@ -54,9 +54,9 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.lang.Math.min; import static java.lang.String.format; import static java.util.stream.Collectors.toSet; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.db.Pagination.forPage; import static org.sonar.server.project.ws.SearchAction.buildDbQuery; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/CreateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/CreateAction.java index d76aff13413..9d8e5a5c509 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/CreateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/CreateAction.java @@ -44,7 +44,7 @@ import org.sonarqube.ws.Projects.CreateWsResponse; import static java.util.Objects.requireNonNull; import static org.apache.commons.lang3.StringUtils.abbreviate; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.core.component.ComponentKeys.MAX_COMPONENT_KEY_LENGTH; import static org.sonar.db.component.ComponentValidator.MAX_COMPONENT_NAME_LENGTH; import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java index 262cf3f127d..3752dac68fc 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java @@ -48,9 +48,9 @@ import org.sonarqube.ws.Projects.SearchWsResponse; import static java.util.Optional.ofNullable; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toMap; -import static org.sonar.api.resources.Qualifiers.APP; -import static org.sonar.api.resources.Qualifiers.PROJECT; -import static org.sonar.api.resources.Qualifiers.VIEW; +import static org.sonar.db.component.ComponentQualifiers.APP; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.VIEW; import static org.sonar.api.utils.DateUtils.formatDateTime; import static org.sonar.api.utils.DateUtils.parseDateOrDateTime; import static org.sonar.db.Pagination.forPage; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java index 6aa328a0ed8..f55abb86781 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java @@ -27,7 +27,7 @@ import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -202,7 +202,7 @@ public class SearchMyProjectsAction implements ProjectsWsAction { private ProjectsResult searchProjects(DbSession dbSession, SearchMyProjectsRequest request) { String userUuid = requireNonNull(userSession.getUuid(), "Current user must be authenticated"); - List entitiesUuid = dbClient.roleDao().selectEntityUuidsByPermissionAndUserUuidAndQualifier(dbSession, UserRole.ADMIN, userUuid, Set.of(Qualifiers.PROJECT)); + List entitiesUuid = dbClient.roleDao().selectEntityUuidsByPermissionAndUserUuidAndQualifier(dbSession, UserRole.ADMIN, userUuid, Set.of(ComponentQualifiers.PROJECT)); ImmutableSet subSetEntityUuids = ImmutableSet.copyOf(entitiesUuid.subList(0, Math.min(entitiesUuid.size(), DatabaseUtils.PARTITION_SIZE_FOR_ORACLE))); Pagination pagination = Pagination.forPage(request.page).andSize(request.pageSize); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchRequest.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchRequest.java index 0395c79a2ae..8f7aad47157 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchRequest.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchRequest.java @@ -22,7 +22,7 @@ package org.sonar.server.project.ws; import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Collections.singletonList; @@ -94,7 +94,7 @@ class SearchRequest { } public static class Builder { - private List qualifiers = singletonList(Qualifiers.PROJECT); + private List qualifiers = singletonList(ComponentQualifiers.PROJECT); private Integer page; private Integer pageSize; private String query; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java index 81131c7237d..a6a11b646bf 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java @@ -22,7 +22,7 @@ package org.sonar.server.projectanalysis.ws; import java.util.List; import java.util.function.Consumer; import java.util.function.Predicate; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -141,7 +141,7 @@ public class CreateEventAction implements ProjectAnalysesWsAction { private void checkRequest(CreateEventRequest request, ProjectDto project) { userSession.checkEntityPermission(UserRole.ADMIN, project); - checkArgument(EventCategory.VERSION != request.getCategory() || Qualifiers.PROJECT.equals(project.getQualifier()), "A version event must be created on a project"); + checkArgument(EventCategory.VERSION != request.getCategory() || ComponentQualifiers.PROJECT.equals(project.getQualifier()), "A version event must be created on a project"); checkVersionName(request.getCategory(), request.getName()); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java index 7c1481a3c0f..af3da76160d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java @@ -22,8 +22,8 @@ package org.sonar.server.projectanalysis.ws; import java.util.EnumSet; import java.util.List; import java.util.Set; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -62,7 +62,7 @@ import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class SearchAction implements ProjectAnalysesWsAction { - private static final Set ALLOWED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.APP, Qualifiers.VIEW); + private static final Set ALLOWED_QUALIFIERS = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.APP, ComponentQualifiers.VIEW); private final DbClient dbClient; private final ComponentFinder componentFinder; @@ -192,14 +192,14 @@ public class SearchAction implements ProjectAnalysesWsAction { private void checkPermission(ComponentDto project) { userSession.checkComponentPermission(UserRole.USER, project); - if (Scopes.PROJECT.equals(project.scope()) && Qualifiers.APP.equals(project.qualifier())) { + if (ComponentScopes.PROJECT.equals(project.scope()) && ComponentQualifiers.APP.equals(project.qualifier())) { userSession.checkChildProjectsPermission(UserRole.USER, project); } } private void addProject(SearchData.Builder data) { ComponentDto project = loadComponent(data.getDbSession(), data.getRequest()); - checkArgument(Scopes.PROJECT.equals(project.scope()) && ALLOWED_QUALIFIERS.contains(project.qualifier()), "A project, portfolio or application is required"); + checkArgument(ComponentScopes.PROJECT.equals(project.scope()) && ALLOWED_QUALIFIERS.contains(project.qualifier()), "A project, portfolio or application is required"); data.setProject(project); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java index 260d0b246b2..6af186251ac 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/SettingValidations.java @@ -39,7 +39,7 @@ import org.apache.commons.io.IOUtils; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.core.i18n.I18n; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -58,7 +58,7 @@ public class SettingValidations { "sonar.security.config.pythonsecurity", "sonar.security.config.roslyn.sonaranalyzer.security.cs" ); - private static final Set SUPPORTED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP, Qualifiers.SUBVIEW); + private static final Set SUPPORTED_QUALIFIERS = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW, ComponentQualifiers.APP, ComponentQualifiers.SUBVIEW); private final PropertyDefinitions definitions; private final DbClient dbClient; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java index 9fed1e84f89..842f557aad1 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java @@ -30,10 +30,10 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nullable; import org.sonar.api.config.Configuration; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; -import org.sonar.api.resources.Scopes; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; +import org.sonar.db.component.ComponentScopes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -77,7 +77,7 @@ import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001; public class ComponentAction implements NavigationWsAction { - private static final Set MODULE_OR_DIR_QUALIFIERS = Set.of(Qualifiers.MODULE, Qualifiers.DIRECTORY); + private static final Set MODULE_OR_DIR_QUALIFIERS = Set.of(ComponentQualifiers.MODULE, ComponentQualifiers.DIRECTORY); static final String PARAM_COMPONENT = "component"; private static final String PARAM_BRANCH = "branch"; private static final String PARAM_PULL_REQUEST = "pullRequest"; @@ -89,21 +89,21 @@ public class ComponentAction implements NavigationWsAction { /** * The concept of "visibility" will only be configured for these qualifiers. */ - private static final Set QUALIFIERS_WITH_VISIBILITY = Set.of(Qualifiers.PROJECT, Qualifiers.VIEW, Qualifiers.APP); + private static final Set QUALIFIERS_WITH_VISIBILITY = Set.of(ComponentQualifiers.PROJECT, ComponentQualifiers.VIEW, ComponentQualifiers.APP); private final DbClient dbClient; private final PageRepository pageRepository; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final UserSession userSession; private final ComponentFinder componentFinder; private final QualityGateFinder qualityGateFinder; private final Configuration config; - public ComponentAction(DbClient dbClient, PageRepository pageRepository, ResourceTypes resourceTypes, UserSession userSession, + public ComponentAction(DbClient dbClient, PageRepository pageRepository, ComponentTypes componentTypes, UserSession userSession, ComponentFinder componentFinder, QualityGateFinder qualityGateFinder, Configuration config) { this.dbClient = dbClient; this.pageRepository = pageRepository; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.userSession = userSession; this.componentFinder = componentFinder; this.qualityGateFinder = qualityGateFinder; @@ -215,10 +215,10 @@ public class ComponentAction implements NavigationWsAction { if (branchKey != null) { json.prop("branch", branchKey); } - if (Qualifiers.APP.equals(component.qualifier())) { + if (ComponentQualifiers.APP.equals(component.qualifier())) { json.prop("canBrowseAllChildProjects", userSession.hasChildProjectsPermission(USER, component)); } - if (Qualifiers.VIEW.equals(component.qualifier()) || Qualifiers.SUBVIEW.equals(component.qualifier())) { + if (ComponentQualifiers.VIEW.equals(component.qualifier()) || ComponentQualifiers.SUBVIEW.equals(component.qualifier())) { json.prop("canBrowseAllChildProjects", userSession.hasPortfolioChildProjectsPermission(USER, component)); } if (QUALIFIERS_WITH_VISIBILITY.contains(component.qualifier())) { @@ -243,7 +243,7 @@ public class ComponentAction implements NavigationWsAction { } private static boolean isSubview(ComponentDto component) { - return Qualifiers.SUBVIEW.equals(component.qualifier()) && Scopes.PROJECT.equals(component.scope()); + return ComponentQualifiers.SUBVIEW.equals(component.qualifier()) && ComponentScopes.PROJECT.equals(component.scope()); } private void writeProfiles(JsonWriter json, DbSession dbSession, ComponentDto component) { @@ -296,8 +296,8 @@ public class ComponentAction implements NavigationWsAction { } private void writeConfigPageAccess(JsonWriter json, boolean isProjectAdmin, ComponentDto component) { - boolean isProject = Qualifiers.PROJECT.equals(component.qualifier()); - boolean showBackgroundTasks = isProjectAdmin && (isProject || Qualifiers.VIEW.equals(component.qualifier()) || Qualifiers.APP.equals(component.qualifier())); + boolean isProject = ComponentQualifiers.PROJECT.equals(component.qualifier()); + boolean showBackgroundTasks = isProjectAdmin && (isProject || ComponentQualifiers.VIEW.equals(component.qualifier()) || ComponentQualifiers.APP.equals(component.qualifier())); boolean isQualityProfileAdmin = userSession.hasPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES); boolean isQualityGateAdmin = userSession.hasPermission(GlobalPermission.ADMINISTER_QUALITY_GATES); boolean isGlobalAdmin = userSession.hasPermission(GlobalPermission.ADMINISTER); @@ -320,8 +320,8 @@ public class ComponentAction implements NavigationWsAction { } private boolean componentTypeHasProperty(ComponentDto component, String resourceTypeProperty) { - ResourceType resourceType = resourceTypes.get(component.qualifier()); - return resourceType != null && resourceType.getBooleanProperty(resourceTypeProperty); + ComponentType componentType = componentTypes.get(component.qualifier()); + return componentType != null && componentType.getBooleanProperty(resourceTypeProperty); } private void writeBreadCrumbs(JsonWriter json, DbSession session, ComponentDto component) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java index 5ac651b5469..f346a7604ef 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java @@ -26,8 +26,8 @@ import java.util.Set; import org.sonar.api.Startable; import org.sonar.api.config.Configuration; import org.sonar.api.platform.Server; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -71,7 +71,7 @@ public class GlobalAction implements NavigationWsAction, Startable { private final PageRepository pageRepository; private final Configuration config; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; private final Server server; private final NodeInformation nodeInformation; private final DbClient dbClient; @@ -82,13 +82,13 @@ public class GlobalAction implements NavigationWsAction, Startable { private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier; private final DocumentationLinkGenerator documentationLinkGenerator; - public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server, + public GlobalAction(PageRepository pageRepository, Configuration config, ComponentTypes componentTypes, Server server, NodeInformation nodeInformation, DbClient dbClient, UserSession userSession, PlatformEditionProvider editionProvider, WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker, DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier, DocumentationLinkGenerator documentationLinkGenerator) { this.pageRepository = pageRepository; this.config = config; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; this.server = server; this.nodeInformation = nodeInformation; this.dbClient = dbClient; @@ -173,7 +173,7 @@ public class GlobalAction implements NavigationWsAction, Startable { private void writeQualifiers(JsonWriter json) { json.name("qualifiers").beginArray(); - for (ResourceType rootType : resourceTypes.getRoots()) { + for (ComponentType rootType : componentTypes.getRoots()) { json.value(rootType.getQualifier()); } json.endArray(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/NewComponentTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/NewComponentTest.java index ab704771472..6bc983b1953 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/NewComponentTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/NewComponentTest.java @@ -26,7 +26,7 @@ import static com.google.common.base.Strings.repeat; import static org.apache.commons.lang3.RandomStringUtils.secure; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.sonar.api.resources.Qualifiers.PROJECT; +import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.server.common.component.NewComponent.newComponentBuilder; public class NewComponentTest { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java index a9c02e9ca39..f6bccfc8e72 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchResponseFormatFormatOperationTest.java @@ -58,7 +58,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE; +import static org.sonar.db.component.ComponentQualifiers.UNIT_TEST_FILE; import static org.sonar.api.rule.RuleKey.EXTERNAL_RULE_REPO_PREFIX; import static org.sonar.api.rules.RuleType.CODE_SMELL; import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java index 4daeb93fbd6..aedd9bad2c2 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeSortTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; import org.sonar.api.issue.impact.Severity; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric.ValueType; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.core.util.Uuids; import org.sonar.db.component.ComponentDto; import org.sonar.db.metric.MetricDto; @@ -164,9 +164,9 @@ class ComponentTreeSortTest { @Test void sort_by_name_ascending_in_case_of_equality() { components = newArrayList( - newComponentWithoutSnapshotId("PROJECT 12", Qualifiers.PROJECT, "PROJECT_PATH_1"), - newComponentWithoutSnapshotId("PROJECT 11", Qualifiers.PROJECT, "PROJECT_PATH_1"), - newComponentWithoutSnapshotId("PROJECT 0", Qualifiers.PROJECT, "PROJECT_PATH_2")); + newComponentWithoutSnapshotId("PROJECT 12", ComponentQualifiers.PROJECT, "PROJECT_PATH_1"), + newComponentWithoutSnapshotId("PROJECT 11", ComponentQualifiers.PROJECT, "PROJECT_PATH_1"), + newComponentWithoutSnapshotId("PROJECT 0", ComponentQualifiers.PROJECT, "PROJECT_PATH_2")); ComponentTreeRequest wsRequest = newRequest(newArrayList(PATH_SORT), false, null); @@ -178,10 +178,10 @@ class ComponentTreeSortTest { @Test void sort_by_alert_status_ascending() { components = newArrayList( - newComponentWithoutSnapshotId("PROJECT OK 1", Qualifiers.PROJECT, "PROJECT_OK_PATH_1"), - newComponentWithoutSnapshotId("PROJECT ERROR 1", Qualifiers.PROJECT, "PROJECT_ERROR_PATH_1"), - newComponentWithoutSnapshotId("PROJECT OK 2", Qualifiers.PROJECT, "PROJECT_OK_PATH_2"), - newComponentWithoutSnapshotId("PROJECT ERROR 2", Qualifiers.PROJECT, "PROJECT_ERROR_PATH_2")); + newComponentWithoutSnapshotId("PROJECT OK 1", ComponentQualifiers.PROJECT, "PROJECT_OK_PATH_1"), + newComponentWithoutSnapshotId("PROJECT ERROR 1", ComponentQualifiers.PROJECT, "PROJECT_ERROR_PATH_1"), + newComponentWithoutSnapshotId("PROJECT OK 2", ComponentQualifiers.PROJECT, "PROJECT_OK_PATH_2"), + newComponentWithoutSnapshotId("PROJECT ERROR 2", ComponentQualifiers.PROJECT, "PROJECT_ERROR_PATH_2")); metrics = singletonList(newMetricDto() .setKey(CoreMetrics.ALERT_STATUS_KEY) .setValueType(ValueType.LEVEL.name())); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java index 6f2984ca0a8..4e94dda6b45 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java @@ -23,7 +23,7 @@ import java.util.List; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.resources.Qualifiers; +import org.sonar.db.component.ComponentQualifiers; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.web.page.Page; import org.sonar.api.web.page.Page.Qualifier; @@ -89,7 +89,7 @@ public class PageRepositoryTest { underTest = new PageRepository(pluginRepository, coreExtensionRepository, new PageDefinition[]{plugin}); underTest.start(); - List result = underTest.getComponentPages(false, Qualifiers.PROJECT); + List result = underTest.getComponentPages(false, ComponentQualifiers.PROJECT); assertThat(result) .extracting(Page::getKey) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index 9faee23bd61..9a39e3e399f 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -27,9 +27,9 @@ import org.mockito.MockedStatic; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.internal.MetadataLoader; import org.sonar.api.platform.Server; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypeTree; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypeTree; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.web.page.Page; import org.sonar.api.web.page.PageDefinition; import org.sonar.core.documentation.DocumentationLinkGenerator; @@ -89,15 +89,15 @@ class GlobalActionTest { @Test void return_qualifiers() { - init(new Page[]{}, new ResourceTypeTree[]{ - ResourceTypeTree.builder() - .addType(ResourceType.builder("POL").build()) - .addType(ResourceType.builder("LOP").build()) + init(new Page[]{}, new ComponentTypeTree[]{ + ComponentTypeTree.builder() + .addType(ComponentType.builder("POL").build()) + .addType(ComponentType.builder("LOP").build()) .addRelations("POL", "LOP") .build(), - ResourceTypeTree.builder() - .addType(ResourceType.builder("PAL").build()) - .addType(ResourceType.builder("LAP").build()) + ComponentTypeTree.builder() + .addType(ComponentType.builder("PAL").build()) + .addType(ComponentType.builder("LAP").build()) .addRelations("PAL", "LAP") .build() }); @@ -163,7 +163,7 @@ class GlobalActionTest { @Test void the_returned_global_pages_do_not_include_administration_pages() { - init(createPages(), new ResourceTypeTree[]{}); + init(createPages(), new ComponentTypeTree[]{}); assertJson(call()).isSimilarTo("{" + " \"globalPages\": [" + @@ -280,15 +280,15 @@ class GlobalActionTest { settings.setProperty("sonar.lf.enableGravatar", true); settings.setProperty("sonar.updatecenter.activate", false); settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5"); - init(createPages(), new ResourceTypeTree[]{ - ResourceTypeTree.builder() - .addType(ResourceType.builder("POL").build()) - .addType(ResourceType.builder("LOP").build()) + init(createPages(), new ComponentTypeTree[]{ + ComponentTypeTree.builder() + .addType(ComponentType.builder("POL").build()) + .addType(ComponentType.builder("LOP").build()) .addRelations("POL", "LOP") .build(), - ResourceTypeTree.builder() - .addType(ResourceType.builder("PAL").build()) - .addType(ResourceType.builder("LAP").build()) + ComponentTypeTree.builder() + .addType(ComponentType.builder("PAL").build()) + .addType(ComponentType.builder("LAP").build()) .addRelations("PAL", "LAP") .build() }); @@ -356,10 +356,10 @@ class GlobalActionTest { } private void init() { - init(new org.sonar.api.web.page.Page[]{}, new ResourceTypeTree[]{}); + init(new org.sonar.api.web.page.Page[]{}, new ComponentTypeTree[]{}); } - private void init(org.sonar.api.web.page.Page[] pages, ResourceTypeTree[] resourceTypeTrees) { + private void init(org.sonar.api.web.page.Page[] pages, ComponentTypeTree[] componentTypeTrees) { when(dbClient.getDatabase().getDialect()).thenReturn(new H2()); when(server.getVersion()).thenReturn("6.42"); PluginRepository pluginRepository = mock(PluginRepository.class); @@ -373,7 +373,7 @@ class GlobalActionTest { } }}); pageRepository.start(); - GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server, + GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ComponentTypes(componentTypeTrees), server, nodeInformation, dbClient, userSession, editionProvider, webAnalyticsLoader, indexSyncProgressChecker, defaultAdminCredentialsVerifier, documentationLinkGenerator); ws = new WsActionTester(wsAction); diff --git a/server/sonar-webserver-webapi/src/testFixtures/java/org/sonar/server/component/TestComponentFinder.java b/server/sonar-webserver-webapi/src/testFixtures/java/org/sonar/server/component/TestComponentFinder.java index c0f894f4cc0..ca41fa55b41 100644 --- a/server/sonar-webserver-webapi/src/testFixtures/java/org/sonar/server/component/TestComponentFinder.java +++ b/server/sonar-webserver-webapi/src/testFixtures/java/org/sonar/server/component/TestComponentFinder.java @@ -19,18 +19,16 @@ */ package org.sonar.server.component; -import org.sonar.api.resources.Qualifiers; -import org.sonar.api.resources.ResourceTypes; import org.sonar.db.DbClient; import org.sonar.db.DbTester; -import org.sonar.db.component.ResourceTypesRule; +import org.sonar.db.component.ComponentQualifiers; public class TestComponentFinder extends ComponentFinder { - private TestComponentFinder(DbClient dbClient, ResourceTypes resourceTypes) { - super(dbClient, resourceTypes); + private TestComponentFinder(DbClient dbClient, ComponentTypes componentTypes) { + super(dbClient, componentTypes); } public static TestComponentFinder from(DbTester dbTester) { - return new TestComponentFinder(dbTester.getDbClient(), new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)); + return new TestComponentFinder(dbTester.getDbClient(), new ComponentTypesRule().setRootQualifiers(ComponentQualifiers.PROJECT)); } } diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java index d466e4d29f9..7be099820c7 100644 --- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java +++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java @@ -23,8 +23,8 @@ import java.util.Locale; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService; import org.sonar.core.i18n.I18n; @@ -71,22 +71,22 @@ public class WsParameterBuilder { .setPossibleValues(filteredQualifiers); } - private static Set getRootQualifiers(ResourceTypes resourceTypes) { - return resourceTypes.getRoots().stream() - .map(ResourceType::getQualifier) + private static Set getRootQualifiers(ComponentTypes componentTypes) { + return componentTypes.getRoots().stream() + .map(ComponentType::getQualifier) .collect(Collectors.toCollection(TreeSet::new)); } - private static Set getDefaultTemplateQualifiers(ResourceTypes resourceTypes) { - return resourceTypes.getRoots().stream() - .map(ResourceType::getQualifier) + private static Set getDefaultTemplateQualifiers(ComponentTypes componentTypes) { + return componentTypes.getRoots().stream() + .map(ComponentType::getQualifier) .collect(Collectors.toCollection(TreeSet::new)); } - private static Set getAllQualifiers(ResourceTypes resourceTypes) { - return resourceTypes.getAll().stream() + private static Set getAllQualifiers(ComponentTypes componentTypes) { + return componentTypes.getAll().stream() .filter(r -> !r.getBooleanProperty("ignored")) - .map(ResourceType::getQualifier) + .map(ComponentType::getQualifier) .collect(Collectors.toCollection(TreeSet::new)); } @@ -117,23 +117,23 @@ public class WsParameterBuilder { public static class QualifierParameterContext { private final I18n i18n; - private final ResourceTypes resourceTypes; + private final ComponentTypes componentTypes; - private QualifierParameterContext(I18n i18n, ResourceTypes resourceTypes) { + private QualifierParameterContext(I18n i18n, ComponentTypes componentTypes) { this.i18n = i18n; - this.resourceTypes = resourceTypes; + this.componentTypes = componentTypes; } - public static QualifierParameterContext newQualifierParameterContext(I18n i18n, ResourceTypes resourceTypes) { - return new QualifierParameterContext(i18n, resourceTypes); + public static QualifierParameterContext newQualifierParameterContext(I18n i18n, ComponentTypes componentTypes) { + return new QualifierParameterContext(i18n, componentTypes); } public I18n getI18n() { return i18n; } - public ResourceTypes getResourceTypes() { - return resourceTypes; + public ComponentTypes getResourceTypes() { + return componentTypes; } } } diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java index fc6e4ab8154..6114cf8a24c 100644 --- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java +++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java @@ -22,8 +22,8 @@ package org.sonar.server.ws; import com.google.common.collect.Sets; import java.util.Collection; import org.junit.Test; -import org.sonar.api.resources.ResourceType; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentType; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.ws.WebService.NewAction; import org.sonar.api.server.ws.WebService.NewParam; import org.sonar.core.i18n.I18n; @@ -41,9 +41,9 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_Q public class WsParameterBuilderTest { - private ResourceTypes resourceTypes = mock(ResourceTypes.class); - private static final ResourceType Q1 = ResourceType.builder("Q1").build(); - private static final ResourceType Q2 = ResourceType.builder("Q2").build(); + private ComponentTypes componentTypes = mock(ComponentTypes.class); + private static final ComponentType Q1 = ComponentType.builder("Q1").build(); + private static final ComponentType Q2 = ComponentType.builder("Q2").build(); private I18n i18n = mock(I18n.class); private NewAction newAction = mock(NewAction.class); @@ -51,7 +51,7 @@ public class WsParameterBuilderTest { @Test public void test_createRootQualifierParameter() { - when(resourceTypes.getRoots()).thenReturn(asList(Q1, Q2)); + when(componentTypes.getRoots()).thenReturn(asList(Q1, Q2)); when(newAction.createParam(PARAM_QUALIFIER)).thenReturn(newParam); when(newParam.setDescription(startsWith("Project qualifier. Filter the results with the specified qualifier. " + "Possible values are:" @@ -59,14 +59,14 @@ public class WsParameterBuilderTest { + "
  • Q2 - null
  • "))).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createRootQualifierParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createRootQualifierParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); assertThat(newParam).isNotNull(); } @Test public void test_createRootQualifiersParameter() { - when(resourceTypes.getRoots()).thenReturn(asList(Q1, Q2)); + when(componentTypes.getRoots()).thenReturn(asList(Q1, Q2)); when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam); when(newParam.setDescription(startsWith("Comma-separated list of component qualifiers. Filter the results with the specified qualifiers. " + "Possible values are:" @@ -74,14 +74,14 @@ public class WsParameterBuilderTest { + "
  • Q2 - null
  • "))).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createRootQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createRootQualifiersParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); assertThat(newParam).isNotNull(); } @Test public void test_createDefaultTemplateQualifierParameter() { - when(resourceTypes.getRoots()).thenReturn(asList(Q1, Q2)); + when(componentTypes.getRoots()).thenReturn(asList(Q1, Q2)); when(newAction.createParam(PARAM_QUALIFIER)).thenReturn(newParam); when(newParam.setDescription(startsWith("Project qualifier. Filter the results with the specified qualifier. " + "Possible values are:" @@ -89,14 +89,14 @@ public class WsParameterBuilderTest { + "
  • Q2 - null
  • "))).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createDefaultTemplateQualifierParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createDefaultTemplateQualifierParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); assertThat(newParam).isNotNull(); } @Test public void test_createQualifiersParameter() { - when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2)); + when(componentTypes.getAll()).thenReturn(asList(Q1, Q2)); when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam); when(newParam.setDescription(startsWith("Comma-separated list of component qualifiers. Filter the results with the specified qualifiers. " + "Possible values are:" @@ -104,21 +104,21 @@ public class WsParameterBuilderTest { + "
  • Q2 - null
  • "))).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); assertThat(newParam).isNotNull(); } @Test public void test_createQualifiersParameter_with_filter() { - when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2)); + when(componentTypes.getAll()).thenReturn(asList(Q1, Q2)); when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam); when(newParam.setDescription(startsWith("Comma-separated list of component qualifiers. Filter the results with the specified qualifiers. " + "Possible values are:" + "
    • Q1 - null
    "))).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes), Sets.newHashSet(Q1.getQualifier())); + .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, componentTypes), Sets.newHashSet(Q1.getQualifier())); assertThat(newParam).isNotNull(); } @@ -126,25 +126,25 @@ public class WsParameterBuilderTest { @Test public void createQualifiersParameter_whenIgnoreIsSetToTrue_shouldNotReturnQualifier(){ - when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2,ResourceType.builder("Q3").setProperty("ignored", true).build())); + when(componentTypes.getAll()).thenReturn(asList(Q1, Q2, ComponentType.builder("Q3").setProperty("ignored", true).build())); when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); when(newParam.setDescription(any())).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); verify(newParam).setPossibleValues(Sets.newHashSet(Q1.getQualifier(), Q2.getQualifier())); } @Test public void createQualifiersParameter_whenIgnoreIsSetToFalse_shouldReturnQualifier(){ - ResourceType q3Qualifier = ResourceType.builder("Q3").setProperty("ignored", false).build(); - when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2, q3Qualifier)); + ComponentType q3Qualifier = ComponentType.builder("Q3").setProperty("ignored", false).build(); + when(componentTypes.getAll()).thenReturn(asList(Q1, Q2, q3Qualifier)); when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam); when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam); when(newParam.setDescription(any())).thenReturn(newParam); NewParam newParam = WsParameterBuilder - .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes)); + .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, componentTypes)); verify(newParam).setPossibleValues(Sets.newHashSet(Q1.getQualifier(), Q2.getQualifier(), q3Qualifier.getQualifier())); } diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 920bab6fbd1..9da8b6da3a4 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -41,7 +41,7 @@ import org.sonar.alm.client.gitlab.GitlabApplicationHttpClient; import org.sonar.alm.client.gitlab.GitlabGlobalSettingsValidator; import org.sonar.alm.client.gitlab.GitlabHeaders; import org.sonar.alm.client.gitlab.GitlabPaginatedHttpClient; -import org.sonar.api.resources.ResourceTypes; +import org.sonar.server.component.ComponentTypes; import org.sonar.api.server.rule.RulesDefinitionXmlLoader; import org.sonar.auth.bitbucket.BitbucketModule; import org.sonar.auth.github.GitHubModule; @@ -54,7 +54,7 @@ import org.sonar.ce.task.projectanalysis.taskprocessor.AuditPurgeTaskProcessor; import org.sonar.ce.task.projectanalysis.taskprocessor.IssueSyncTaskProcessor; import org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor; import org.sonar.ce.task.projectexport.taskprocessor.ProjectExportTaskProcessor; -import org.sonar.core.component.DefaultResourceTypes; +import org.sonar.server.component.DefaultComponentTypes; import org.sonar.core.documentation.DefaultDocumentationLinkGenerator; import org.sonar.core.extension.CoreExtensionsInstaller; import org.sonar.core.language.LanguagesProvider; @@ -331,8 +331,8 @@ public class PlatformLevel4 extends PlatformLevel { PluginUninstaller.class, PluginDownloader.class, PageRepository.class, - ResourceTypes.class, - DefaultResourceTypes.get(), + ComponentTypes.class, + DefaultComponentTypes.get(), SettingsChangeNotifier.class, ServerWs.class, IndexDefinitions.class, diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index 538964a8117..440c6d09ff4 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -26,7 +26,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.PropertyType; import org.sonar.api.config.EmailSettings; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.core.documentation.DefaultDocumentationLinkGenerator; import org.sonar.core.extension.PluginRiskConsent; @@ -78,7 +78,7 @@ public class CorePropertyDefinitions { "necessary changes, clear this setting to prevent analysis from showing a warning about it.") .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_MODULES) - .onlyOnQualifiers(Qualifiers.PROJECT) + .onlyOnConfigScopes(ConfigScope.PROJECT) .type(TEXT) .build(), PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL) @@ -179,7 +179,7 @@ public class CorePropertyDefinitions { .description("Don't show issue facets aggregating information per developer") .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_ISSUES) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .type(BOOLEAN) .defaultValue(Boolean.toString(false)) .build(), @@ -189,7 +189,7 @@ public class CorePropertyDefinitions { .description("New issues will be assigned to this user each time it is not possible to determine the user who is the author of the issue.") .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_ISSUES) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .type(PropertyType.USER_LOGIN) .build(), @@ -199,7 +199,7 @@ public class CorePropertyDefinitions { .description("Quality Gate conditions about duplications in new code and coverage on new code are ignored until the number of new lines is at least 20.") .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_QUALITY_GATE) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .type(BOOLEAN) .defaultValue(Boolean.toString(true)) .build(), @@ -214,7 +214,7 @@ public class CorePropertyDefinitions { + "this property will significantly increase each SonarQube analysis time, " + "and therefore badly impact the performances of report processing as more and more projects " + "are getting involved in this cross project duplication mechanism.") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_GENERAL) .subCategory(CoreProperties.SUBCATEGORY_DUPLICATIONS) .type(BOOLEAN) @@ -224,7 +224,7 @@ public class CorePropertyDefinitions { .name("Duplication Exclusions") .description("Patterns used to exclude some source files from the duplication detection mechanism. " + "See below to know how to use wildcards to specify this property.") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_EXCLUSIONS) .subCategory(CoreProperties.SUBCATEGORY_DUPLICATIONS_EXCLUSIONS) .multiValues(true) diff --git a/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java index 0f384a4accf..248d64e4f6a 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java @@ -23,7 +23,7 @@ import java.util.List; import org.sonar.api.CoreProperties; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; public class ExclusionProperties { @@ -40,7 +40,7 @@ public class ExclusionProperties { .subCategory(CoreProperties.SUBCATEGORY_COVERAGE_EXCLUSIONS) .type(PropertyType.STRING) .multiValues(true) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build(), // FILES @@ -64,7 +64,7 @@ public class ExclusionProperties { .multiValues(true) .category(CoreProperties.CATEGORY_EXCLUSIONS) .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(0) .build(), @@ -73,7 +73,7 @@ public class ExclusionProperties { .multiValues(true) .category(CoreProperties.CATEGORY_EXCLUSIONS) .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(1) .build(), PropertyDefinition.builder(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY) @@ -81,7 +81,7 @@ public class ExclusionProperties { .multiValues(true) .category(CoreProperties.CATEGORY_EXCLUSIONS) .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(2) .build(), PropertyDefinition.builder(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY) @@ -89,7 +89,7 @@ public class ExclusionProperties { .multiValues(true) .category(CoreProperties.CATEGORY_EXCLUSIONS) .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(3) .build() diff --git a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java index cf2db944d51..c77ea4fbf3e 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java @@ -23,8 +23,8 @@ import java.util.List; import org.sonar.api.CoreProperties; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.api.config.PropertyFieldDefinition; -import org.sonar.api.resources.Qualifiers; public final class IssueExclusionProperties { @@ -64,7 +64,7 @@ public final class IssueExclusionProperties { .subCategory(SUB_CATEGORY_IGNORE_ISSUES) .name("Ignore Issues on Multiple Criteria") .description("Patterns to ignore issues on certain components and for certain coding rules." + PROPERTY_RULE_KEY_PATTERN_HELP) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(3) .fields( PropertyFieldDefinition.build(RULE_KEY) @@ -85,7 +85,7 @@ public final class IssueExclusionProperties { .name("Ignore Issues in Blocks") .description("Patterns to ignore all issues on specific blocks of code, " + "while continuing to scan and mark issues on the remainder of the file.") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(2) .fields( PropertyFieldDefinition.build(BEGIN_BLOCK_REGEXP) @@ -105,7 +105,7 @@ public final class IssueExclusionProperties { .subCategory(SUB_CATEGORY_IGNORE_ISSUES) .name("Ignore Issues on Files") .description("Patterns to ignore all issues on files that contain a block of code matching a given regular expression.") - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(1) .fields( PropertyFieldDefinition.build(FILE_REGEXP) @@ -120,7 +120,7 @@ public final class IssueExclusionProperties { .subCategory(SUB_CATEGORY_IGNORE_ISSUES) .name("Restrict Scope of Coding Rules") .description("Patterns to restrict the application of a rule to only certain components, ignoring all others." + PROPERTY_RULE_KEY_PATTERN_HELP) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .index(4) .fields( PropertyFieldDefinition.build(RULE_KEY) diff --git a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java index c1068e385c1..255f8fbbc8f 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java @@ -23,7 +23,7 @@ import java.util.List; import org.sonar.api.CoreProperties; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import static java.util.Arrays.asList; import static org.sonar.core.config.Frequency.MONTHLY; @@ -42,7 +42,7 @@ public final class PurgeProperties { .description("After this number of hours, if there are several analyses during the same day, " + "the DbCleaner keeps the most recent one and fully deletes the other ones.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(1) @@ -54,7 +54,7 @@ public final class PurgeProperties { .description("After this number of weeks, if there are several analyses during the same week, " + "the DbCleaner keeps the most recent one and fully deletes the other ones") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(2) @@ -66,7 +66,7 @@ public final class PurgeProperties { .description("After this number of weeks, if there are several analyses during the same month, " + "the DbCleaner keeps the most recent one and fully deletes the other ones.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(3) @@ -77,7 +77,7 @@ public final class PurgeProperties { .name("Keep only analyses with a version event after") .description("After this number of weeks, the DbCleaner keeps only analyses with a version event associated.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(4) @@ -88,7 +88,7 @@ public final class PurgeProperties { .name("Delete all analyses after") .description("After this number of weeks, all analyses are fully deleted.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(5) @@ -99,7 +99,7 @@ public final class PurgeProperties { .name("Delete closed issues after") .description("Issues that have been closed for more than this number of days will be deleted.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(6) @@ -110,7 +110,7 @@ public final class PurgeProperties { .name("Delete anticipated transitions after") .description("Anticipated transitions that have not been applied for more than this number of days will be deleted.") .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .category(CoreProperties.CATEGORY_HOUSEKEEPING) .subCategory(CoreProperties.SUBCATEGORY_GENERAL) .index(7) diff --git a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java index f919a44db58..e024b91cfca 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java @@ -22,7 +22,7 @@ package org.sonar.core.config; import java.util.List; import org.sonar.api.CoreProperties; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import static java.util.Arrays.asList; import static org.sonar.api.PropertyType.BOOLEAN; @@ -53,14 +53,14 @@ public class ScannerProperties { .description("Disable the retrieval of blame information from Source Control Manager") .category(CoreProperties.CATEGORY_SCM) .type(BOOLEAN) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .defaultValue(String.valueOf(false)) .build(), PropertyDefinition.builder(CoreProperties.SCM_PROVIDER_KEY) .name("Key of the SCM provider for this project") .description("Force the provider to be used to get SCM information for this project. By default auto-detection is done. Example: svn, git.") .category(CoreProperties.CATEGORY_SCM) - .onlyOnQualifiers(Qualifiers.PROJECT) + .onlyOnConfigScopes(ConfigScope.PROJECT) .build(), PropertyDefinition.builder(BRANCH_NAME) .name("Optional name of SonarQube/SCM branch") diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java index b49944513c3..ef0ceb4a0db 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java @@ -22,7 +22,6 @@ package org.sonar.scanner.bootstrap; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.sonar.core.component.DefaultResourceTypes; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.core.sarif.SarifSerializerImpl; import org.sonar.scanner.cpd.JavaCpdBlockIndexerSensor; @@ -48,7 +47,6 @@ public class BatchComponents { public static Collection all() { List components = new ArrayList<>(); - components.add(DefaultResourceTypes.get()); components.addAll(CorePropertyDefinitions.all()); components.add(ZeroCoverageSensor.class); components.add(JavaCpdBlockIndexerSensor.class); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssuesImportSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssuesImportSensor.java index c5ea6d2d7a1..d1e03ecac01 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssuesImportSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/ExternalIssuesImportSensor.java @@ -33,7 +33,7 @@ import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.config.Configuration; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.api.scanner.ScannerSide; @ScannerSide @@ -54,7 +54,7 @@ public class ExternalIssuesImportSensor implements Sensor { .name("Issues report paths") .description("List of comma-separated paths (absolute or relative) containing report with issues created by external rule engines.") .category(CoreProperties.CATEGORY_EXTERNAL_ISSUES) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build()); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java index ce333db5216..3269cc3cd77 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java @@ -35,7 +35,7 @@ import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.config.Configuration; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.api.scanner.ScannerSide; import org.sonar.api.scanner.sensor.ProjectSensor; import org.sonar.api.utils.MessageException; @@ -66,7 +66,7 @@ public class SarifIssuesImportSensor implements ProjectSensor { .name("SARIF report paths") .description("List of comma-separated paths (absolute or relative) containing a SARIF report with issues created by external rule engines.") .category(CoreProperties.CATEGORY_EXTERNAL_ISSUES) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .build()); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java index 7106ecb1bd1..d09949b9be7 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java @@ -26,13 +26,13 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.api.scanner.sensor.ProjectSensor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.sonar.scanner.config.DefaultConfiguration; import static org.sonar.api.CoreProperties.CATEGORY_CODE_COVERAGE; @@ -54,7 +54,7 @@ public class GenericCoverageSensor implements ProjectSensor { .name("Coverage report paths") .description("List of comma-separated paths (absolute or relative) containing coverage report.") .category(CATEGORY_CODE_COVERAGE) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .multiValues(true) .build()); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java index a016927512c..6615372735b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java @@ -23,13 +23,13 @@ import java.io.File; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.resources.Qualifiers; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.sonar.api.config.PropertyDefinition.ConfigScope; import org.sonar.scanner.config.DefaultConfiguration; import org.sonar.scanner.deprecated.test.TestPlanBuilder; @@ -61,7 +61,7 @@ public class GenericTestExecutionSensor implements Sensor { .name("Unit tests results report paths") .description("List of comma-separated paths (absolute or relative) containing unit tests results report.") .category(CATEGORY_CODE_COVERAGE) - .onQualifiers(Qualifiers.PROJECT) + .onConfigScopes(ConfigScope.PROJECT) .multiValues(true) .deprecatedKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY) .build()); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java index 7f060c295fd..1c6fc7fb20e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java @@ -31,7 +31,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule; import org.sonar.api.batch.fs.internal.SensorStrategy; import org.sonar.api.measures.Metrics; import org.sonar.api.resources.Languages; -import org.sonar.api.resources.ResourceTypes; import org.sonar.core.config.ScannerProperties; import org.sonar.core.language.LanguagesProvider; import org.sonar.core.metric.ScannerMetrics; @@ -100,8 +99,6 @@ public class SpringProjectScanContainer extends SpringComponentContainer { ScanProperties.class, - ResourceTypes.class, - // lang LanguagesProvider.class, -- 2.39.5