aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-02 10:25:35 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-02 15:28:17 +0200
commit5725b5108f1c1a507e3134080fa6ba2a31ec069d (patch)
treee1c46ffe799f0ebda808f49b3181a488d8b77aad /sonar-core
parentdd9b60a85b5cb8e76ca29759fb93fc16219b4133 (diff)
downloadsonarqube-5725b5108f1c1a507e3134080fa6ba2a31ec069d.tar.gz
sonarqube-5725b5108f1c1a507e3134080fa6ba2a31ec069d.zip
SONAR-5663 Fix issue when updating provisioned project key
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java25
2 files changed, 16 insertions, 11 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java
index 7be4c1deed9..ee13722ce7c 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/AuthorizedComponentDto.java
@@ -26,7 +26,7 @@ import org.sonar.core.persistence.Dto;
* Used to check that a project exists. Can return provisionned projects and projects from analysis.
* The root project id is not available because no join on snapshot is done to retrieve it.
*
- * Warning, this component should not be retrieve from db using a join on snapshots, otherwise provisionned projects will not be returned anymore.
+ * Warning, this component should not be retrieve from db using a join on snapshots, otherwise provisioned projects will not be returned anymore.
*/
public class AuthorizedComponentDto extends Dto<String> {
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
index 41ae718bf99..c47cf8b997c 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
@@ -220,19 +220,24 @@ public class ResourceDao implements DaoComponent {
* The implementation should rather use a new column already containing the root project, see https://jira.codehaus.org/browse/SONAR-5188.
*/
@CheckForNull
+ public ResourceDto getRootProjectByComponentKey(DbSession session, String componentKey) {
+ ResourceDto component = getResource(ResourceQuery.create().setKey(componentKey), session);
+ if (component != null) {
+ Long rootId = component.getRootId();
+ if (rootId != null) {
+ return getParentModuleByComponentId(rootId, session);
+ } else {
+ return component;
+ }
+ }
+ return null;
+ }
+
+ @CheckForNull
public ResourceDto getRootProjectByComponentKey(String componentKey) {
DbSession session = mybatis.openSession(false);
try {
- ResourceDto component = getResource(ResourceQuery.create().setKey(componentKey), session);
- if (component != null) {
- Long rootId = component.getRootId();
- if (rootId != null) {
- return getParentModuleByComponentId(rootId, session);
- } else {
- return component;
- }
- }
- return null;
+ return getRootProjectByComponentKey(session, componentKey);
} finally {
MyBatis.closeQuietly(session);
}