diff options
77 files changed, 632 insertions, 652 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index bafe68fcfaa..267ccceeffe 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -75,6 +75,7 @@ min=Min minor=Minor more_actions=More actions name=Name +name_too_long_x=Name is too long (maximum is {0} characters) none=None off=Off on=On @@ -94,6 +95,7 @@ plugin=Plugin project=Project projects=Projects raw=Raw +remove=Remove rename=Rename reset_verb=Reset result=Result @@ -132,6 +134,7 @@ unselect_all=Unselect all unselect_verb=Unselect updated=Updated update_verb=Update +updating=Updating user=User value=Value variation=Variation @@ -141,6 +144,7 @@ views=Views violations=Violations + #------------------------------------------------------------------------------ # # GENERIC EXPRESSIONS, sorted alphabetically @@ -1094,10 +1098,7 @@ update_key.no_key_to_update=No key contains the string to replace ("{0}"). # PROJECT QUALITY PROFILE PAGE # #------------------------------------------------------------------------------ -project_quality_profile.select_profile_for_x=Select the quality profile to be used when analyzing the "{0}" project: -project_quality_profile.project_cannot_be_update_with_profile_x=The current project can not be updated with the following profile: "{0}". -project_quality_profile.profile_successfully_updated=Quality profile successfully updated. -project_quality_profile.default_profile=default +project_quality_profile.default_profile=Default #------------------------------------------------------------------------------ @@ -1153,7 +1154,6 @@ quality_profiles.are_you_sure_want_x_profile_as_default=Are you sure that you wa quality_profiles.profile_x_created=Profile "{0}" created. Set it as default or link it to a project to use it for next measures. quality_profiles.already_exists=This profile already exists. quality_profiles.please_type_profile_name=Please type a profile name. -quality_profiles.delete_confirm_title=Delete Profile quality_profiles.profile_x_deleted=Profile "{0}" is deleted. quality_profiles.default_profile_is_x=Default profile is "{0}". quality_profiles.profile_x_not_activated=Profile "{0}" is created but not activated. @@ -1193,7 +1193,9 @@ quality_profiles.with_same_configuration=With same configuration quality_profiles.x_rules_only_in={0} rules only in quality_profiles.x_rules_have_different_configuration={0} rules have a different configuration quality_profiles.export_all_rules=All rules - +quality_profiles.remove_projects_action=Remove All +quality_profiles.copy_x_title=Copy Profile {0} +quality_profiles.copy_new_name=New Name #------------------------------------------------------------------------------ # diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ReferenceAnalysisTest/shared.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ReferenceAnalysisTest/shared.xml index dd96aeecbf1..cca1757cb78 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ReferenceAnalysisTest/shared.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ReferenceAnalysisTest/shared.xml @@ -2,7 +2,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]" scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml index 47dd47e31a2..53b31f29464 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml @@ -10,7 +10,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml index b5ce1f7afc7..76d13a53489 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml @@ -10,7 +10,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml index 5bd323e8866..485a01a5977 100644 --- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml +++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml @@ -9,7 +9,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultProfileLoader.java index 35a10a679f7..cdc5876300c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultProfileLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultProfileLoader.java @@ -19,6 +19,8 @@ */ package org.sonar.batch; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.rules.ActiveRule; @@ -26,27 +28,26 @@ import org.sonar.api.utils.SonarException; import org.sonar.jpa.dao.ProfilesDao; public class DefaultProfileLoader implements ProfileLoader { - static final String PARAM_PROFILE = "sonar.profile"; - private ProfilesDao dao; + private Settings settings; - public DefaultProfileLoader(ProfilesDao dao) { + public DefaultProfileLoader(ProfilesDao dao, Settings settings) { this.dao = dao; + this.settings = settings; } public RulesProfile load(Project project) { - String profileName = (String) project.getProperty(PARAM_PROFILE); + String profileName = StringUtils.defaultIfBlank(settings.getString("sonar.profile." + project.getLanguageKey()), settings.getString("sonar.profile")); RulesProfile profile; - if (profileName == null) { - Project root = project.getRoot(); - profile = dao.getActiveProfile(root.getLanguageKey(), root.getKey()); + + // temporary + if (StringUtils.isBlank(profileName)) { + profile = dao.getDefaultProfile(project.getLanguageKey()); if (profile == null) { // This means that the current language is not supported by any installed plugin, otherwise at least a // "Default <Language Name>" profile would have been created by ActivateDefaultProfiles class. - throw new SonarException("You must intall a Sonar plugin that supports language '" + root.getLanguageKey() - + "' in order to analyse the following project: " + root.getKey()); + throw new SonarException("You must install a plugin that supports the language '" + project.getLanguageKey() + "'"); } - } else { profile = dao.getProfile(project.getLanguageKey(), profileName); if (profile == null) { @@ -56,6 +57,7 @@ public class DefaultProfileLoader implements ProfileLoader { // hack to lazy initialize the profile collections profile.getActiveRules().size(); + for (ActiveRule activeRule : profile.getActiveRules()) { activeRule.getActiveRuleParams().size(); activeRule.getRule().getParams().size(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProfileProvider.java b/sonar-batch/src/main/java/org/sonar/batch/ProfileProvider.java index a274827ee36..22a8c030108 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProfileProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProfileProvider.java @@ -34,7 +34,7 @@ public class ProfileProvider extends ProviderAdapter { public RulesProfile provide(Project project, ProfileLoader profileLoader) { if (profile == null) { profile = profileLoader.load(project); - LOG.info("Selected quality profile : {}", profile); + LOG.info("Quality profile : {}", profile); } return profile; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java index 139c296fad7..1ea83f62df9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java @@ -73,8 +73,7 @@ public class ProjectConfigurator implements BatchComponent { .setAnalysisDate(analysisDate) .setLatestAnalysis(isLatestAnalysis(project.getKey(), analysisDate)) .setAnalysisVersion(loadAnalysisVersion()) - .setAnalysisType(loadAnalysisType()) - .setLanguageKey(loadLanguageKey()); + .setAnalysisType(loadAnalysisType()); return this; } @@ -88,7 +87,7 @@ public class ProjectConfigurator implements BatchComponent { } Date loadAnalysisDate() { - Date date = null; + Date date; try { // sonar.projectDate may have been specified as a time date = settings.getDateTime(CoreProperties.PROJECT_DATE_PROPERTY); @@ -119,8 +118,4 @@ public class ProjectConfigurator implements BatchComponent { String loadAnalysisVersion() { return settings.getString(CoreProperties.PROJECT_VERSION_PROPERTY); } - - String loadLanguageKey() { - return StringUtils.defaultIfBlank(settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY), Java.KEY); - } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java index d470a9cdb02..aca22d363f4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java @@ -26,6 +26,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.Settings; +import org.sonar.api.resources.Java; import org.sonar.api.resources.Project; import org.sonar.core.config.ConfigurationUtils; import org.sonar.core.properties.PropertiesDao; @@ -48,6 +49,13 @@ public class ProjectSettings extends Settings { this.projectDefinition = projectDefinition; this.propertiesDao = propertiesDao; load(); + updateProject(project); + } + + private void updateProject(Project project) { + // The class org.sonar.api.batch.Project should be deeply refactored and should load language from settings. + // Meanwhile the language must be updated : + project.setLanguageKey(StringUtils.defaultIfBlank(getString("sonar.language"), Java.KEY)); } public ProjectSettings load() { diff --git a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java index 735c21c7130..9d50aadfb9b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java @@ -19,104 +19,75 @@ */ package org.sonar.batch; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.HashMap; - -import org.apache.commons.configuration.MapConfiguration; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.profiles.Alert; +import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Java; import org.sonar.api.resources.Project; -import org.sonar.api.rules.ActiveRule; import org.sonar.api.utils.SonarException; import org.sonar.jpa.dao.ProfilesDao; +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class DefaultProfileLoaderTest { @Rule public ExpectedException thrown = ExpectedException.none(); private ProfilesDao dao; - private ProfileLoader loader; + private Project javaProject = new Project("project").setLanguageKey(Java.KEY); @Before public void setUp() { dao = mock(ProfilesDao.class); - loader = new DefaultProfileLoader(dao); } @Test - public void shouldGetProjectProfile() { - Project project = new Project("project").setLanguageKey(Java.KEY); - Project module = new Project("module").setParent(project).setLanguageKey(Java.KEY); + public void should_get_configured_profile() { + Settings settings = new Settings(); + settings.setProperty("sonar.profile.java", "legacy profile"); + when(dao.getProfile(Java.KEY, "legacy profile")).thenReturn(RulesProfile.create("legacy profile", "java")); - when(dao.getActiveProfile(Java.KEY, "project")).thenReturn(newProfile()); + RulesProfile profile = new DefaultProfileLoader(dao, settings).load(javaProject); - assertNotNull(loader.load(module)); - - verify(dao, never()).getActiveProfile(Java.KEY, "module"); - verify(dao).getActiveProfile(Java.KEY, "project"); - } - - private RulesProfile newProfile() { - RulesProfile profile = new RulesProfile(); - profile.setAlerts(Collections.<Alert> emptyList()); - profile.setActiveRules(Collections.<ActiveRule> emptyList()); - return profile; + assertThat(profile.getName()).isEqualTo("legacy profile"); } @Test - public void mavenPropertyShouldOverrideProfile() { - Project project = new Project("project").setLanguageKey(Java.KEY); - - MapConfiguration conf = new MapConfiguration(new HashMap()); - conf.addProperty(DefaultProfileLoader.PARAM_PROFILE, "profile1"); - project.setConfiguration(conf); + public void should_get_default_profile() { + Settings settings = new Settings(); + when(dao.getDefaultProfile(Java.KEY)).thenReturn(RulesProfile.create("default profile", "java")); - when(dao.getProfile(Java.KEY, "profile1")).thenReturn(newProfile()); + RulesProfile profile = new DefaultProfileLoader(dao, settings).load(javaProject); - loader.load(project); - - verify(dao).getProfile(Java.KEY, "profile1"); - verify(dao, never()).getActiveProfile(Java.KEY, "project"); + assertThat(profile.getName()).isEqualTo("default profile"); } @Test - public void shouldFailIfProfileIsNotFound() { - Project project = new Project("project").setLanguageKey(Java.KEY); - - MapConfiguration conf = new MapConfiguration(new HashMap()); - conf.addProperty(DefaultProfileLoader.PARAM_PROFILE, "unknown"); - project.setConfiguration(conf); - - when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null); + public void should_fail_if_not_found() { + Settings settings = new Settings(); + settings.setProperty("sonar.profile.java", "unknown"); thrown.expect(SonarException.class); thrown.expectMessage("Quality profile not found : unknown, language java"); - loader.load(project); + new DefaultProfileLoader(dao, settings).load(javaProject); } /** * SONAR-3125 */ @Test - public void shouldGiveExplicitMessageIfNoProfileFound() { - Project project = new Project("foo:project").setLanguageKey("unknown-language"); - when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null); + public void should_give_explicit_message_if_default_profile_not_found() { + Project cobolProject = new Project("cobol-javaProject").setLanguageKey("cobol"); thrown.expect(SonarException.class); - thrown.expectMessage("You must intall a Sonar plugin that supports language 'unknown-language' in order to analyse the following project: foo:project"); - loader.load(project); + thrown.expectMessage("You must install a plugin that supports the language 'cobol'"); + new DefaultProfileLoader(dao, new Settings()).load(cobolProject); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java index 1d60f84f59b..4db0e9f4c5a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java @@ -37,25 +37,6 @@ import static org.junit.Assert.assertTrue; public class ProjectConfiguratorTest extends AbstractDbUnitTestCase { @Test - public void getLanguageFromConfiguration() { - Settings configuration = new Settings(); - configuration.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "foo"); - - Project project = new Project("key"); - new ProjectConfigurator(getSession(), configuration).configure(project); - - assertThat(project.getLanguageKey(), is("foo")); - } - - @Test - public void defaultLanguageIsJava() { - Project project = new Project("key"); - new ProjectConfigurator(getSession(), new Settings()).configure(project); - - assertThat(project.getLanguageKey(), is(Java.KEY)); - } - - @Test public void analysisIsTodayByDefault() { Project project = new Project("key"); new ProjectConfigurator(getSession(), new Settings()).configure(project); diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultTimeMachineTest/loadMeasuresFromDate.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultTimeMachineTest/loadMeasuresFromDate.xml index 3a6d76cabaf..fef06b0f60d 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultTimeMachineTest/loadMeasuresFromDate.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/DefaultTimeMachineTest/loadMeasuresFromDate.xml @@ -6,10 +6,10 @@ <projects long_name="[null]" id="1" scope="PRJ" kee="group:artifact" qualifier="TRK" name="my project" root_id="[null]" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="[null]" id="2" scope="DIR" kee="group:artifact:org.sonar" qualifier="PAC" name="org.sonar" root_id="2" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <!-- Project : 3 snapshots --> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml index 65c8a495038..c8796e2bb80 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml @@ -1,12 +1,12 @@ <dataset> <projects long_name="[null]" id="1" scope="PRJ" kee="my:project" qualifier="LIB" name="my project as lib" - root_id="[null]" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + root_id="[null]" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="[null]" id="2" scope="PRJ" kee="my:project" qualifier="TRK" name="my project" - root_id="[null]" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + root_id="[null]" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="[null]" id="3" scope="DIR" kee="my:project:path/to/dir" qualifier="TRK" name="my dir" - root_id="2" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + root_id="2" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> </dataset> diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml index cff08ac82fe..4eaddace0e1 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml index 475dc3fe89b..bc7fc1c6f0a 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml @@ -2,7 +2,7 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- old snapshot --> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml index a8e44dd6f86..8b4092b1e96 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml @@ -3,7 +3,7 @@ <!-- This project has a root_id which should be set to NULL (SONAR-1700) --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="12345" name="name" long_name="long name" description="description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml index b78bd590b18..bfa0198e5b9 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,11 +13,11 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001" name="org.foo" long_name="org.foo" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml index bfc203efeea..7c4ab1f4008 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,11 +13,11 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <projects id="1002" scope="PRJ" qualifier="LIB" kee="junit:junit" root_id="[null]" name="junit:junit" long_name="junit:junit" description="[null]" - enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml index 5e9999e6488..a36b177dafb 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,19 +13,19 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="root" root_id="[null]" name="Root" long_name="Root" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <projects id="1002" scope="PRJ" qualifier="BRC" kee="a" root_id="1001" name="A" long_name="A" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <projects id="1003" scope="PRJ" qualifier="BRC" kee="b" root_id="1001" name="B" long_name="B" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <projects id="1004" scope="PRJ" qualifier="BRC" kee="b1" root_id="1001" name="B1" long_name="B1" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" root_project_id="1001" parent_snapshot_id="[null]" root_snapshot_id="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml index e78b1d11356..9f7c802b57e 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml @@ -3,7 +3,7 @@ <!-- other project --> <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]" name="Other project" long_name="Other" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" @@ -13,7 +13,7 @@ <!-- new project --> <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="Foo" long_name="Foo" description="some description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml index 4114dac7b8e..4fe4bcf5894 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml @@ -2,7 +2,7 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="new name" long_name="new name" description="new description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- old snapshot --> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml index 95efadf881b..23570debd77 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml @@ -2,7 +2,7 @@ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" name="old name" long_name="old name" description="old description" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]" scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml index 9bfe3ded05d..f20f89769d8 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml @@ -2,7 +2,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]" scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shouldSaveSource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shouldSaveSource-result.xml index 8bc81a76ad2..d1e1a8dc456 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shouldSaveSource-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shouldSaveSource-result.xml @@ -2,7 +2,7 @@ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]" name="Bar" long_name="org.foo.Bar" description="[null]" - enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]" scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path="" diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 8aa94e8d2a5..754d5e973b6 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -35,7 +35,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 330; + public static final int LAST_VERSION = 331; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java index 73ee680a5d4..a9edcb4ed19 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java @@ -35,7 +35,6 @@ public final class ResourceDto { private String language; private Long copyResourceId; private Long personId; - private Long profileId; private Date createdAt; public Long getId() { @@ -146,15 +145,6 @@ public final class ResourceDto { return this; } - public Long getProfileId() { - return profileId; - } - - public ResourceDto setProfileId(Long profileId) { - this.profileId = profileId; - return this; - } - public Date getCreatedAt() { return createdAt;// NOSONAR May expose internal representation by returning reference to mutable object } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java index 3721c2560dc..40ab93b9cbe 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java @@ -20,7 +20,6 @@ package org.sonar.jpa.dao; import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; public class ProfilesDao extends BaseDao { @@ -29,16 +28,12 @@ public class ProfilesDao extends BaseDao { super(session); } - public RulesProfile getActiveProfile(String languageKey, String projectResourceKey) { - ResourceModel projectResource = getSession().getSingleResult(ResourceModel.class, "key", projectResourceKey, "scope", ResourceModel.SCOPE_PROJECT); - if (projectResource != null && projectResource.getRulesProfile() != null && projectResource.getRulesProfile().isEnabled()) { - return projectResource.getRulesProfile(); - } - return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey, "enabled", true); + public RulesProfile getDefaultProfile(String languageKey) { + return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey); } public RulesProfile getProfile(String languageKey, String profileName) { - return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName, "enabled", true); + return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName); } } diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 9b7211d2862..05b077452b2 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -172,6 +172,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('306'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('320'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('321'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('330'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('331'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index a66ee4b5f0f..53e322fc449 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -293,7 +293,6 @@ CREATE TABLE "PROJECTS" ( "QUALIFIER" VARCHAR(10), "KEE" VARCHAR(400), "ROOT_ID" INTEGER, - "PROFILE_ID" INTEGER, "LANGUAGE" VARCHAR(5), "COPY_RESOURCE_ID" INTEGER, "LONG_NAME" VARCHAR(256), diff --git a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml index 1d51aff6cc6..e35451c4f6e 100644 --- a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml @@ -34,7 +34,6 @@ <result property="language" column="language"/> <result property="copyResourceId" column="copy_resource_id"/> <result property="personId" column="person_id"/> - <result property="profileId" column="profile_id"/> <result property="createdAt" column="created_at"/> </resultMap> @@ -86,11 +85,11 @@ <insert id="insert" parameterType="Resource" useGeneratedKeys="true" keyProperty="id"> insert into projects - (name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, profile_id, enabled, created_at) + (name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at) values ( #{name}, #{longName}, #{description}, #{scope}, #{qualifier}, #{key}, #{language}, #{rootId}, #{copyResourceId}, - #{personId}, #{profileId}, #{enabled}, #{createdAt} + #{personId}, #{enabled}, #{createdAt} ) </insert> @@ -100,11 +99,11 @@ select projects_seq.NEXTVAL from DUAL </selectKey> insert into projects - (id, name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, profile_id, enabled, created_at) + (id, name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at) values ( #{id}, #{name}, #{longName}, #{description}, #{scope}, #{qualifier}, #{key}, #{language}, #{rootId}, #{copyResourceId}, - #{personId}, #{profileId}, #{enabled}, #{createdAt} + #{personId}, #{enabled}, #{createdAt} ) </insert> @@ -112,7 +111,7 @@ update projects set name=#{name}, long_name=#{longName}, description=#{description}, scope=#{scope}, qualifier=#{qualifier}, kee=#{key}, language=#{language}, root_id=#{rootId}, copy_resource_id=#{copyResourceId}, - person_id=#{personId}, profile_id=#{profileId}, enabled=#{enabled} where id=#{id} + person_id=#{personId}, enabled=#{enabled} where id=#{id} </update> </mapper> diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java index 0ab2cf17506..01f7310fca0 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java @@ -21,12 +21,10 @@ package org.sonar.jpa.dao; import org.junit.Before; import org.junit.Test; -import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.fest.assertions.Assertions.assertThat; public class ProfilesDaoTest extends AbstractDbUnitTestCase { @@ -37,22 +35,24 @@ public class ProfilesDaoTest extends AbstractDbUnitTestCase { profilesDao = new ProfilesDao(getSession()); } + @Test + public void should_get_profile_by_name() { + RulesProfile profile = RulesProfile.create("my profile", "java"); + getSession().save(profile); + + assertThat(profilesDao.getProfile("unknown language", "my profile")).isNull(); + assertThat(profilesDao.getProfile("java", "my profile").getName()).isEqualTo("my profile"); + } @Test - public void testGetActiveProfile() { - RulesProfile testDefaultProfile = new RulesProfile("default", "java", true, true); - RulesProfile testProfile = new RulesProfile("not default", "java", false, false); - getSession().save(testDefaultProfile, testProfile); - - ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test"); - testResourceWithProfile.setRulesProfile(testProfile); - ResourceModel testResourceWithNoProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withoutProfile", "TRK", null, "test"); - getSession().save(testResourceWithProfile, testResourceWithNoProfile); - - assertNull(profilesDao.getActiveProfile("wrongLanguage", "withoutProfile")); - assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "wrongKey").getId()); - assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "withoutProfile").getId()); - assertEquals(testProfile.getId(), profilesDao.getActiveProfile("java", "withProfile").getId()); + public void should_get_default_profile() { + RulesProfile defaultProfile = RulesProfile.create("default profile", "java"); + defaultProfile.setDefaultProfile(true); + RulesProfile otherProfile = RulesProfile.create("other profile", "java"); + otherProfile.setDefaultProfile(false); + getSession().save(defaultProfile, otherProfile); + + assertThat(profilesDao.getDefaultProfile("java").getName()).isEqualTo("default profile"); } } diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml index d9fe0172ed6..ff3b37a56ea 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml @@ -2,7 +2,7 @@ <projects id="1" enabled="[true]" root_id="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="[false]" purge_status="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml index 7f21ab01f6e..4e982e4dc12 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml @@ -8,7 +8,7 @@ Snapshot 2 has been deleted <!-- the project --> <projects id="1" enabled="[true]" root_id="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- past snapshot with status "processed" and already purged --> <snapshots id="1" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml index da6f52837c7..34716adee47 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml @@ -3,7 +3,7 @@ <!-- the project --> <projects id="1" enabled="[true]" root_id="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- past snapshot with status "processed" and already purged --> <snapshots id="1" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml index 5a659ed2b14..83f1ff3676e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml @@ -9,17 +9,17 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 <!-- the project --> <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the directory --> <projects id="2" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the file --> <projects id="3" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- do not purge last snapshots --> <snapshots id="1" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml index 49f63da1e7f..a3445a40a64 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml @@ -3,17 +3,17 @@ <!-- the project --> <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the directory --> <projects id="2" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the file --> <projects id="3" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- do not purge last snapshots --> <snapshots id="1" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml index 66d6efd5e73..8888c64bb0f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -3,7 +3,7 @@ <!-- root --> <projects id="1" enabled="[true]" root_id="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="[false]" purge_status="[null]" @@ -34,7 +34,7 @@ <!-- modules --> <projects id="2" enabled="[true]" root_id="1" long_name="[null]" scope="PRJ" qualifier="BRC" kee="module1" name="module1" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" status="P" islast="[false]" purge_status="[null]" @@ -50,7 +50,7 @@ <projects id="3" enabled="[false]" root_id="1" long_name="[null]" scope="PRJ" qualifier="BRC" kee="module2" name="module2" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="3" project_id="3" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" status="P" islast="[true]" purge_status="[null]" @@ -66,7 +66,7 @@ <!-- file of module 2--> <projects id="4" enabled="[false]" root_id="3" long_name="[null]" scope="FIL" qualifier="FIL" kee="module2:File.java" name="File" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="4" project_id="4" parent_snapshot_id="3" root_project_id="1" root_snapshot_id="1" status="P" islast="[true]" purge_status="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot-result.xml index b14e00595da..96c616fb46f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot-result.xml @@ -10,17 +10,17 @@ What has been changed : <!-- the project --> <projects id="1" enabled="[false]" root_id="[null]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the directory --> <projects id="2" enabled="[false]" root_id="1" created_at="[null]" long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the file --> <projects id="3" enabled="[false]" root_id="1" created_at="[null]" long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot.xml index 05bb41f18f6..b943a8f0ea6 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot.xml @@ -3,17 +3,17 @@ <!-- the project --> <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the directory --> <projects id="2" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- the file --> <projects id="3" enabled="[true]" root_id="1" created_at="[null]" long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java" - description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject-result.xml index 0adc84368f7..d80268aff4e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject-result.xml @@ -3,7 +3,7 @@ <!-- the project --> <projects id="1" enabled="[true]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- snapshot already purged --> diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject.xml index a38c88faa59..23490655cbe 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject.xml @@ -3,7 +3,7 @@ <!-- the project --> <projects id="1" enabled="[true]" created_at="[null]" long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project" - root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/> + root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" /> <!-- snapshot already purged --> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml index 0b7b9325056..27016ad3471 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml @@ -2,10 +2,10 @@ <projects id="1" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action" description="[null]" long_name="org.struts.Action" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> <projects id="2" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter" description="[null]" long_name="org.struts.Filter" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml index 05ef16cbee5..4a59dd793f1 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml @@ -2,6 +2,6 @@ <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" description="MVC Framework" long_name="Apache Struts" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/> + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml index 74ff92ef743..dcd5ae6480b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml @@ -2,6 +2,6 @@ <projects id="1" root_id="200" scope="PRJ" qualifier="TRK" kee="old key" name="old name" description="old name" long_name="old long name" - enabled="[false]" language="old" copy_resource_id="2" person_id="3" profile_id="4" created_at="[null]"/> + enabled="[false]" language="old" copy_resource_id="2" person_id="3" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shared.xml index dff49673540..4613c167d31 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shared.xml @@ -2,49 +2,49 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" + description="[null]" long_name="Apache Struts" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** First sub project **************** --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" + scope="PRJ" qualifier="BRC" long_name="Struts Core" description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project **************** --> <projects id="5" root_id="1" kee="org.struts:struts-ui" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" + scope="PRJ" qualifier="BRC" long_name="Struts UI" description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-ui:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-ui:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Another independent project **************** --> <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core" - scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1" + scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml index a4b3fdd195e..b9fc934e546 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml @@ -2,49 +2,49 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.apache.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" long_name="Apache Struts" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** First sub project **************** --> <projects id="2" root_id="1" kee="org.apache.struts:struts-core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project **************** --> <projects id="5" root_id="1" kee="org.apache.struts:struts-ui" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts UI" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-ui:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-ui:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Another independent project **************** --> <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core" - scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml index 40bb3ed144d..71ed68a61ae 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml @@ -2,49 +2,49 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" long_name="Apache Struts" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** First sub project **************** --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project **************** --> <projects id="5" root_id="1" kee="org.struts:struts-web" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts UI" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-web:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-web:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Another independent project **************** --> <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core" - scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml index 6ebe224cfaf..54bf43d5802 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml @@ -2,43 +2,43 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.apache.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" long_name="Apache Struts" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** First sub project **************** --> <projects id="2" root_id="1" kee="org.apache.struts:struts-core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** --> <projects id="5" root_id="1" kee="foo:struts-ui" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + scope="PRJ" qualifier="BRC" long_name="Struts UI" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="foo:struts-ui:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="foo:struts-ui:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" /> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml index 1b33265baeb..93f747e9d72 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml @@ -2,43 +2,43 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" long_name="Apache Struts" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** First sub project **************** --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + scope="PRJ" qualifier="BRC" long_name="Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** --> <projects id="5" root_id="1" kee="foo:struts-ui" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + scope="PRJ" qualifier="BRC" long_name="Struts UI" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="foo:struts-ui:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="foo:struts-ui:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" - enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" + enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml index 5680e1d1814..178b172ddd0 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml @@ -2,7 +2,7 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - description="[null]" long_name="Apache Struts" profile_id="1" + description="[null]" long_name="Apache Struts" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> @@ -10,43 +10,43 @@ <!-- ONLY THIS PROJECT MUST HAVE BEEN UPDATED --> <!-- --> <projects id="2" root_id="1" kee="struts:core" name="Struts Core" - scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1" - description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> + scope="PRJ" qualifier="BRC" long_name="Struts Core" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> <!-- directory --> <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="struts:core:org.struts" name="org.struts" root_id="2" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="struts:core:org.struts.RequestContext" name="RequestContext" root_id="2" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Second sub project **************** --> <projects id="5" root_id="1" kee="org.struts:struts-ui" name="Struts UI" - scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1" + scope="PRJ" qualifier="BRC" long_name="Struts UI" description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- directory --> <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-ui:org.struts" name="org.struts" root_id="5" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-ui:org.struts.RequestContext" name="RequestContext" root_id="5" - description="[null]" profile_id="1" + description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> <!-- **************** Another independent project **************** --> <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core" - scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1" + scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/> </dataset> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java index 35a6e481340..59b735a0138 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java @@ -25,7 +25,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.hibernate.annotations.BatchSize; import org.sonar.api.database.BaseIdentifiable; -import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.ProjectLink; import org.sonar.api.resources.Resource; @@ -99,10 +98,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable { @BatchSize(size = 8) private List<ProjectLink> projectLinks = new ArrayList<ProjectLink>(); - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "profile_id", updatable = true, nullable = true) - private RulesProfile rulesProfile; - /** * Default constructor */ @@ -264,14 +259,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable { this.rootId = rootId; } - public RulesProfile getRulesProfile() { - return rulesProfile; - } - - public void setRulesProfile(RulesProfile rulesProfile) { - this.rulesProfile = rulesProfile; - } - public String getQualifier() { return qualifier; } @@ -337,7 +324,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable { clone.setDescription(getDescription()); clone.setEnabled(getEnabled()); clone.setProjectLinks(getProjectLinks()); - clone.setRulesProfile(getRulesProfile()); clone.setLanguageKey(getLanguageKey()); clone.setCopyResourceId(getCopyResourceId()); clone.setLongName(getLongName()); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java index a06e887c02d..171f2e92219 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java @@ -91,9 +91,6 @@ public class RulesProfile implements Cloneable { @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE}) private List<Alert> alerts = Lists.newArrayList(); - @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY) - private List<ResourceModel> projects = Lists.newArrayList(); - /** * @deprecated use the factory method create() */ @@ -110,7 +107,6 @@ public class RulesProfile implements Cloneable { this.language = language; this.activeRules = Lists.newArrayList(); this.alerts = Lists.newArrayList(); - this.projects = Lists.newArrayList(); } /** @@ -291,20 +287,6 @@ public class RulesProfile implements Cloneable { } /** - * @return the list of projects attached to the profile - */ - public List<ResourceModel> getProjects() { - return projects; - } - - /** - * Sets the list of projects attached to the profile - */ - public void setProjects(List<ResourceModel> projects) { - this.projects = projects; - } - - /** * Note: disabled rules are excluded. * * @return the list of active rules for a given severity @@ -424,13 +406,6 @@ public class RulesProfile implements Cloneable { } }))); } - if (CollectionUtils.isNotEmpty(getProjects())) { - clone.setProjects(new ArrayList<ResourceModel>(CollectionUtils.collect(getProjects(), new Transformer() { - public Object transform(Object input) { - return ((ResourceModel) input).clone(); - } - }))); - } return clone; } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java index bd7b1921eb0..54fbae8b538 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java @@ -22,7 +22,6 @@ package org.sonar.server.configuration; import org.apache.commons.lang.ObjectUtils; import org.codehaus.plexus.util.StringUtils; import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rules.*; import org.sonar.api.utils.ValidationMessages; @@ -40,20 +39,6 @@ public class ProfilesManager extends BaseDao { this.rulesDao = rulesDao; } - public void renameProfile(int profileId, String newProfileName) { - RulesProfile profile = getSession().getSingleResult(RulesProfile.class, "id", profileId); - if (profile != null && !profile.getProvided()) { - String hql = "UPDATE " + RulesProfile.class.getSimpleName() + " o SET o.parentName=:newName WHERE o.parentName=:oldName"; - getSession().getEntityManager().createQuery(hql) - .setParameter("oldName", profile.getName()) - .setParameter("newName", newProfileName) - .executeUpdate(); - profile.setName(newProfileName); - getSession().save(profile); - getSession().commit(); - } - } - public void copyProfile(int profileId, String newProfileName) { RulesProfile profile = getSession().getSingleResult(RulesProfile.class, "id", profileId); RulesProfile toImport = (RulesProfile) profile.clone(); @@ -65,27 +50,12 @@ public class ProfilesManager extends BaseDao { getSession().commit(); } - public void deleteProfile(int profileId) { - RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId); - if (profile != null && !profile.getProvided() && getChildren(profile).isEmpty()) { - // Remove history of rule changes - String hqlDeleteRc = "DELETE " + ActiveRuleChange.class.getSimpleName() + " rc WHERE rc.rulesProfile=:rulesProfile"; - getSession().createQuery(hqlDeleteRc).setParameter("rulesProfile", profile).executeUpdate(); - - String hql = "UPDATE " + ResourceModel.class.getSimpleName() + " o SET o.rulesProfile=null WHERE o.rulesProfile=:rulesProfile"; - getSession().createQuery(hql).setParameter("rulesProfile", profile).executeUpdate(); - getSession().remove(profile); - getSession().commit(); - } - } public void deleteAllProfiles() { // Remove history of rule changes String hqlDeleteRc = "DELETE " + ActiveRuleChange.class.getSimpleName() + " rc"; getSession().createQuery(hqlDeleteRc).executeUpdate(); - String hql = "UPDATE " + ResourceModel.class.getSimpleName() + " o SET o.rulesProfile = null WHERE o.rulesProfile IS NOT NULL"; - getSession().createQuery(hql).executeUpdate(); List profiles = getSession().createQuery("FROM " + RulesProfile.class.getSimpleName()).getResultList(); for (Object profile : profiles) { getSession().removeWithoutFlush(profile); 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 85f177aaec9..3738332bdcc 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 @@ -280,18 +280,10 @@ public final class JRubyFacade { return get(ProfilesConsole.class).getProfileExporter(exporterKey).getMimeType(); } - public void renameProfile(int profileId, String newProfileName) { - getProfilesManager().renameProfile(profileId, newProfileName); - } - public void copyProfile(long profileId, String newProfileName) { getProfilesManager().copyProfile((int) profileId, newProfileName); } - public void deleteProfile(long profileId) { - getProfilesManager().deleteProfile((int) profileId); - } - public ValidationMessages changeParentProfile(int profileId, String parentName, String userName) { return getProfilesManager().changeParentProfile(profileId, parentName, userName); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index 8636de40e54..e125aaefe2d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -125,6 +125,23 @@ class ApplicationController < ActionController::Base raise Errors::AccessDenied end + # since 3.3 + def require_parameters(*keys) + keys.each do |key| + bad_request("Missing parameter: #{key}") if params[key].blank? + end + end + + # since 3.3 + def verify_post_request + bad_request('Not a POST request') unless request.post? + end + + # since 3.3 + def verify_ajax_request + bad_request('Not an AJAX request') unless request.xhr? + end + def render_not_found(error) render :file => "#{Rails.public_path}/404.html", :status => 404 end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index d380dbff837..50fbf55c26f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -20,38 +20,37 @@ class ProfilesController < ApplicationController SECTION=Navigation::SECTION_CONFIGURATION - # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) - verify :method => :post, :only => ['create', 'delete', 'copy', 'set_as_default', 'restore', 'set_projects', 'rename', 'change_parent'], :redirect_to => {:action => 'index'} - # the backup action is allow to non-admin users : see http://jira.codehaus.org/browse/SONAR-2039 before_filter :admin_required, :only => ['create', 'delete', 'set_as_default', 'copy', 'restore', 'change_parent', 'set_projects', 'rename_form', 'rename'] # GET /profiles/index def index - @profiles = Profile.find(:all, :conditions => ['enabled=?', true], :order => 'name') + @profiles = Profile.find(:all, :order => 'name') end # GET /profiles/show/<id> def show + require_parameters 'id' @profile = Profile.find(params[:id]) end # GET /profiles/create_form?language=<language> def create_form - language = params[:language] - bad_request 'Missing parameter: language' if language.blank? - profile = Profile.new(:language => language) - render :partial => 'profiles/create_form', :locals => {:language_key => language} + require_parameters 'language' + render :partial => 'profiles/create_form', :locals => {:language_key => params[:language]} end # POST /profiles/create?name=<profile name>&language=<language>&[backup=<file>] def create + verify_post_request + require_parameters 'language' + profile_name=params[:name] language=params[:language] - profile = Profile.create(:name => profile_name, :language => language, :default_profile => false, :enabled => true) + profile = Profile.create(:name => profile_name, :language => language, :default_profile => false) ok = profile.errors.empty? if ok && params[:backup] params[:backup].each_pair do |importer_key, file| @@ -75,9 +74,12 @@ class ProfilesController < ApplicationController # POST /profiles/delete/<id> def delete + verify_post_request + require_parameters 'id' + @profile = Profile.find(params[:id]) if @profile && @profile.deletable? - java_facade.deleteProfile(@profile.id) + @profile.destroy end redirect_to(:controller => 'profiles', :action => 'index') end @@ -85,40 +87,50 @@ class ProfilesController < ApplicationController # POST /profiles/set_as_default/<id> def set_as_default + verify_post_request + require_parameters 'id' + profile = Profile.find(params[:id]) profile.set_as_default - flash[:notice]=message('quality_profiles.default_profile_is_x', :params => profile.name) + #TODO remove l10n key: flash[:notice]=message('quality_profiles.default_profile_is_x', :params => profile.name) redirect_to :action => 'index' end # GET /profiles/copy_form/<profile id> def copy_form + require_parameters 'id' @profile = Profile.find(params[:id]) render :partial => 'profiles/copy_form' end # POST /profiles/copy/<id>?name=<name of new profile> def copy - render :text => 'Not an ajax request', :status => '400' unless request.xhr? + verify_post_request + verify_ajax_request + require_parameters 'id' @profile = Profile.find(params[:id]) name = params['name'] - validation_errors = @profile.validate_copy(name) - if validation_errors.empty? + target_profile=Profile.new(:name => name, :language => @profile.language, :provided => false, :default_profile => false) + if target_profile.valid? java_facade.copyProfile(@profile.id, name) flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => name) render :text => 'ok', :status => 200 else - @error = validation_errors.full_messages.first + @errors = [] + target_profile.errors.each{|attr,msg| @errors<<msg} render :partial => 'profiles/copy_form', :status => 400 end end - # POST /profiles/backup/<id> + # POST /profiles/backup?id=<profile id> def backup + verify_post_request + require_parameters 'id' + profile = Profile.find(params[:id]) xml = java_facade.backupProfile(profile.id) filename=profile.name.gsub(' ', '_') @@ -129,11 +141,13 @@ class ProfilesController < ApplicationController # Modal window to restore profile backup # GET /profiles/restore_form/<profile id> def restore_form + verify_ajax_request render :partial => 'profiles/restore_form' end # POST /profiles/restore?backup=<file> def restore + verify_post_request if params[:backup].blank? flash[:warning]=message('quality_profiles.please_upload_backup_file') else @@ -148,7 +162,7 @@ class ProfilesController < ApplicationController def export language = params[:language] if (params[:name].blank?) - profile = Profile.find_active_profile_by_language(language) + profile = Profile.by_default(language) else profile = Profile.find_by_name_and_language(CGI::unescape(params[:name]), language) end @@ -165,24 +179,18 @@ class ProfilesController < ApplicationController end end - # - # # GET /profiles/inheritance?id=<profile id> - # - # def inheritance + require_parameters 'id' @profile = Profile.find(params[:id]) - profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?) and enabled=?', @profile.language, @profile.id, @profile.name, true], :order => 'name') + profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?)', @profile.language, @profile.id, @profile.name], :order => 'name') @select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name, profile.name] } end - # - # # GET /profiles/changelog?id=<profile id> - # - # def changelog + require_parameters 'id' @profile = Profile.find(params[:id]) versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version') @@ -210,12 +218,11 @@ class ProfilesController < ApplicationController end - # - # # POST /profiles/change_parent?id=<profile id>&parent_name=<parent profile name> - # - # def change_parent + verify_post_request + require_parameters 'id' + id = params[:id].to_i parent_name = params[:parent_name] if parent_name.blank? @@ -234,6 +241,7 @@ class ProfilesController < ApplicationController # # def permalinks + require_parameters 'id' @profile = Profile.find(params[:id]) end @@ -244,62 +252,68 @@ class ProfilesController < ApplicationController # # def projects + require_parameters 'id' @profile = Profile.find(params[:id]) - @available_projects=Project.find(:all, - :include => ['profile', 'snapshots'], - :conditions => ['projects.qualifier=? AND projects.scope=? AND snapshots.islast=?', Project::QUALIFIER_PROJECT, Project::SCOPE_SET, true], - :order => 'projects.name asc') - @available_projects-=@profile.projects end - # - # - # POST /profiles/set_projects/<id>?projects=<project ids> - # - # - def set_projects - @profile = Profile.find(params[:id]) - @profile.projects.clear + # POST /profiles/add_project?id=<profile id>&project_id=<project id> + def add_project + verify_post_request + require_parameters 'id', 'project_id' + admin_required + + profile=Profile.find(params[:id]) + bad_request('Unknown profile') unless profile + project=Project.find(params[:project_id]) + bad_request('Unknown project') unless project - projects=Project.find(params[:projects] || []) - @profile.projects=projects - flash[:notice]=message('quality_profiles.profile_x_associated_to_x_projects', :params => [@profile.name, projects.size]) - redirect_to :action => 'projects', :id => @profile.id + profile.add_project_id(project.id) + redirect_to :action => 'projects', :id => profile.id end + # POST /profiles/remove_project?id=<profile id>&project_id=<project id> + def remove_project + verify_post_request + require_parameters 'id', 'project_id' + admin_required + + profile=Profile.find(params[:id]) + bad_request('Unknown profile') unless profile + + Profile.reset_default_profile_for_project_id(profile.language, params[:project_id]) + redirect_to :action => 'projects', :id => profile.id + end + + # POST /profiles/remove_projects?id=<profile id> + def remove_projects + verify_post_request + require_parameters 'id' + admin_required + + profile=Profile.find(params[:id]) + bad_request('Unknown profile') unless profile + + profile.remove_projects + redirect_to :action => 'projects', :id => profile.id + end # GET /profiles/rename_form?id=<id> def rename_form + require_parameters 'id' @profile = Profile.find(params[:id]) render :partial => 'profiles/rename_form' end - # - # # POST /profiles/rename?id=<id>&name=<new name> - # - # def rename - render :text => 'Not an ajax request', :status => '400' unless request.xhr? + verify_post_request + verify_ajax_request + require_parameters 'id' @profile = Profile.find(params[:id]) - name = params[:name] - success=false - if name.blank? - @error=message('quality_profiles.profile_name_cant_be_blank') - else - existing=Profile.find(:first, :conditions => {:name => name, :language => @profile.language, :enabled => true}) - if existing - @error=message('quality_profiles.already_exists') - elsif !@profile.provided? - java_facade.renameProfile(@profile.id, name) - success=true - end - end - - if success + if @profile.rename(params[:name]).errors.empty? render :text => 'ok', :status => 200 else render :partial => 'profiles/rename_form', :status => 400 @@ -307,13 +321,9 @@ class ProfilesController < ApplicationController end - # - # # GET /profiles/compare?id1=<profile1 id>&id2=<profile2 id> - # - # def compare - @profiles = Profile.find(:all, :conditions => ['enabled=?', true], :order => 'language asc, name') + @profiles = Profile.find(:all, :order => 'language asc, name') if params[:id1].present? && params[:id2].present? @profile1 = Profile.find(params[:id1]) @profile2 = Profile.find(params[:id2]) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index a993d5331ec..5e59296c6e3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # class ProjectController < ApplicationController - verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update, :update_quality_profile], + verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update], :redirect_to => {:action => :index} verify :method => :delete, :only => [:delete], :redirect_to => {:action => :index} @@ -75,25 +75,29 @@ class ProjectController < ApplicationController redirect_to :action => 'deletion', :id => params[:id] end - def quality_profile + # GET /project/profile?id=<project id> + def profile + require_parameters :id @project = get_current_project(params[:id]) - @profiles = Profile.find(:all, :conditions => {:language => @project.language, :enabled => true}) end - def update_quality_profile + #Â POST /project/set_profile?id=<project id>&language=<language>[&profile_id=<profile id>] + def set_profile + require_parameters :id, :language + verify_post_request + + language=params[:language] project = get_current_project(params[:id]) - selected_profile = Profile.find(:first, :conditions => {:id => params[:quality_profile].to_i}) - if selected_profile && selected_profile.language == project.language - project.profile = selected_profile - project.save! - flash[:notice] = message('project_quality_profile.profile_successfully_updated') + if params[:profile_id].blank? + Profile.reset_default_profile_for_project_id(language, project.id) else - selected_profile_name = selected_profile ? selected_profile.name + "(" + selected_profile.language + ")" : "Unknown profile" - flash[:error] = message('project_quality_profile.project_cannot_be_update_with_profile_x', :params => selected_profile_name) + profile = Profile.find(params[:profile_id]) + bad_request('Bad language') if profile.language!=language + profile.add_project_id(project.id) end - redirect_to :action => 'quality_profile', :id => project.id + redirect_to :action => 'profile', :id => project.id end def key diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 39b9ac0f3ab..8720d718e20 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -721,7 +721,7 @@ module ApplicationHelper end # - # Creates a button linked to a POST action. A confirmation popup is opened when user clicks on the button. + # Creates a link linked to a POST action. A confirmation popup is opened when user clicks on the button. # ==== Options # * <tt>:id</tt> - HTML ID of the button # * <tt>:class</tt> - Additional CSS class, generally 'red-button' for deletions @@ -731,7 +731,7 @@ module ApplicationHelper # * <tt>:message_params</tt> - # * <tt>:width</tt> - width in pixels # - def button_to_action(label, post_url, options={}) + def link_to_action(label, post_url, options={}) clazz = options[:class] id = "id='#{options[:id]}'" if options[:id] title_key = options[:title_key] @@ -750,6 +750,6 @@ module ApplicationHelper url += "&bk=#{button_key}" end - "<a href='#{url}' modal-width='#{width}' class='open-modal button #{clazz}' #{id}>#{h label}</a>" + "<a href='#{url}' modal-width='#{width}' class='open-modal #{clazz}' #{id}>#{h label}</a>" end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb index ddf214b88e2..81e74632ca9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb @@ -169,4 +169,8 @@ class Api::Utils def self.java_facade Java::OrgSonarServerUi::JRubyFacade.getInstance() end + + def self.languages + java_facade.getLanguages() + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index 079645ff6c6..a9bb3d3a20e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -22,13 +22,21 @@ class Profile < ActiveRecord::Base has_many :alerts, :dependent => :delete_all has_many :active_rules, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :dependent => :destroy, :include => ['rule'] - has_many :projects, :order => 'name asc' - has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', - :include => ['active_rule_parameters', 'active_rule_note'] + has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :include => ['active_rule_parameters', 'active_rule_note'] + has_many :projects, :class_name => 'Project', :finder_sql => %q( + select prj.* from projects prj, properties prop where prj.id=prop.resource_id and prop.resource_id is not null and prop.prop_key='sonar.profile.#{language}' and prop.text_value='#{name}' + ) + has_many :changes, :class_name => 'ActiveRuleChange', :dependent => :destroy + has_many :children, :class_name => 'Profile', :finder_sql => %q( + select c.* from rules_profiles c where c.parent_name='#{name}' and c.language='#{language}' + ) validates_uniqueness_of :name, :scope => :language, :case_sensitive => false, :message => Api::Utils.message('quality_profiles.already_exists') validates_presence_of :name, :message => Api::Utils.message('quality_profiles.please_type_profile_name') + MAX_NAME_LENGTH = 100 + validates_length_of :name, :maximum => MAX_NAME_LENGTH, :message => Api::Utils.message('name_too_long_x', :params => [MAX_NAME_LENGTH]) + # The warnings that are set on this record, equivalent to normal ActiveRecord errors but does not prevent # the record from saving. def warnings @@ -36,7 +44,7 @@ class Profile < ActiveRecord::Base end def warnings? - not warnings.empty? + !warnings.empty? end def notices @@ -59,34 +67,16 @@ class Profile < ActiveRecord::Base provided end - def validate_copy(name) - new_rule_profile = Profile.new(:name => name, :provided => false, :default_profile => false, :language => language) - new_rule_profile.valid? - new_rule_profile.errors - end - - def self.find_by_name_and_language(name, language) - Profile.find(:first, :conditions => {:name => name, :language => language, :enabled => true}) - end - - def self.find_active_profile_by_language(language) - Profile.find(:first, :conditions => {:default_profile => true, :language => language, :enabled => true}) - end - - def self.default_profile - Profile.find(:first, :conditions => {:default_profile => true, :enabled => true}) - end - def set_as_default - default_profile=nil - Profile.find(:all, :conditions => {:language => language, :enabled => true}).each do |profile| - if profile.id==id - profile.default_profile=true - default_profile=profile - else - profile.default_profile=false + Profile.transaction do + Profile.find(:all, :conditions => {:language => language}).each do |profile| + if profile.id==id + profile.default_profile=true + else + profile.default_profile=false + end + profile.save end - profile.save end self end @@ -97,7 +87,7 @@ class Profile < ActiveRecord::Base def self.options_for_select array=[] - Profile.find(:all, :conditions => {:enabled => true}, :order => 'name').each do |profile| + Profile.find(:all, :order => 'name').each do |profile| label = profile.name label = label + ' (active)' if profile.default_profile? array<<[label, profile.id] @@ -123,9 +113,9 @@ class Profile < ActiveRecord::Base def count_overriding_rules @count_overriding_rules||= - begin - active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES']) - end + begin + active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES']) + end end def inherited? @@ -134,13 +124,13 @@ class Profile < ActiveRecord::Base def parent @parent||= - begin - if parent_name.present? - Profile.find(:first, :conditions => ['language=? and name=? and enabled=?', language, parent_name, true]) - else - nil - end + begin + if parent_name.present? + Profile.find(:first, :conditions => ['language=? and name=?', language, parent_name]) + else + nil end + end end def count_active_rules @@ -149,21 +139,14 @@ class Profile < ActiveRecord::Base def ancestors @ancestors ||= - begin - array=[] - if parent - array<<parent - array.concat(parent.ancestors) - end - array - end - end - - def children - @children ||= - begin - Profile.find(:all, :conditions => ['language=? and parent_name=? and enabled=?', language, name, true], :order => 'name') + begin + array=[] + if parent + array<<parent + array.concat(parent.ancestors) end + array + end end def import_configuration(importer_key, file) @@ -178,4 +161,60 @@ class Profile < ActiveRecord::Base notices.add_to_base msg end end + + def before_destroy + Property.clear_for_resources("sonar.profile.#{language}", name) + #TODO clear global property sonar.profile.#{language} with value #{name} + end + + def rename(new_name) + old_name=self.name + Profile.transaction do + children_to_be_renamed=children() + self.name=new_name + if save + children_to_be_renamed.each do |child| + child.parent_name=new_name + child.save + end + Property.update_all("text_value='#{new_name}'", ['prop_key=? and text_value=?', "sonar.profile.#{language}", old_name]) + end + end + self + end + + def add_project_id(project_id) + Property.set("sonar.profile.#{language}", name, project_id) + end + + def remove_projects + Property.clear_for_resources("sonar.profile.#{language}", name) + end + + def self.reset_default_profile_for_project_id(lang, project_id) + Property.clear("sonar.profile.#{lang}", project_id) + end + + def self.by_project_id(language, project_id, returns_default_if_nil=false) + profile_name=Property.value("sonar.profile.#{language}", project_id) + profile = (profile_name.present? ? Profile.find_by_name_and_language(profile_name, language) : nil) + + if !profile && returns_default_if_nil + profile = by_default(language) + end + profile + end + + def self.by_default(language) + Profile.find(:first, :conditions => {:default_profile => true, :language => language}) + end + + # Results are NOT sorted + def self.all_by_language(language) + Profile.find(:all, :conditions => {:language => language}) + end + + def self.find_by_name_and_language(name, language) + Profile.find(:first, :conditions => {:name => name, :language => language}) + end end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index 07e3a251282..4acf953c17c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -25,7 +25,6 @@ class Project < ActiveRecord::Base has_many :processed_snapshots, :class_name => 'Snapshot', :conditions => "status='#{Snapshot::STATUS_PROCESSED}' AND qualifier<>'LIB'", :order => 'created_at asc' has_many :events, :foreign_key => 'resource_id', :order => 'event_date DESC' has_many :project_links, :dependent => :delete_all, :order => 'link_type' - belongs_to :profile, :class_name => 'Profile', :foreign_key => 'profile_id' has_many :user_roles, :foreign_key => 'resource_id' has_many :group_roles, :foreign_key => 'resource_id' has_many :manual_measures, :foreign_key => 'resource_id' @@ -182,6 +181,10 @@ class Project < ActiveRecord::Base last_snapshot ? last_snapshot.path_name : nil end + def profile(lang, returns_default_if_nil=false) + Profile.by_project_id(lang, id, returns_default_if_nil) + end + private def create_chart_measures(results, date_column_name, value_column_name) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb index 976fdf7480a..6371b51242d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb @@ -21,9 +21,11 @@ class Property < ActiveRecord::Base validates_presence_of :prop_key named_scope :with_key, lambda { |value| {:conditions => {:prop_key, value}} } + named_scope :with_value, lambda { |value| {:conditions => {:text_value, value}} } named_scope :with_resource, lambda { |value| {:conditions => {:resource_id => value}} } named_scope :with_user, lambda { |value| {:conditions => {:user_id => value}} } - named_scope :on_resource, :conditions => ['resource_id is not ?', nil] + named_scope :with_resources, :conditions => 'resource_id is not null' + named_scope :with_users, :conditions => 'user_id is not null' def key prop_key @@ -47,6 +49,18 @@ class Property < ActiveRecord::Base end end + def self.clear_for_resources(key, value=nil) + scope=Property.with_resources().with_key(key) + if value + scope.with_value(value) + end + scope.delete_all + end + + def self.clear_for_users(key) + Property.with_users().with_key(key).delete_all + end + def self.by_key(key, resource_id=nil, user_id=nil) all(key, resource_id, user_id).first end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 9788893ab96..96d831919b5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -89,8 +89,8 @@ <% if has_role?(:admin, @project) %> <li class="h2"><%= message('sidebar.project_settings') -%></li> <% if (@project.project?) %> - <li class="<%= 'selected' if request.request_uri.include?('/project/quality_profile') -%>"> - <a href="<%= ApplicationController.root_context -%>/project/quality_profile/<%= @project.id -%>"><%= message('project_quality_profile.page') -%></a></li> + <li class="<%= 'selected' if request.request_uri.include?('/project/profile') -%>"> + <a href="<%= ApplicationController.root_context -%>/project/profile/<%= @project.id -%>"><%= message('project_quality_profile.page') -%></a></li> <% end %> <li class="<%= 'selected' if request.request_uri.include?('/manual_measures') -%>"> <a href="<%= ApplicationController.root_context -%>/manual_measures/index/<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb index bff1d8c7bfc..535ea549a10 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb @@ -2,14 +2,18 @@ <input type="hidden" name="id" value="<%= @profile.id -%>"/> <fieldset> <div class="form-head"> - <h2>Copy Profile: <%= h @profile.name -%></h2> + <h2> <%= message('quality_profiles.copy_x_title', :params => [h @profile.name]) -%></h2> </div> <div class="form-body"> - <% if @error %> - <p class="error"><%= h @error -%></p> - <% end %> + <% if @errors + @errors.each do |error| + %> + <p class="error"><%= h error -%></p> + <% end + end + %> <div class="form-field"> - <label for="name">New name <em>*</em></label> + <label for="name"><%= message 'quality_profiles.copy_new_name' -%> <em>*</em></label> <input id="copy-name" name="name" type="text" size="50" maxlength="100"/> </div> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb index 4da833e138d..b7c11aa4ac7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb @@ -3,12 +3,12 @@ <fieldset> <div class="form-head"> - <h2>Rename Profile: <%= h @profile.name -%></h2> + <h2>Rename Profile: <%= h @profile.name_was -%></h2> </div> <div class="form-body"> - <% if @error %> - <p class="error"><%= h @error -%></p> + <% @profile.errors.each do |attr, msg| %> + <p class="error"><%= h msg -%></p> <% end %> <div class="form-field"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index 201a7718682..50efc517ad0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -49,7 +49,7 @@ </td> <td align="right"> - <span id="activated_rules_<%= u profile.key -%>"><%= profile.count_active_rules -%></span> + <span id="activated_rules_<%= u profile.key -%>"><%= profile.active_rules.count -%></span> </td> <td align="right"><span id="alerts_<%= u profile.key -%>"><%= profile.alerts.size -%></span></td> @@ -62,8 +62,9 @@ <td align="right"> <% if !profile.default_profile? && administrator? %> - <%= button_to_action message('set_as_default'), "profiles/set_as_default?id=#{profile.id}", + <%= link_to_action message('set_as_default'), "profiles/set_as_default?id=#{profile.id}", :id => "activate_#{profile.key.parameterize}", + :class => 'button', :title_key => 'set_as_default', :message_key => 'quality_profiles.are_you_sure_want_x_profile_as_default', :message_params => [profile.name] -%> @@ -96,8 +97,8 @@ <td> <% if profile.deletable? %> - <%= button_to_action message('delete'), "profiles/delete/#{profile.id}", - :class => 'red-button', + <%= link_to_action message('delete'), "profiles/delete/#{profile.id}", + :class => 'button red-button', :id => "delete_#{profile.key.parameterize}", :button_key => 'delete', :title_key => 'quality_profiles.delete_confirm_title', diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb index 8a155a8adbd..df77976eb84 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb @@ -1,54 +1,79 @@ -<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1> -<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Projects'} %> +<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> + / <%= h @profile.name %></h1> +<%= render :partial => 'profiles/tabs', :locals => {:selected_tab => 'Projects'} %> <div class="tabs-panel"> -<% if is_admin? %> -<form action="<%= url_for :action => 'set_projects' -%>" method="post" id="select_projects_form"> - <input type="hidden" name="id" value="<%= @profile.id -%>"/> -<table> - <tr> - <td style="padding: 5px 0" valign="top"> - <h3><%= message('quality_profiles.available_projects') -%></h3> - <select name="from" id="from" size="10" style="max-width:380px;margin-top: 5px" multiple="multiple"> - <% @available_projects.each do |project| %> - <option value="<%= project.id -%>"><%= project.name %><%= " (#{project.profile.name})" if project.profile %></option> + <% if is_admin? %> + <form method="POST" action="<%= ApplicationController.root_context -%>/profiles/add_project" id="add_project_form"> + <input type="hidden" name="id" value="<%= @profile.id -%>"/> + + Add project: <%= resource_select_tag 'project_id', { + :qualifiers => ['TRK'], + :width => '400px', + :html_id => "select-project", + } -%> + <script>$j('#select-project').on("change", function (e) { + $j(this).select2("disable"); + $j('#add_project_form').submit(); + })</script> + </form> + + <% unless @profile.projects.empty? %> + <table class="data"> + <thead> + <tr> + <th></th> + <th></th> + </tr> + </thead> + <tbody> + <% @profile.projects.each do |project| %> + <tr class="<%= cycle('even', 'odd') -%>"> + <td class="thin"> + <%= link_to_action message('remove'), + "#{ApplicationController.root_context}/profiles/remove_project?id=#{@profile.id}&project_id=#{project.id}", + :class => 'link-action', + :id => "link-remove-#{project.key.parameterize}" -%> + </td> + <td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td> + </tr> <% end %> - </select> - </td> - <td align="center" style="padding: 0 10px;"> - <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;"><%= message('select_verb').downcase -%> »</button><br/> - <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;"><%= message('select_all').downcase -%> »</button><br/><br/> - <button id="select_left" onclick="SelectBox.move('to', 'from');return false;">« <%= message('unselect_verb').downcase -%></button><br/> - <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;">« <%= message('unselect_all').downcase -%></button> - </td> - <td class="box" style="padding: 5px 10px;" valign="top"> - <h3><%= message('quality_profiles.associated_projects') -%></h3> - <select name="projects[]" id="to" size="10" multiple="multiple" style="min-width: 300px;margin: 5px 0;"> - <%= options_from_collection_for_select(@profile.projects, "id", "name") %> - </select><br/> - <div style="padding:5px 0"> - <input type="submit" id="save" value="<%= message('save') -%>" onclick="SelectBox.select_all('to');submit();"/> - </div> - </td> -</tr> -</table> -</form> -<script> -SelectBox.init('from'); -SelectBox.init('to'); -</script> + </tbody> + <tfoot> + <tr> + <td colspan="2"> + <%= link_to_action message('quality_profiles.remove_projects_action'), + "#{ApplicationController.root_context}/profiles/remove_projects?id=#{@profile.id}", + :class => 'link-action', + :id => "link-remove-projects" -%> + </td> + </tr> + </tfoot> + </table> -<% else %> - <% if @profile.projects.empty? %> - <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p> + <% end %> <% else %> - <p><%= message('quality_profiles.projects_warning') -%></p> - <ol> - <% @profile.projects.each do |project| %> - <li><%= project.name %></li> + + <% if @profile.projects.empty? %> + <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p> + <% else %> + <p><%= message('quality_profiles.projects_warning') -%></p> + + <table class="data"> + <thead> + <tr> + <th></th> + </tr> + </thead> + <tbody> + <% @profile.projects.each do |project| %> + <tr class="<%= cycle('even', 'odd') -%>"> + <td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td> + </tr> + <% end %> + </tbody> + </table> <% end %> - </ol> <% end %> -<% end %> </div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb new file mode 100644 index 00000000000..a52e06af2ec --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb @@ -0,0 +1,40 @@ +<h1 class="marginbottom10"><%= message('project_quality_profile.page') -%></h1> + +<table class="data"> + <thead> + <tr> + <th><%= message 'language' -%></th> + <th>Quality Profile</th> + </tr> + </thead> + <tbody> + <% + Api::Utils.languages.sort_by { |l| l.getKey() }.each do |language| + selected_profile=@project.profile(language.getKey(), false) + %> + <tr class="<%= cycle 'even', 'odd' -%>"> + <td class="thin"><%= h language.getName() -%></td> + <td> + <form id="form-<%= language.getKey().parameterize -%>" method="POST" action="<%= ApplicationController.root_context -%>/project/set_profile"> + <input type="hidden" name="id" value="<%= @project.id -%>"/> + <input type="hidden" name="language" value="<%= language.getKey() -%>"/> + + <select id="select-profiles-<%= language.getKey().parameterize -%>" name="profile_id"> + <option value="" <%= "selected='selected'" unless selected_profile -%>><%= message 'project_quality_profile.default_profile' -%></option> + <optgroup> + <% + profiles = Api::Utils.insensitive_sort(Profile.all_by_language(language.getKey())) { |profile| profile.name } + profiles.each do |profile| + %> + <option value="<%= profile.id -%>" <%= "selected='selected'" if selected_profile && selected_profile.id==profile.id -%>><%= h profile.name -%></option> + <% end %> + </optgroup> + </select> + + <%= submit_tag message('update_verb'), :id => "submit-#{language.getKey()}", :disable_with => message('updating') %> + </form> + </td> + </tr> + <% end %> + </tbody> +</table> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb deleted file mode 100644 index f75218f7db9..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<h1><%= message('project_quality_profile.page') -%></h1> -<br/> -<% - form_tag( {:action => 'update_quality_profile', :id => @project.id }) do - project_profile = @project.profile -%> - - <span style= "padding-right: 10px"><%= message('project_quality_profile.select_profile_for_x', :params => @project.name) -%></span> - - <select name="quality_profile" id="quality_profile"> - <% - @profiles.each do |profile| - should_be_selected = (project_profile && project_profile==profile) || (!project_profile && profile.default_profile) - label = profile.name - label += ' (' + message('project_quality_profile.default_profile') + ')' if profile.default_profile - %> - <option <%= 'selected' if should_be_selected -%> value="<%= profile.id -%>"><%= label -%></option> - <% end %> - </select> - - <%= submit_tag message('update_verb'), :id => 'update_profile' %> - -<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb new file mode 100644 index 00000000000..68fc65062e4 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb @@ -0,0 +1,45 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 3.3 +# +class RemoveProjectsProfileId < ActiveRecord::Migration + + class Profile < ActiveRecord::Base + set_table_name 'rules_profiles' + end + + class Project < ActiveRecord::Base + belongs_to :profile + end + + class Property < ActiveRecord::Base + end + + def self.up + projects=Project.find(:all, :conditions => ['profile_id is not null and copy_resource_id is null'], :include => :profile) + projects.each do |project| + Property.create(:prop_key => "sonar.profile.#{project.profile.language}", :text_value => project.profile.name, :resource_id => project.id) + end + remove_column('projects', 'profile_id') + end + +end diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/InheritedProfilesTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/InheritedProfilesTest.java index 8674f421d4a..461caa5efb8 100644 --- a/sonar-server/src/test/java/org/sonar/server/configuration/InheritedProfilesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/configuration/InheritedProfilesTest.java @@ -54,20 +54,6 @@ public class InheritedProfilesTest extends AbstractDbUnitTestCase { } @Test - public void shouldNotDeleteInheritedProfile() { - setupData("shouldCheckCycles"); - profilesManager.deleteProfile(1); - checkTables("shouldNotDeleteInheritedProfile", "rules_profiles"); - } - - @Test - public void shouldRenameInheritedProfile() { - setupData("shouldCheckCycles"); - profilesManager.renameProfile(1, "newName"); - checkTables("shouldRenameInheritedProfile", "rules_profiles"); - } - - @Test public void shouldSetParent() { setupData("shouldSetParent"); profilesManager.changeParentProfile(2, "parent", "admin"); diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesManagerTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesManagerTest.java index 917cc55bfbc..162600f7871 100644 --- a/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesManagerTest.java +++ b/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesManagerTest.java @@ -21,13 +21,10 @@ package org.sonar.server.configuration; import org.junit.Before; import org.junit.Test; -import org.sonar.api.database.model.ResourceModel; import org.sonar.api.profiles.RulesProfile; import org.sonar.jpa.test.AbstractDbUnitTestCase; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; public class ProfilesManagerTest extends AbstractDbUnitTestCase { @@ -39,41 +36,13 @@ public class ProfilesManagerTest extends AbstractDbUnitTestCase { } @Test - public void testDeleteProfile() { - RulesProfile testDefaultProfile = RulesProfile.create("default", "java"); - testDefaultProfile.setDefaultProfile(true); - testDefaultProfile.setProvided(true); - RulesProfile testProfile = RulesProfile.create("not default", "java"); - ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test"); - testResourceWithProfile.setRulesProfile(testProfile); - getSession().save(testDefaultProfile, testProfile, testResourceWithProfile); - - getSession().commit(); - getSession().getEntityManager().clear(); - - manager.deleteProfile(testDefaultProfile.getId()); - // default profiles cannot be deleted - assertNotNull(getSession().getEntity(RulesProfile.class, testDefaultProfile.getId())); - - manager.deleteProfile(testProfile.getId()); - // default profiles cannot be deleted - assertNull(getSession().getEntity(RulesProfile.class, testProfile.getId())); - - testResourceWithProfile = getSession().getEntity(ResourceModel.class, testResourceWithProfile.getId()); - assertNull(testResourceWithProfile.getRulesProfile()); - - } - - @Test public void testDeleteAllProfiles() { RulesProfile test1 = RulesProfile.create("test1", "java"); test1.setDefaultProfile(true); test1.setProvided(true); RulesProfile test2 = RulesProfile.create("test2", "java"); - ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test"); - testResourceWithProfile.setRulesProfile(test1); - getSession().save(test1, test2, testResourceWithProfile); + getSession().save(test1, test2); assertEquals(new Long(2), getHQLCount(RulesProfile.class)); diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml deleted file mode 100644 index 5200875be21..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - - <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> - - <rules_profiles id="1" version="1" used_profile="true" provided="false" name="level1" default_profile="0" language="java" parent_name="[null]" enabled="true"/> - - <rules_profiles id="2" version="1" used_profile="true" provided="false" name="level2" default_profile="0" language="java" parent_name="level1" enabled="true"/> - - <rules_profiles id="3" version="1" used_profile="true" provided="false" name="level3" default_profile="0" language="java" parent_name="level2" enabled="true"/> - -</dataset> diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml deleted file mode 100644 index c7a2355a55a..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - - <rules id="1" name="foo" description="test" plugin_config_key="checker/foo" - plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/> - - <rules_profiles id="1" version="1" used_profile="true" provided="false" name="newName" default_profile="0" language="java" parent_name="[null]" enabled="true"/> - - <rules_profiles id="2" version="1" used_profile="true" provided="false" name="level2" default_profile="0" language="java" parent_name="newName" enabled="true"/> - - <rules_profiles id="3" version="1" used_profile="true" provided="false" name="level3" default_profile="0" language="java" parent_name="level2" enabled="true"/> - -</dataset> diff --git a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/measures.xml b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/measures.xml index daf3a4cf609..73a9937f781 100644 --- a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/measures.xml +++ b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/measures.xml @@ -15,11 +15,11 @@ <!-- Java classes --> <projects long_name="org.sonar.foo:File1" id="4" scope="FIL" kee="project:java:org.sonar.foo:File1" qualifier="CLA" name="File1" root_id="1" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="org.sonar.foo:File2" id="5" scope="FIL" kee="project:java:org.sonar.foo:File2" qualifier="CLA" name="File2" root_id="1" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="5" created_at="2008-12-25 01:00:01.00" build_date="2008-12-25 01:00:01.00" version="1.0" project_id="4" scope="FIL" qualifier="CLA" diff --git a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml index 03e194f11aa..cdb51032ca9 100644 --- a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml +++ b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml @@ -1,15 +1,15 @@ <dataset> <projects long_name="java project" id="1" scope="PRJ" kee="project:java" qualifier="TRK" name="java project" root_id="[null]" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="php project" id="2" scope="PRJ" kee="project:a-php-project" qualifier="TRK" name="php project" root_id="[null]" - description="[null]" enabled="true" profile_id="[null]" language="php" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="php" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="org.sonar.foo" id="3" scope="DIR" kee="project:java:org.sonar.foo" qualifier="PAC" name="org.sonar.foo" root_id="1" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <!-- Java project --> diff --git a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/views.xml b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/views.xml index aac9b0863b0..2b6a2036717 100644 --- a/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/views.xml +++ b/sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/views.xml @@ -2,21 +2,21 @@ <!-- java project --> <projects long_name="java project" id="1" scope="PRJ" kee="project:java" qualifier="TRK" name="java project" root_id="[null]" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> <!-- views --> <projects long_name="Root view" id="2" scope="PRJ" kee="ROOT_VIEW" qualifier="VW" name="Root view" root_id="[null]" - description="[null]" enabled="true" profile_id="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]"/> <projects long_name="Sub view" id="3" scope="PRJ" kee="SUB_VIEW" qualifier="SVW" name="Sub view" root_id="2" - description="[null]" enabled="true" profile_id="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"/> + description="[null]" enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]"/> <!-- java project copy used in view --> <projects long_name="java project" id="4" scope="FIL" kee="cp-project:java" qualifier="TRK" name="java project" root_id="2" - description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="1"/> + description="[null]" enabled="true" language="java" copy_resource_id="1"/> <!-- snapshots --> |