From 404437827385fa720792e9661552b5be6a7e5567 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 5 Dec 2012 08:38:50 +0100 Subject: [PATCH] Fix quality flaws --- .../org/sonar/core/persistence/DryRunDatabaseFactory.java | 6 +++--- .../sonar/core/persistence/DryRunDatabaseFactoryTest.java | 2 +- .../src/main/java/org/sonar/server/ui/JRubyFacade.java | 4 ++-- .../WEB-INF/app/controllers/batch_bootstrap_controller.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java index 6530140510d..91ebe74f100 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java @@ -46,14 +46,14 @@ public class DryRunDatabaseFactory implements ServerComponent { this.serverFileSystem = serverFileSystem; } - public byte[] createDatabaseForDryRun(Integer resourceId) { + public byte[] createDatabaseForDryRun() { String name = serverFileSystem.getTempDir().getAbsolutePath() + "db-" + System.nanoTime(); try { DataSource source = database.getDataSource(); BasicDataSource destination = create(DIALECT, DRIVER, USER, PASSWORD, URL + name); - copy(source, destination, resourceId); + copy(source, destination); close(destination); return dbFileContent(name); @@ -62,7 +62,7 @@ public class DryRunDatabaseFactory implements ServerComponent { } } - private void copy(DataSource source, DataSource dest, Integer resourceId) { + private void copy(DataSource source, DataSource dest) { new DbTemplate() .copyTable(source, dest, "active_rules") .copyTable(source, dest, "active_rule_parameters") diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java index aa284c22e13..2832446ae53 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java @@ -63,7 +63,7 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase { when(serverFileSystem.getTempDir()).thenReturn(temporaryFolder.getRoot()); - byte[] database = localDatabaseFactory.createDatabaseForDryRun(1); + byte[] database = localDatabaseFactory.createDatabaseForDryRun(); dataSource = createDatabase(database); assertThat(rowCount("metrics")).isEqualTo(2); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index ab58927f5fe..681912fd13a 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -517,7 +517,7 @@ public final class JRubyFacade { } } - public byte[] createDatabaseForDryRun(int resourceId) { - return get(DryRunDatabaseFactory.class).createDatabaseForDryRun(resourceId); + public byte[] createDatabaseForDryRun() { + return get(DryRunDatabaseFactory.class).createDatabaseForDryRun(); } } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb index 592870aa354..45fd241e2f4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb @@ -25,7 +25,7 @@ class BatchBootstrapController < Api::ApiController def db require_parameters :project project = load_project() - db_content = java_facade.createDatabaseForDryRun(project ? project.id : nil) + db_content = java_facade.createDatabaseForDryRun() send_data String.from_java_bytes(db_content) end -- 2.39.5