001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.wsclient.services;
021
022 /**
023 * @since 2.7
024 */
025 public final class ProfileQuery extends Query<Profile> {
026 public static final String BASE_URL = "/api/profiles";
027
028 private String language;
029 private String name;//optional
030 private String[] ruleRepositories;//optional
031 private String[] ruleSeverities;//optional
032
033 private ProfileQuery(String language) {
034 this.language = language;
035 }
036
037 public String getLanguage() {
038 return language;
039 }
040
041 public String getName() {
042 return name;
043 }
044
045 public String[] getRuleRepositories() {
046 return ruleRepositories;
047 }
048
049 public String[] getRuleSeverities() {
050 return ruleSeverities;
051 }
052
053 public ProfileQuery setName(String name) {
054 this.name = name;
055 return this;
056 }
057
058 public ProfileQuery setRuleRepositories(String[] ruleRepositories) {
059 this.ruleRepositories = ruleRepositories;
060 return this;
061 }
062
063 public ProfileQuery setRuleSeverities(String[] ruleSeverities) {
064 this.ruleSeverities = ruleSeverities;
065 return this;
066 }
067
068 @Override
069 public Class<Profile> getModelClass() {
070 return Profile.class;
071 }
072
073 @Override
074 public String getUrl() {
075 StringBuilder url = new StringBuilder(BASE_URL);
076 url.append('?');
077 appendUrlParameter(url, "language", language);
078 appendUrlParameter(url, "name", name);
079 appendUrlParameter(url, "rule_repositories", ruleRepositories);
080 appendUrlParameter(url, "rule_severities", ruleSeverities);
081 return url.toString();
082 }
083
084 public static ProfileQuery createWithLanguage(String language) {
085 return new ProfileQuery(language);
086 }
087
088 public static ProfileQuery create(String language, String name) {
089 return new ProfileQuery(language).setName(name);
090 }
091 }