aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-14 10:34:04 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-14 10:34:04 +0100
commit4f18ef7dbe845455598bba7217ad286bd2beec4e (patch)
treeabd96f7f9d4fdbd5e341bb1585fe7161405e2da4
parentb74eecaa0a60f30078f68f462226efe14eeb647a (diff)
downloadsonarqube-4f18ef7dbe845455598bba7217ad286bd2beec4e.tar.gz
sonarqube-4f18ef7dbe845455598bba7217ad286bd2beec4e.zip
Purge: add missing log and remove needs for cursors when disabling orphan resources
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java2
2 files changed, 8 insertions, 10 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
index a93661f87a0..d1669a4dbc2 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
@@ -22,8 +22,6 @@ package org.sonar.core.purge;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import org.apache.commons.lang.ArrayUtils;
-import org.apache.ibatis.session.ResultContext;
-import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,14 +110,12 @@ public class PurgeDao {
}
private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper) {
- session.select("org.sonar.core.purge.PurgeMapper.selectResourceIdsToDisable", project.getId(), new ResultHandler() {
- public void handleResult(ResultContext resultContext) {
- Long resourceId = (Long) resultContext.getResultObject();
- if (resourceId != null) {
- disableResource(resourceId, purgeMapper);
- }
- }
- });
+ LOG.info("-> Disable resources in " + project.getLongName() + " [id=" + project.getId() + "]");
+ List<Long> resourceIds = purgeMapper.selectResourceIdsToDisable(project.getId());
+ LOG.info("<- " + resourceIds.size() + " resources to disable");
+ for (Long resourceId : resourceIds) {
+ disableResource(resourceId, purgeMapper);
+ }
session.commit();
}
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
index 2deacdd4600..0ff068a5974 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
@@ -82,4 +82,6 @@ public interface PurgeMapper {
List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithoutEvents(long resourceId);
List<Long> selectResourceIdsByRootId(long rootProjectId);
+
+ List<Long> selectResourceIdsToDisable(long projectId);
}