summaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-12-21 23:03:58 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-12-21 23:03:58 +0100
commit27ef81ee84252c85e3dd09d44d88fb441700182b (patch)
treede09fc298f72e31f7ac58adbd819cf3603e1272e /sonar-core/src
parentb87e9dae5c6f0a10f60340f69e78bfe4146e4ac5 (diff)
downloadsonarqube-27ef81ee84252c85e3dd09d44d88fb441700182b.tar.gz
sonarqube-27ef81ee84252c85e3dd09d44d88fb441700182b.zip
SONAR-983 i18n, better purge, fix NPE when deleted resource
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerDao.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerMapper.java2
-rw-r--r--sonar-core/src/main/resources/org/sonar/persistence/resource/ResourceIndexerMapper.xml7
-rw-r--r--sonar-core/src/test/java/org/sonar/persistence/resource/ResourceIndexerDaoTest.java9
-rw-r--r--sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes-result.xml8
-rw-r--r--sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes.xml31
6 files changed, 0 insertions, 75 deletions
diff --git a/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerDao.java b/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerDao.java
index 68561370ab7..99b9ebe845c 100644
--- a/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerDao.java
+++ b/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerDao.java
@@ -77,24 +77,6 @@ public class ResourceIndexerDao {
return this;
}
- public ResourceIndexerDao delete(List<Integer> resourceIds) {
- final SqlSession sqlSession = mybatis.openSession();
- try {
- ResourceIndexerMapper mapper = sqlSession.getMapper(ResourceIndexerMapper.class);
- List<List<Integer>> partitionsOfResourceIds = Lists.partition(resourceIds, DatabaseUtils.MAX_IN_ELEMENTS);
- for (List<Integer> partitionOfResourceIds : partitionsOfResourceIds) {
- if (!partitionOfResourceIds.isEmpty()) {
- mapper.deleteByResourceIds(partitionOfResourceIds);
- }
- }
- sqlSession.commit();
-
- } finally {
- sqlSession.close();
- }
- return this;
- }
-
void index(ResourceDto resource, SqlSession session, boolean correctProjectRootId) {
String name = resource.getName();
if (StringUtils.isBlank(name) || resource.getId() == null) {
diff --git a/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerMapper.java b/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerMapper.java
index beec37e4bfd..2fd1ad13fe5 100644
--- a/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerMapper.java
+++ b/sonar-core/src/main/java/org/sonar/persistence/resource/ResourceIndexerMapper.java
@@ -31,7 +31,5 @@ public interface ResourceIndexerMapper {
void deleteByResourceId(int resourceId);
- void deleteByResourceIds(@Param("resourceIds") List<Integer> resourceIds);
-
void insert(ResourceIndexDto dto);
}
diff --git a/sonar-core/src/main/resources/org/sonar/persistence/resource/ResourceIndexerMapper.xml b/sonar-core/src/main/resources/org/sonar/persistence/resource/ResourceIndexerMapper.xml
index bae19fea41a..62e58dfcd51 100644
--- a/sonar-core/src/main/resources/org/sonar/persistence/resource/ResourceIndexerMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/persistence/resource/ResourceIndexerMapper.xml
@@ -35,13 +35,6 @@
where resource_id=#{id}
</delete>
- <delete id="deleteByResourceIds" parameterType="map">
- delete from resource_index
- where resource_id in
- <foreach item="i" index="index" collection="resourceIds" open="(" separator="," close=")">#{i}</foreach>
- </delete>
-
-
<insert id="insert" parameterType="ResourceIndex" useGeneratedKeys="false">
insert into resource_index (kee, position, name_size, resource_id, root_project_id, qualifier)
values (#{key}, #{position}, #{nameSize}, #{resourceId}, #{rootProjectId}, #{qualifier})
diff --git a/sonar-core/src/test/java/org/sonar/persistence/resource/ResourceIndexerDaoTest.java b/sonar-core/src/test/java/org/sonar/persistence/resource/ResourceIndexerDaoTest.java
index 7312b15b088..c23b4dd554c 100644
--- a/sonar-core/src/test/java/org/sonar/persistence/resource/ResourceIndexerDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/persistence/resource/ResourceIndexerDaoTest.java
@@ -69,13 +69,4 @@ public class ResourceIndexerDaoTest extends DaoTestCase {
checkTables("shouldReindexProjectAfterRenaming", "resource_index");
}
-
- @Test
- public void shouldDeleteIndexes() {
- setupData("shouldDeleteIndexes");
-
- dao.delete(Arrays.asList(3, 4, 5, 6));
-
- checkTables("shouldDeleteIndexes", "resource_index");
- }
}
diff --git a/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes-result.xml b/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes-result.xml
deleted file mode 100644
index 1eb9d339ae9..00000000000
--- a/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes-result.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<dataset>
-
- <resource_index kee="struts" position="0" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
-
-</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes.xml b/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes.xml
deleted file mode 100644
index 535c13fb251..00000000000
--- a/sonar-core/src/test/resources/org/sonar/persistence/resource/ResourceIndexerDaoTest/shouldDeleteIndexes.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<dataset>
-
- <!-- Struts -->
- <resource_index kee="struts" position="0" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="truts" position="1" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="ruts" position="2" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
- <resource_index kee="uts" position="3" name_size="6" resource_id="1" root_project_id="1" qualifier="TRK"/>
-
- <!-- RequestContext -->
- <resource_index kee="requestcontext" position="0" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="equestcontext" position="1" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="questcontext" position="2" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="uestcontext" position="3" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="estcontext" position="4" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="stcontext" position="5" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="tcontext" position="6" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="context" position="7" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="ontext" position="8" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="ntext" position="9" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="text" position="10" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="ext" position="11" name_size="14" resource_id="3" root_project_id="1" qualifier="FIL"/>
-
- <!-- ZipUtils -->
- <resource_index kee="ziputils" position="0" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="iputils" position="1" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="putils" position="2" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="utils" position="3" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="tils" position="4" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
- <resource_index kee="ils" position="5" name_size="8" resource_id="6" root_project_id="1" qualifier="FIL"/>
-
-</dataset>