diff options
author | Michal Duda <44705056+michal-duda-sonarsource@users.noreply.github.com> | 2019-06-27 13:57:22 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-06-28 08:45:58 +0200 |
commit | 97a815175c48fbd63bebb607ff4a4a6d12e5164c (patch) | |
tree | 831b8dc084aaaeefa216e0f81031b059ed70c239 /server/sonar-server | |
parent | 41775a1b983fff935264484bdef27e693f896ac1 (diff) | |
download | sonarqube-97a815175c48fbd63bebb607ff4a4a6d12e5164c.tar.gz sonarqube-97a815175c48fbd63bebb607ff4a4a6d12e5164c.zip |
Merge pull request #1789 from SonarSource/fix/md/SONAR-11845-project-import-should-handle-external-issues
SONAR-11845 project import should handle external issues
Diffstat (limited to 'server/sonar-server')
5 files changed, 10 insertions, 10 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index 60a149bb652..691fccc29e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -74,7 +74,7 @@ public class RuleCreator { String defaultOrganizationUuid = defaultOrganizationProvider.get().getUuid(); OrganizationDto defaultOrganization = dbClient.organizationDao().selectByUuid(dbSession, defaultOrganizationUuid) .orElseThrow(() -> new IllegalStateException(format("Could not find default organization for uuid '%s'", defaultOrganizationUuid))); - RuleDto templateRule = dbClient.ruleDao().selectByKey(dbSession, defaultOrganization, templateKey) + RuleDto templateRule = dbClient.ruleDao().selectByKey(dbSession, defaultOrganization.getUuid(), templateKey) .orElseThrow(() -> new IllegalArgumentException(format("The template key doesn't exist: %s", templateKey))); checkArgument(templateRule.isTemplate(), "This rule is not a template rule: %s", templateKey.toString()); checkArgument(templateRule.getStatus() != RuleStatus.REMOVED, "The template key doesn't exist: %s", templateKey.toString()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ShowAction.java index b3f87fc4914..d3ce556fba8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ShowAction.java @@ -104,7 +104,7 @@ public class ShowAction implements RulesWsAction { RuleKey key = RuleKey.parse(request.mandatoryParam(PARAM_KEY)); try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = ruleWsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION)); - RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization, key) + RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization.getUuid(), key) .orElseThrow(() -> new NotFoundException(String.format("Rule not found: %s", key))); List<RuleDefinitionDto> templateRules = ofNullable(rule.getTemplateId()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/UpdateAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/UpdateAction.java index 40278e60e52..39eb128af3c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/UpdateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/UpdateAction.java @@ -207,7 +207,7 @@ public class UpdateAction implements RulesWsAction { } private RuleUpdate createRuleUpdate(DbSession dbSession, RuleKey key, OrganizationDto organization) { - RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization, key) + RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization.getUuid(), key) .orElseThrow(() -> new NotFoundException(format("This rule does not exist: %s", key))); RuleUpdate ruleUpdate = ofNullable(rule.getTemplateId()) .map(x -> RuleUpdate.createForCustomRule(key)) @@ -252,7 +252,7 @@ public class UpdateAction implements RulesWsAction { } private UpdateResponse buildResponse(DbSession dbSession, RuleKey key, OrganizationDto organization) { - RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization, key) + RuleDto rule = dbClient.ruleDao().selectByKey(dbSession, organization.getUuid(), key) .orElseThrow(() -> new NotFoundException(format("Rule not found: %s", key))); List<RuleDefinitionDto> templateRules = new ArrayList<>(1); if (rule.getDefinition().isCustomRule()) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index 80a5084a761..a557963cee6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -664,7 +664,7 @@ public class RegisterRulesTest { repo.done(); }); - RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization, rule.getKey()).get(); + RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization.getUuid(), rule.getKey()).get(); assertThat(reloaded.isAdHoc()).isFalse(); } @@ -677,7 +677,7 @@ public class RegisterRulesTest { execute(); - RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization, rule.getKey()).get(); + RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization.getUuid(), rule.getKey()).get(); assertThat(reloaded.getStatus()).isEqualTo(REMOVED); } @@ -690,7 +690,7 @@ public class RegisterRulesTest { execute(); - RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization, rule.getKey()).get(); + RuleDto reloaded = dbClient.ruleDao().selectByKey(db.getSession(), defaultOrganization.getUuid(), rule.getKey()).get(); assertThat(reloaded.getStatus()).isEqualTo(READY); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java index a11505feed6..13bb50c00bc 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java @@ -197,7 +197,7 @@ public class UpdateActionTest { assertThat(updatedRule.getTags().getTagsList()).containsExactly("tag2", "tag3"); // check database - RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization) + RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization.getUuid()) .orElseThrow(() -> new IllegalStateException("Cannot load metadata")); assertThat(metadataOfSpecificOrg.getTags()).containsExactly("tag2", "tag3"); } @@ -238,7 +238,7 @@ public class UpdateActionTest { assertThat(updatedRule.getRemFnBaseEffort()).isEqualTo(newEffort); // check database - RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization) + RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization.getUuid()) .orElseThrow(() -> new IllegalStateException("Cannot load metadata")); assertThat(metadataOfSpecificOrg.getRemediationFunction()).isEqualTo(newOffset); assertThat(metadataOfSpecificOrg.getRemediationGapMultiplier()).isEqualTo(newMultiplier); @@ -267,7 +267,7 @@ public class UpdateActionTest { assertThat(updatedRule.getNoteLogin()).isEqualTo(userAuthenticated.getLogin()); // check database - RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization).get(); + RuleMetadataDto metadataOfSpecificOrg = db.getDbClient().ruleDao().selectMetadataByKey(db.getSession(), rule.getKey(), organization.getUuid()).get(); assertThat(metadataOfSpecificOrg.getNoteData()).isEqualTo("new data"); assertThat(metadataOfSpecificOrg.getNoteUserUuid()).isEqualTo(userAuthenticated.getUuid()); } |