diff options
author | David Gageot <david@gageot.net> | 2012-10-24 16:59:13 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-10-24 19:20:27 +0200 |
commit | 0ad53bdcfa20c61945713e78030920d5b2f1e491 (patch) | |
tree | f711d9fa0e0e7a34d8056f889a253bae9dee6ab4 /sonar-core | |
parent | cc8897d8d488954e532aa7a98198051f417d3ae2 (diff) | |
download | sonarqube-0ad53bdcfa20c61945713e78030920d5b2f1e491.tar.gz sonarqube-0ad53bdcfa20c61945713e78030920d5b2f1e491.zip |
SONAR-3895 User resource key and optional authent.
Diffstat (limited to 'sonar-core')
3 files changed, 12 insertions, 9 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/LocalDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/LocalDatabaseFactory.java index a2e265bd5cd..edebb896eef 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/LocalDatabaseFactory.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/LocalDatabaseFactory.java @@ -46,12 +46,12 @@ public class LocalDatabaseFactory implements ServerComponent { this.serverFileSystem = serverFileSystem; } - public byte[] createDatabaseForLocalMode() { + public byte[] createDatabaseForLocalMode(int resourceId) { String name = serverFileSystem.getTempDir().getAbsolutePath() + "db-" + System.nanoTime(); try { BasicDataSource destination = create(DIALECT, DRIVER, USER, PASSWORD, URL + name); - copy(database.getDataSource(), destination); + copy(database.getDataSource(), destination, resourceId); close(destination); return dbFileContent(name); @@ -60,8 +60,10 @@ public class LocalDatabaseFactory implements ServerComponent { } } - private void copy(DataSource source, DataSource dest) { - new DbTemplate().copyTable(source, dest, "PROPERTIES", "SELECT * FROM PROPERTIES WHERE (USER_ID IS NULL) AND (RESOURCE_ID IS NULL) AND NOT (PROP_KEY LIKE '%.secured')") + private void copy(DataSource source, DataSource dest, int resourceId) { + new DbTemplate() + .copyTable(source, dest, "PROPERTIES", + "SELECT * FROM PROPERTIES WHERE (((USER_ID IS NULL) AND (RESOURCE_ID IS NULL)) OR (RESOURCE_ID='" + resourceId + "')) AND NOT (PROP_KEY LIKE '%.secured')") .copyTable(source, dest, "RULES_PROFILES", "SELECT * FROM RULES_PROFILES") .copyTable(source, dest, "RULES", "SELECT * FROM RULES") .copyTable(source, dest, "RULES_PARAMETERS", "SELECT * FROM RULES_PARAMETERS") diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/LocalDatabaseFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/LocalDatabaseFactoryTest.java index 3486fb9638a..3eb0d75c300 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/LocalDatabaseFactoryTest.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/LocalDatabaseFactoryTest.java @@ -63,10 +63,10 @@ public class LocalDatabaseFactoryTest extends AbstractDaoTestCase { when(serverFileSystem.getTempDir()).thenReturn(temporaryFolder.getRoot()); - byte[] database = localDatabaseFactory.createDatabaseForLocalMode(); + byte[] database = localDatabaseFactory.createDatabaseForLocalMode(1); dataSource = createDatabase(database); - assertThat(rowCount("PROPERTIES")).isEqualTo(1); + assertThat(rowCount("PROPERTIES")).isEqualTo(2); assertThat(rowCount("PROJECTS")).isZero(); } diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/LocalDatabaseFactoryTest/should_create_database.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/LocalDatabaseFactoryTest/should_create_database.xml index 281958780db..30343973116 100644 --- a/sonar-core/src/test/resources/org/sonar/core/persistence/LocalDatabaseFactoryTest/should_create_database.xml +++ b/sonar-core/src/test/resources/org/sonar/core/persistence/LocalDatabaseFactoryTest/should_create_database.xml @@ -1,6 +1,7 @@ <dataset> <properties id="1" prop_key="resourceProperty" text_value="value1" resource_id="1" user_id="[null]"/> - <properties id="2" prop_key="globalProperty" text_value="value2" resource_id="[null]" user_id="[null]"/> - <properties id="3" prop_key="userProperty" text_value="value3" resource_id="[null]" user_id="1"/> - <properties id="4" prop_key="property.secured" text_value="value4" resource_id="[null]" user_id="[null]"/> + <properties id="2" prop_key="resourceProperty" text_value="value2" resource_id="2" user_id="[null]"/> + <properties id="3" prop_key="globalProperty" text_value="value3" resource_id="[null]" user_id="[null]"/> + <properties id="4" prop_key="userProperty" text_value="value4" resource_id="[null]" user_id="1"/> + <properties id="5" prop_key="property.secured" text_value="value5" resource_id="[null]" user_id="[null]"/> </dataset>
\ No newline at end of file |