dao.update(qualityProfile);
}
- public void updateDefaultProfile(Integer id, UserSession userSession) {
+ public void setDefaultProfile(Integer id, UserSession userSession) {
QualityProfileDto qualityProfile = validateUpdateDefaultProfile(id, userSession);
propertiesDao.setProperty(new PropertyDto().setKey(PROPERTY_PREFIX + qualityProfile.getLanguage()).setValue(qualityProfile.getName()));
}
- public void updateDefaultProfile(String name, String language, UserSession userSession) {
- updateDefaultProfile(findNotNull(name, language).getId(), userSession);
+ public void setDefaultProfile(String name, String language, UserSession userSession) {
+ setDefaultProfile(findNotNull(name, language).getId(), userSession);
}
public QProfileProjects projects(Integer profileId) {
}
public List<QProfile> searchProfiles() {
- throw new UnsupportedOperationException();
+ return search.searchProfiles();
}
public void searchProfile(Integer profileId) {
operations.renameProfile(profileId, newName, UserSession.get());
}
- public void updateDefaultProfile(Integer profileId) {
- operations.updateDefaultProfile(profileId, UserSession.get());
+ public void setDefaultProfile(Integer profileId) {
+ operations.setDefaultProfile(profileId, UserSession.get());
}
/**
* Used by WS
*/
- public void updateDefaultProfile(String name, String language) {
- operations.updateDefaultProfile(name, language, UserSession.get());
+ public void setDefaultProfile(String name, String language) {
+ operations.setDefaultProfile(name, language, UserSession.get());
}
public void copyProfile() {
throw new UnsupportedOperationException();
}
- /**
- * Used in /project/profile
- */
- public List<QProfile> profiles(String language) {
- throw new UnsupportedOperationException();
- }
-
public void addProject(Integer profileId, Long projectId) {
operations.addProject(profileId, projectId, UserSession.get());
}
# Since v.3.3
def set_as_default
verify_post_request
- Internal.qprofiles.updateDefaultProfile(params[:name], params[:language])
+ Internal.quality_profiles.setDefaultProfile(params[:name], params[:language])
render_success
end
paging = Java::OrgSonarServerQualityprofile::Paging.create(@pagination.per_page.to_i, @pagination.page.to_i)
if @activation==STATUS_ACTIVE
- result = Internal.qprofiles.searchActiveRules(query, paging)
+ result = Internal.quality_profiles.searchActiveRules(query, paging)
else
- result = Internal.qprofiles.searchInactiveRules(query, paging)
+ result = Internal.quality_profiles.searchInactiveRules(query, paging)
end
@rules = result.rules
unless @searchtext.blank?
if @activation==STATUS_ACTIVE
- @hidden_inactives = Internal.qprofiles.countInactiveRules(query)
+ @hidden_inactives = Internal.quality_profiles.countInactiveRules(query)
else
- @hidden_actives = Internal.qprofiles.countInactiveRules(query)
+ @hidden_actives = Internal.quality_profiles.countInactiveRules(query)
end
end
end
end
end
end
- result = Internal.qprofiles.newProfile(params[:name], params[:language], files_by_key)
+ result = Internal.quality_profiles.newProfile(params[:name], params[:language], files_by_key)
flash[:notice] = message('quality_profiles.profile_x_created', :params => result.profile.name)
# only 4 messages are kept each time to avoid cookie overflow.
# POST /profiles/set_as_default/<id>
def set_as_default
verify_post_request
+ require_parameters 'id'
+
call_backend do
- Internal.qprofiles.updateDefaultProfile(params[:id].to_i)
+ Internal.quality_profiles.setDefaultProfile(params[:id].to_i)
end
redirect_to :action => 'index'
end
#
#
def projects
+ require_parameters 'id'
+
call_backend do
- result = Internal.qprofiles.projects(params[:id].to_i)
+ result = Internal.quality_profiles.projects(params[:id].to_i)
@profile = result.profile
@projects = Api::Utils.insensitive_sort(result.projects.to_a) { |p| p.name }
set_profile_breadcrumbs
# POST /profiles/add_project?id=<profile id>&project=<project id>
def add_project
verify_post_request
+ require_parameters 'id', 'project'
# Used for Selenium test as it send a project key instead of a project id
begin
profile_id = params[:id].to_i
call_backend do
- Internal.qprofiles.addProject(profile_id, project_id.to_i)
+ Internal.quality_profiles.addProject(profile_id, project_id.to_i)
end
redirect_to :action => 'projects', :id => profile_id
end
# POST /profiles/remove_project?id=<profile id>&project=<project id>
def remove_project
verify_post_request
+ require_parameters 'id', 'project'
+
profile_id = params[:id].to_i
call_backend do
- Internal.qprofiles.removeProject(profile_id, params[:project].to_i)
+ Internal.quality_profiles.removeProject(profile_id, params[:project].to_i)
end
redirect_to :action => 'projects', :id => profile_id
end
def rename
verify_post_request
verify_ajax_request
+ require_parameters 'id'
call_backend do
- Internal.qprofiles.renameProfile(params[:id].to_i, params[:new_name])
+ Internal.quality_profiles.renameProfile(params[:id].to_i, params[:new_name])
end
render :text => 'ok', :status => 200
end
call_backend do
if profile_id.blank?
- Internal.qprofiles.removeProjectByLanguage(language, project)
+ Internal.quality_profiles.removeProjectByLanguage(language, project)
else
- Internal.qprofiles.addProject(profile_id.to_i, project)
+ Internal.quality_profiles.addProject(profile_id.to_i, project)
end
end
component(Java::OrgSonarServerGroup::InternalGroupMembershipService.java_class)
end
- def self.qprofiles
+ def self.quality_profiles
component(Java::OrgSonarServerQualityprofile::QProfiles.java_class)
end
public void update_default_profile() throws Exception {
when(dao.selectById(1)).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
- operations.updateDefaultProfile(1, MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
+ operations.setDefaultProfile(1, MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
ArgumentCaptor<PropertyDto> argumentCaptor = ArgumentCaptor.forClass(PropertyDto.class);
verify(propertiesDao).setProperty(argumentCaptor.capture());
when(dao.selectByNameAndLanguage("My profile", "java")).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
when(dao.selectById(1)).thenReturn(new QualityProfileDto().setId(1).setName("My profile").setLanguage("java"));
- operations.updateDefaultProfile("My profile", "java", MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
+ operations.setDefaultProfile("My profile", "java", MockUserSession.create().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN));
ArgumentCaptor<PropertyDto> argumentCaptor = ArgumentCaptor.forClass(PropertyDto.class);
verify(propertiesDao).setProperty(argumentCaptor.capture());
qProfiles = new QProfiles(search, operations, rules);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void search_profiles() throws Exception {
qProfiles.searchProfiles();
+ verify(search).searchProfiles();
}
@Test(expected = UnsupportedOperationException.class)
@Test
public void update_default_profile() throws Exception {
- qProfiles.updateDefaultProfile(1);
- verify(operations).updateDefaultProfile(eq(1), any(UserSession.class));
+ qProfiles.setDefaultProfile(1);
+ verify(operations).setDefaultProfile(eq(1), any(UserSession.class));
}
@Test
public void update_default_profile_from_name_and_language() throws Exception {
- qProfiles.updateDefaultProfile("Default", "java");
- verify(operations).updateDefaultProfile(eq("Default"), eq("java"), any(UserSession.class));
+ qProfiles.setDefaultProfile("Default", "java");
+ verify(operations).setDefaultProfile(eq("Default"), eq("java"), any(UserSession.class));
}
@Test(expected = UnsupportedOperationException.class)
qProfiles.profile(1);
}
- @Test(expected = UnsupportedOperationException.class)
- public void get_profiles_from_language() throws Exception {
- qProfiles.profiles("java");
- }
-
@Test
public void add_project() throws Exception {
qProfiles.addProject(1, 10L);