diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-16 17:40:20 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-16 17:40:20 +0200 |
commit | 7c84df20dbd367c247389726790026394a53ebb2 (patch) | |
tree | f771a5c298d1f820fee629eab8ab5de7b4346a31 | |
parent | b7e8b9db05cf1e6442315c77fc539a1f3bfc08d5 (diff) | |
download | sonarqube-7c84df20dbd367c247389726790026394a53ebb2.tar.gz sonarqube-7c84df20dbd367c247389726790026394a53ebb2.zip |
Fix /api/profiles due to missing defaultProfile() method
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java | 10 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb | 22 |
2 files changed, 18 insertions, 14 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java index 7f496b39ea3..2fb0b470d19 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java @@ -191,10 +191,14 @@ public class QProfileService implements ServerComponent { factory.setDefault(key); } + /** + * Used in /api/profiles and in /profiles/export + * @param language + * @return + */ @CheckForNull - public String getDefault(String language) { - QualityProfileDto profile = factory.getDefault(language); - return profile != null ? profile.getKey() : null; + public QualityProfileDto getDefault(String language) { + return factory.getDefault(language); } private void verifyAdminPermission() { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb index d3fecdb935e..5897a32b222 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/profiles_controller.rb @@ -40,14 +40,14 @@ class Api::ProfilesController < Api::ApiController project = Project.by_key(project_key) not_found('Unknown project') unless project if language.present? - default_profile_by_language[language] = Internal.quality_profiles.defaultProfile(language) + default_profile_by_language[language] = Internal.qprofile_service.getDefault(language) profile = Internal.quality_profiles.findProfileByProjectAndLanguage(project.id, language) profiles << profile if profile # Return default profile if the project is not associate to a profile profiles << default_profile_by_language[language] unless profile else Api::Utils.languages.each do |language| - default_profile_by_language[language.getKey()] = Internal.quality_profiles.defaultProfile(language.getKey()) + default_profile_by_language[language.getKey()] = Internal.qprofile_service.getDefault(language.getKey()) profile = Internal.quality_profiles.findProfileByProjectAndLanguage(project.id, language.getKey()) profiles << profile if profile # Return default profile if the project is not associate to a profile @@ -65,7 +65,7 @@ class Api::ProfilesController < Api::ApiController profiles.each do |p| lang = p.language unless default_profile_by_language[lang] - default_profile_by_language[lang] = Internal.quality_profiles.defaultProfile(lang.to_s) + default_profile_by_language[lang] = Internal.qprofile_service.getDefault(lang.to_s) end end @@ -83,9 +83,10 @@ class Api::ProfilesController < Api::ApiController access_denied unless has_role?(:profileadmin) require_parameters :language, :name - profile_key=Java::OrgSonarCoreQualityprofileDb::QualityProfileKey.of(params[:name], params[:language]) call_backend do - Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).delete(profile_key) + profile = Internal.quality_profiles.profile(params[:name], params[:language]) + not_found('Profile not found') unless profile + Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).delete(profile.key) end render_success('Profile destroyed') end @@ -97,8 +98,7 @@ class Api::ProfilesController < Api::ApiController verify_post_request profile = Internal.quality_profiles.profile(params[:name], params[:language]) not_found('Profile not found') unless profile - profile_key=Java::OrgSonarCoreQualityprofileDb::QualityProfileKey.of(profile.name, profile.language) - Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).setDefault(profile_key) + Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).setDefault(profile.key) render_success end @@ -131,13 +131,13 @@ class Api::ProfilesController < Api::ApiController language = params[:language] if (params[:name].blank?) - profile = Internal.quality_profiles.defaultProfile(language) + profile = Internal.qprofile_service.getDefault(language) else profile = Internal.quality_profiles.profile(params[:name], params[:language]) end - profile_key=Java::OrgSonarCoreQualityprofileDb::QualityProfileKey.of(profile.name, profile.language) - backup = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).backup(profile_key) + not_found('Profile not found') unless profile + backup = Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).backup(profile.key) respond_to do |format| format.xml { render :xml => backup } @@ -228,7 +228,7 @@ class Api::ProfilesController < Api::ApiController xml.profile do xml.name(@profile.name) xml.language(@profile.language) - xml.parent(@profile.parent_name) if @profile.parent_name.present? + xml.parent(@profile.parent_kee) if @profile.parent_kee.present? xml.default(@profile.default_profile?) @active_rules.each do |active_rule| |