diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-01-29 16:30:25 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-01-29 16:30:25 +0100 |
commit | 75fd4f9a5653b25188918b9c2d7f6cb77f9ab3bd (patch) | |
tree | f69caf99295f101bd428c25c509dca6d0322a865 /sonar-core/src | |
parent | d5236ae0363d97f3ef47712005dee74d6704d7a0 (diff) | |
download | sonarqube-75fd4f9a5653b25188918b9c2d7f6cb77f9ab3bd.tar.gz sonarqube-75fd4f9a5653b25188918b9c2d7f6cb77f9ab3bd.zip |
Display source code with CodeColorizers when no syntax highlighting data are available
Diffstat (limited to 'sonar-core/src')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java | 18 |
1 files changed, 17 insertions, 1 deletions
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 3f011e63148..5c1d75a8590 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 @@ -29,6 +29,7 @@ import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; import javax.annotation.Nullable; + import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -52,12 +53,27 @@ public class ResourceDao { } } + public List<ResourceDto> getResources(ResourceQuery query, SqlSession session) { + return session.getMapper(ResourceMapper.class).selectResources(query); + } + /** * Return a single result or null. If the request returns multiple rows, then * the first row is returned. */ + @CheckForNull public ResourceDto getResource(ResourceQuery query) { - List<ResourceDto> resources = getResources(query); + SqlSession session = mybatis.openSession(); + try { + return getResource(query, session); + } finally { + MyBatis.closeQuietly(session); + } + } + + @CheckForNull + public ResourceDto getResource(ResourceQuery query, SqlSession session) { + List<ResourceDto> resources = getResources(query, session); if (!resources.isEmpty()) { return resources.get(0); } |