import org.sonar.core.resource.ResourceDao;
import org.sonar.core.resource.ResourceDto;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
LOG.info("<- Delete aborted builds");
PurgeSnapshotQuery query = PurgeSnapshotQuery.create()
.setIslast(false)
- .setStatus(new String[]{"U"})
+ .setStatus(new String[] {"U"})
.setRootProjectId(project.getId());
commands.deleteSnapshots(query);
}
private boolean hasAbortedBuilds(Long projectId, PurgeCommands commands) {
PurgeSnapshotQuery query = PurgeSnapshotQuery.create()
.setIslast(false)
- .setStatus(new String[]{"U"})
+ .setStatus(new String[] {"U"})
.setResourceId(projectId);
return !commands.selectSnapshotIds(query).isEmpty();
}
.setResourceId(project.getId())
.setIslast(false)
.setNotPurged(true)
- );
+ );
for (final Long projectSnapshotId : projectSnapshotIds) {
LOG.info("<- Clean snapshot " + projectSnapshotId);
if (!ArrayUtils.isEmpty(scopesWithoutHistoricalData)) {
}
private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper) {
+ final List<Long> resourceIds = new ArrayList<Long>();
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);
+ resourceIds.add(resourceId);
}
}
});
+ for (Long resourceId : resourceIds) {
+ disableResource(resourceId, purgeMapper);
+ }
session.commit();
}