@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.authentication.ws; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.issue.actionplan; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -21,6 +21,7 @@ package org.sonar.server.issue.ws; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.io.Resources; | |||
import org.sonar.api.component.Component; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.issue.*; | |||
@@ -80,14 +81,16 @@ public class IssueShowAction implements RequestHandler { | |||
this.durations = durations; | |||
} | |||
void define (WebService.NewController controller) { | |||
void define(WebService.NewController controller) { | |||
WebService.NewAction action = controller.createAction("show") | |||
.setDescription("Detail of issue") | |||
.setSince("4.2") | |||
.setInternal(true) | |||
.setHandler(this); | |||
.setHandler(this) | |||
.setResponseExample(Resources.getResource(this.getClass(), "example-show.json")); | |||
action.createParam("key") | |||
.setDescription("Issue key"); | |||
.setDescription("Issue key") | |||
.setExampleValue("5bccd6e8-f525-43a2-8d76-fcb13dde79ef"); | |||
} | |||
@Override | |||
@@ -237,7 +240,6 @@ public class IssueShowAction implements RequestHandler { | |||
json.endArray(); | |||
} | |||
// TODO all available actions should be returned by ActionService or another service | |||
private List<String> actions(DefaultIssue issue) { | |||
List<String> actions = newArrayList(); | |||
String login = UserSession.get().login(); |
@@ -293,7 +293,6 @@ public class IssuesWs implements WebService { | |||
.setRequired(true) | |||
.setExampleValue("01fc972e-2a3c-433e-bcae-0bd7f88f5123,01fc972e-2a3c-433e-bcae-0bd7f88f9999"); | |||
action.createParam("actions") | |||
// TODO It's not possible to load actions as actions defined by plugins are not availables | |||
.setDescription("Comma-separated list of actions to perform. Possible values: assign | set_severity | plan | do_transition.") | |||
.setRequired(true) | |||
.setExampleValue("assign,plan"); |
@@ -0,0 +1,92 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.permission.ws; | |||
import com.google.common.collect.ImmutableSet; | |||
import org.sonar.api.security.DefaultGroups; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.core.permission.ComponentPermissions; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
public class PermissionsWs implements WebService { | |||
@Override | |||
public void define(Context context) { | |||
NewController controller = context.createController("api/permissions"); | |||
controller.setDescription("Permissions"); | |||
controller.setSince("3.7"); | |||
defineAddAction(controller); | |||
defineRemoveAction(controller); | |||
controller.done(); | |||
} | |||
private void defineAddAction(NewController controller) { | |||
NewAction action = controller.createAction("add") | |||
.setDescription("Add a global or a project permission. Requires Administer System permission for global permissions, \n" + | |||
"requires Administer permission on project for project permissions.") | |||
.setSince("3.7") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("permission") | |||
.setDescription("Key of the permission to add.") | |||
.setRequired(true) | |||
.setPossibleValues(new ImmutableSet.Builder().<String>addAll(GlobalPermissions.ALL).<String>addAll(ComponentPermissions.ALL).build()) | |||
.setExampleValue("shareDashboard"); | |||
action.createParam("user") | |||
.setDescription("User login. Required if group is not set.") | |||
.setExampleValue("myuser"); | |||
action.createParam("group") | |||
.setDescription("Group name or \"" + DefaultGroups.ANYONE + "\". Required if user is not set.") | |||
.setExampleValue(DefaultGroups.ADMINISTRATORS); | |||
action.createParam("component") | |||
.setDescription("Key of the project. Required if a project permission is set. Available since version 4.0.") | |||
.setExampleValue("org.codehaus.sonar"); | |||
} | |||
private void defineRemoveAction(NewController controller) { | |||
NewAction action = controller.createAction("remove") | |||
.setDescription("Remove a global or a project permission. Requires Administer System permission for global permissions, \n" + | |||
"requires Administer permission on project for project permissions.") | |||
.setSince("3.7") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("permission") | |||
.setDescription("Key of the permission to remove.") | |||
.setRequired(true) | |||
.setPossibleValues(new ImmutableSet.Builder().<String>addAll(GlobalPermissions.ALL).<String>addAll(ComponentPermissions.ALL).build()) | |||
.setExampleValue("shareDashboard"); | |||
action.createParam("user") | |||
.setDescription("User login. Required if group is not set.") | |||
.setExampleValue("myuser"); | |||
action.createParam("group") | |||
.setDescription("Group name or \"" + DefaultGroups.ANYONE + "\". Required if user is not set.") | |||
.setExampleValue(DefaultGroups.ADMINISTRATORS); | |||
action.createParam("component") | |||
.setDescription("Key of the project. Required if a project permission is set. Available since version 4.0.") | |||
.setExampleValue("org.codehaus.sonar"); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.permission.ws; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -55,13 +55,7 @@ import org.sonar.core.measure.MeasureFilterFactory; | |||
import org.sonar.core.metric.DefaultMetricFinder; | |||
import org.sonar.core.notification.DefaultNotificationManager; | |||
import org.sonar.core.permission.PermissionFacade; | |||
import org.sonar.core.persistence.DaoUtils; | |||
import org.sonar.core.persistence.DatabaseVersion; | |||
import org.sonar.core.persistence.DefaultDatabase; | |||
import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.persistence.PreviewDatabaseFactory; | |||
import org.sonar.core.persistence.SemaphoreUpdater; | |||
import org.sonar.core.persistence.SemaphoresImpl; | |||
import org.sonar.core.persistence.*; | |||
import org.sonar.core.preview.PreviewCache; | |||
import org.sonar.core.profiling.Profiling; | |||
import org.sonar.core.purge.PurgeProfiler; | |||
@@ -90,32 +84,10 @@ import org.sonar.server.component.DefaultRubyComponentService; | |||
import org.sonar.server.db.EmbeddedDatabaseFactory; | |||
import org.sonar.server.db.migrations.DatabaseMigrations; | |||
import org.sonar.server.db.migrations.DatabaseMigrator; | |||
import org.sonar.server.debt.DebtCharacteristicsXMLImporter; | |||
import org.sonar.server.debt.DebtModelBackup; | |||
import org.sonar.server.debt.DebtModelLookup; | |||
import org.sonar.server.debt.DebtModelOperations; | |||
import org.sonar.server.debt.DebtModelPluginRepository; | |||
import org.sonar.server.debt.DebtModelService; | |||
import org.sonar.server.debt.DebtModelXMLExporter; | |||
import org.sonar.server.debt.DebtRulesXMLImporter; | |||
import org.sonar.server.debt.*; | |||
import org.sonar.server.es.ESIndex; | |||
import org.sonar.server.es.ESNode; | |||
import org.sonar.server.issue.ActionService; | |||
import org.sonar.server.issue.AssignAction; | |||
import org.sonar.server.issue.CommentAction; | |||
import org.sonar.server.issue.DefaultIssueFinder; | |||
import org.sonar.server.issue.InternalRubyIssueService; | |||
import org.sonar.server.issue.IssueBulkChangeService; | |||
import org.sonar.server.issue.IssueChangelogFormatter; | |||
import org.sonar.server.issue.IssueChangelogService; | |||
import org.sonar.server.issue.IssueCommentService; | |||
import org.sonar.server.issue.IssueService; | |||
import org.sonar.server.issue.IssueStatsFinder; | |||
import org.sonar.server.issue.PlanAction; | |||
import org.sonar.server.issue.PublicRubyIssueService; | |||
import org.sonar.server.issue.ServerIssueStorage; | |||
import org.sonar.server.issue.SetSeverityAction; | |||
import org.sonar.server.issue.TransitionAction; | |||
import org.sonar.server.issue.*; | |||
import org.sonar.server.issue.actionplan.ActionPlanService; | |||
import org.sonar.server.issue.actionplan.ActionPlanWs; | |||
import org.sonar.server.issue.filter.IssueFilterService; | |||
@@ -130,52 +102,17 @@ import org.sonar.server.permission.InternalPermissionTemplateService; | |||
import org.sonar.server.permission.PermissionFinder; | |||
import org.sonar.server.platform.ws.RestartHandler; | |||
import org.sonar.server.platform.ws.SystemWs; | |||
import org.sonar.server.plugins.BatchWs; | |||
import org.sonar.server.plugins.InstalledPluginReferentialFactory; | |||
import org.sonar.server.plugins.PluginDownloader; | |||
import org.sonar.server.plugins.ServerExtensionInstaller; | |||
import org.sonar.server.plugins.ServerPluginJarInstaller; | |||
import org.sonar.server.plugins.ServerPluginJarsInstaller; | |||
import org.sonar.server.plugins.ServerPluginRepository; | |||
import org.sonar.server.plugins.UpdateCenterClient; | |||
import org.sonar.server.plugins.UpdateCenterMatrixFactory; | |||
import org.sonar.server.plugins.*; | |||
import org.sonar.server.qualitygate.QgateProjectFinder; | |||
import org.sonar.server.qualitygate.QualityGates; | |||
import org.sonar.server.qualitygate.RegisterQualityGates; | |||
import org.sonar.server.qualitygate.ws.QgateAppHandler; | |||
import org.sonar.server.qualitygate.ws.QualityGatesWs; | |||
import org.sonar.server.qualityprofile.DefaultProfilesCache; | |||
import org.sonar.server.qualityprofile.ESActiveRule; | |||
import org.sonar.server.qualityprofile.ProfilesManager; | |||
import org.sonar.server.qualityprofile.QProfileActiveRuleOperations; | |||
import org.sonar.server.qualityprofile.QProfileBackup; | |||
import org.sonar.server.qualityprofile.QProfileLookup; | |||
import org.sonar.server.qualityprofile.QProfileOperations; | |||
import org.sonar.server.qualityprofile.QProfileProjectLookup; | |||
import org.sonar.server.qualityprofile.QProfileProjectOperations; | |||
import org.sonar.server.qualityprofile.QProfileRepositoryExporter; | |||
import org.sonar.server.qualityprofile.QProfileRuleLookup; | |||
import org.sonar.server.qualityprofile.QProfiles; | |||
import org.sonar.server.qualityprofile.ws.QProfileBackupWsHandler; | |||
import org.sonar.server.qualityprofile.*; | |||
import org.sonar.server.qualityprofile.ws.QProfileRestoreDefaultAction; | |||
import org.sonar.server.qualityprofile.ws.QProfilesWs; | |||
import org.sonar.server.rule.DeprecatedRulesDefinition; | |||
import org.sonar.server.rule.ESRuleTags; | |||
import org.sonar.server.rule.RegisterRules; | |||
import org.sonar.server.rule.RubyRuleService; | |||
import org.sonar.server.rule.RuleDefinitionsLoader; | |||
import org.sonar.server.rule.RuleOperations; | |||
import org.sonar.server.rule.RuleRegistry; | |||
import org.sonar.server.rule.RuleRepositories; | |||
import org.sonar.server.rule.RuleTagLookup; | |||
import org.sonar.server.rule.RuleTagOperations; | |||
import org.sonar.server.rule.RuleTags; | |||
import org.sonar.server.rule.Rules; | |||
import org.sonar.server.rule.ws.AddTagsWsHandler; | |||
import org.sonar.server.rule.ws.RemoveTagsWsHandler; | |||
import org.sonar.server.rule.ws.RuleSearchWsHandler; | |||
import org.sonar.server.rule.ws.RuleShowWsHandler; | |||
import org.sonar.server.rule.ws.RuleTagsWs; | |||
import org.sonar.server.rule.ws.RulesWs; | |||
import org.sonar.server.rule.*; | |||
import org.sonar.server.rule.ws.*; | |||
import org.sonar.server.rule2.RuleService; | |||
import org.sonar.server.rule2.ws.RulesWebService; | |||
import org.sonar.server.rule2.ws.SearchAction; | |||
@@ -188,40 +125,15 @@ import org.sonar.server.source.ws.ScmAction; | |||
import org.sonar.server.source.ws.ScmWriter; | |||
import org.sonar.server.source.ws.ShowAction; | |||
import org.sonar.server.source.ws.SourcesWs; | |||
import org.sonar.server.startup.CleanPreviewAnalysisCache; | |||
import org.sonar.server.startup.CopyRequirementsFromCharacteristicsToRules; | |||
import org.sonar.server.startup.GeneratePluginIndex; | |||
import org.sonar.server.startup.GwtPublisher; | |||
import org.sonar.server.startup.JdbcDriverDeployer; | |||
import org.sonar.server.startup.LogServerId; | |||
import org.sonar.server.startup.RegisterDashboards; | |||
import org.sonar.server.startup.RegisterDebtModel; | |||
import org.sonar.server.startup.RegisterMetrics; | |||
import org.sonar.server.startup.RegisterNewMeasureFilters; | |||
import org.sonar.server.startup.RegisterPermissionTemplates; | |||
import org.sonar.server.startup.RegisterQualityProfiles; | |||
import org.sonar.server.startup.RegisterServletFilters; | |||
import org.sonar.server.startup.RenameDeprecatedPropertyKeys; | |||
import org.sonar.server.startup.ServerMetadataPersister; | |||
import org.sonar.server.startup.*; | |||
import org.sonar.server.text.MacroInterpreter; | |||
import org.sonar.server.text.RubyTextService; | |||
import org.sonar.server.ui.JRubyI18n; | |||
import org.sonar.server.ui.JRubyProfiling; | |||
import org.sonar.server.ui.PageDecorations; | |||
import org.sonar.server.ui.Views; | |||
import org.sonar.server.user.DefaultUserService; | |||
import org.sonar.server.user.DoPrivileged; | |||
import org.sonar.server.user.GroupMembershipFinder; | |||
import org.sonar.server.user.GroupMembershipService; | |||
import org.sonar.server.user.NewUserNotifier; | |||
import org.sonar.server.user.SecurityRealmFactory; | |||
import org.sonar.server.util.BooleanTypeValidation; | |||
import org.sonar.server.util.FloatTypeValidation; | |||
import org.sonar.server.util.IntegerTypeValidation; | |||
import org.sonar.server.util.StringListTypeValidation; | |||
import org.sonar.server.util.StringTypeValidation; | |||
import org.sonar.server.util.TextTypeValidation; | |||
import org.sonar.server.util.TypeValidations; | |||
import org.sonar.server.user.*; | |||
import org.sonar.server.util.*; | |||
import org.sonar.server.ws.ListingWs; | |||
import org.sonar.server.ws.WebServiceEngine; | |||
@@ -357,7 +269,7 @@ class ServerComponents { | |||
pico.addSingleton(QProfileRepositoryExporter.class); | |||
pico.addSingleton(DefaultProfilesCache.class); | |||
pico.addSingleton(ESActiveRule.class); | |||
pico.addSingleton(QProfileBackupWsHandler.class); | |||
pico.addSingleton(QProfileRestoreDefaultAction.class); | |||
pico.addSingleton(QProfilesWs.class); | |||
// rule |
@@ -23,18 +23,29 @@ package org.sonar.server.qualityprofile.ws; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.RequestHandler; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.server.qualityprofile.QProfileBackup; | |||
import org.sonar.server.qualityprofile.QProfileResult; | |||
public class QProfileBackupWsHandler implements RequestHandler { | |||
public class QProfileRestoreDefaultAction implements RequestHandler { | |||
private final QProfileBackup qProfileBackup; | |||
public QProfileBackupWsHandler(QProfileBackup qProfileBackup) { | |||
public QProfileRestoreDefaultAction(QProfileBackup qProfileBackup) { | |||
this.qProfileBackup = qProfileBackup; | |||
} | |||
void define(WebService.NewController controller){ | |||
WebService.NewAction restoreDefault = controller.createAction("restore_default") | |||
.setDescription("Restore default profiles") | |||
.setSince("4.4") | |||
.setHandler(this); | |||
restoreDefault.createParam("language") | |||
.setDescription("Restore default profiles for this language") | |||
.setExampleValue("java"); | |||
} | |||
@Override | |||
public void handle(Request request, Response response) { | |||
final String language = request.mandatoryParam("language"); |
@@ -20,14 +20,16 @@ | |||
package org.sonar.server.qualityprofile.ws; | |||
import com.google.common.io.Resources; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
public class QProfilesWs implements WebService { | |||
private final QProfileBackupWsHandler qProfileBackupWsHandler; | |||
private final QProfileRestoreDefaultAction qProfileRestoreDefaultAction; | |||
public QProfilesWs(QProfileBackupWsHandler qProfileBackupWsHandler) { | |||
this.qProfileBackupWsHandler = qProfileBackupWsHandler; | |||
public QProfilesWs(QProfileRestoreDefaultAction qProfileRestoreDefaultAction) { | |||
this.qProfileRestoreDefaultAction = qProfileRestoreDefaultAction; | |||
} | |||
@Override | |||
@@ -35,13 +37,92 @@ public class QProfilesWs implements WebService { | |||
NewController controller = context.createController("api/qprofiles") | |||
.setDescription("Quality profiles management"); | |||
NewAction restoreDefault = controller.createAction("restore_default") | |||
.setDescription("Restore default profiles") | |||
.setSince("4.4") | |||
.setHandler(qProfileBackupWsHandler); | |||
restoreDefault.createParam("language") | |||
.setDescription("Restore default profiles for this language"); | |||
qProfileRestoreDefaultAction.define(controller); | |||
defineListAction(controller); | |||
defineBackupAction(controller); | |||
defineRestoreAction(controller); | |||
defineDestroyAction(controller); | |||
defineSetAsDefaultAction(controller); | |||
controller.done(); | |||
} | |||
private void defineListAction(NewController controller) { | |||
WebService.NewAction action = controller.createAction("list") | |||
.setDescription("Get a list of profiles.") | |||
.setSince("3.3") | |||
.setHandler(RailsHandler.INSTANCE) | |||
.setResponseExample(Resources.getResource(this.getClass(), "example-list.json")); | |||
action.createParam("language") | |||
.setDescription("Profile language.") | |||
.setRequired(true) | |||
.setExampleValue("java"); | |||
action.createParam("project") | |||
.setDescription("Project key or id.") | |||
.setExampleValue("org.codehaus.sonar:sonar"); | |||
} | |||
private void defineBackupAction(NewController controller) { | |||
WebService.NewAction action = controller.createAction("backup") | |||
.setDescription("Backup a quality profile. Requires Administer Quality Profiles permission.") | |||
.setSince("3.1") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("language") | |||
.setDescription("Profile language.") | |||
.setRequired(true) | |||
.setExampleValue("java"); | |||
action.createParam("name") | |||
.setDescription("Profile name. If not set, the default profile for the selected language is used.") | |||
.setExampleValue("Sonar way"); | |||
} | |||
private void defineRestoreAction(NewController controller) { | |||
WebService.NewAction action = controller.createAction("restore") | |||
.setDescription("Restore a quality profile backup. Requires Administer Quality Profiles permission.") | |||
.setSince("3.1") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("backup") | |||
.setRequired(true) | |||
.setDescription("Path to the file containing the backup (HTML format)"); | |||
} | |||
private void defineDestroyAction(NewController controller) { | |||
WebService.NewAction action = controller.createAction("destroy") | |||
.setDescription("Delete a quality profile. Requires Administer Quality Profiles permission.") | |||
.setSince("3.3") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("language") | |||
.setDescription("Profile language.") | |||
.setRequired(true) | |||
.setExampleValue("java"); | |||
action.createParam("name") | |||
.setDescription("Profile name.") | |||
.setRequired(true) | |||
.setExampleValue("Sonar way"); | |||
} | |||
private void defineSetAsDefaultAction(NewController controller) { | |||
WebService.NewAction action = controller.createAction("set_as_default") | |||
.setDescription("Set a quality profile as Default. Requires Administer Quality Profiles permission.") | |||
.setSince("3.3") | |||
.setPost(true) | |||
.setHandler(RailsHandler.INSTANCE); | |||
action.createParam("language") | |||
.setDescription("Profile language.") | |||
.setRequired(true) | |||
.setExampleValue("java"); | |||
action.createParam("name") | |||
.setDescription("Profile name.") | |||
.setRequired(true) | |||
.setExampleValue("Sonar way"); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.qualityprofile.ws; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -0,0 +1,56 @@ | |||
{ | |||
"issue": { | |||
"key": "dc94c283-4260-48c8-a0d3-a32f4b1cabe6", | |||
"rule": "squid:S1596", | |||
"ruleName": "Collections.emptyList(),emptyMap() and emptySet() should be used instead of Collections.EMPTY_LIST, EMPTY_MAP and EMPTY_SET", | |||
"line": 36, | |||
"message": "Replace \"Collections.EMPTY_LIST\" by \"Collections.emptyList()\".", | |||
"status": "OPEN", | |||
"severity": "MAJOR", | |||
"author": "Developer 1", | |||
"debt": "2min", | |||
"creationDate": "2014-02-14T23:04:29+0100", | |||
"fCreationDate": "Feb 14, 2014 11:04 PM", | |||
"updateDate": "2014-03-04T23:03:44+0100", | |||
"fUpdateDate": "Mar 4, 2014 11:03 PM", | |||
"fUpdateAge": "about a month", | |||
"component": "com.sonarsource.cobol:cobol-preprocessor:src/main/java/com/sonarsource/cobol/pp/CobolPreprocessor.java", | |||
"componentLongName": "src/main/java/com/sonarsource/cobol/pp/CobolPreprocessor.java", | |||
"componentQualifier": "FIL", | |||
"project": "com.sonarsource.cobol:cobol", | |||
"projectName": "SonarSource :: Cobol", | |||
"subProjectName": "SonarSource :: Cobol :: Preprocessor", | |||
"subCharacteristic": "Readability", | |||
"characteristic": "Maintainability", | |||
"transitions": [ | |||
"confirm", | |||
"resolve", | |||
"falsepositive" | |||
], | |||
"actions": [ | |||
"comment", | |||
"assign", | |||
"assign_to_me", | |||
"plan", | |||
"set_severity", | |||
"link-to-jira" | |||
], | |||
"comments": [ ], | |||
"changelog": [ | |||
{ | |||
"creationDate": "2014-02-14T23:04:29+0100", | |||
"fCreationDate": "Feb 14, 2014 11:04 PM", | |||
"diffs": [ | |||
"Created" | |||
] | |||
}, | |||
{ | |||
"creationDate": "2014-03-04T23:03:44+0100", | |||
"fCreationDate": "Mar 4, 2014 11:03 PM", | |||
"diffs": [ | |||
"Technical Debt changed to 2min" | |||
] | |||
} | |||
] | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
[ | |||
{ | |||
"name": "Sonar way with Findbugs", | |||
"language": "java", | |||
"default": false | |||
}, | |||
{ | |||
"name": "Sonar way", | |||
"language": "java", | |||
"default": false | |||
} | |||
] |
@@ -68,6 +68,7 @@ public class IssuesWsTest { | |||
assertThat(action.isPost()).isFalse(); | |||
assertThat(action.isInternal()).isTrue(); | |||
assertThat(action.handler()).isSameAs(showAction); | |||
assertThat(action.responseExampleAsString()).isNotEmpty(); | |||
assertThat(action.params()).hasSize(1); | |||
WebService.Param key = action.param("key"); |
@@ -0,0 +1,72 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.permission.ws; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class PermissionsWsTest { | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
tester = new WsTester(new PermissionsWs()); | |||
} | |||
@Test | |||
public void define_controller() throws Exception { | |||
WebService.Controller controller = tester.controller("api/permissions"); | |||
assertThat(controller).isNotNull(); | |||
assertThat(controller.description()).isNotEmpty(); | |||
assertThat(controller.since()).isEqualTo("3.7"); | |||
assertThat(controller.actions()).hasSize(2); | |||
} | |||
@Test | |||
public void define_add_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/permissions"); | |||
WebService.Action action = controller.action("add"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.INSTANCE.getClass()); | |||
assertThat(action.params()).hasSize(4); | |||
WebService.Param permission = action.param("permission"); | |||
assertThat(permission).isNotNull(); | |||
assertThat(permission.possibleValues()).hasSize(9); | |||
} | |||
@Test | |||
public void define_remove_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/permissions"); | |||
WebService.Action action = controller.action("remove"); | |||
assertThat(action).isNotNull(); | |||
assertThat(action.handler()).isInstanceOf(RailsHandler.INSTANCE.getClass()); | |||
assertThat(action.params()).hasSize(4); | |||
} | |||
} |
@@ -25,15 +25,15 @@ import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.server.ws.WsTester; | |||
import org.sonar.server.qualityprofile.QProfileBackup; | |||
import org.sonar.server.qualityprofile.QProfileResult; | |||
import org.sonar.server.ws.WsTester; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class QProfileBackupWsHandlerTest { | |||
public class QProfileRestoreDefaultActionTest { | |||
@Mock | |||
QProfileBackup qProfileBackup; | |||
@@ -42,7 +42,7 @@ public class QProfileBackupWsHandlerTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
tester = new WsTester(new QProfilesWs(new QProfileBackupWsHandler(qProfileBackup))); | |||
tester = new WsTester(new QProfilesWs(new QProfileRestoreDefaultAction(qProfileBackup))); | |||
} | |||
@Test |
@@ -23,40 +23,92 @@ package org.sonar.server.qualityprofile.ws; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.api.server.ws.RailsHandler; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.server.qualityprofile.QProfileBackup; | |||
import org.sonar.server.ws.WsTester; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class QProfilesWsTest { | |||
@Mock | |||
QProfileBackupWsHandler qProfileBackupWsHandler; | |||
WsTester tester; | |||
@Before | |||
public void setUp() { | |||
tester = new WsTester(new QProfilesWs(qProfileBackupWsHandler)); | |||
tester = new WsTester(new QProfilesWs(new QProfileRestoreDefaultAction(mock(QProfileBackup.class)))); | |||
} | |||
@Test | |||
public void define_ws() throws Exception { | |||
public void define_controller() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
assertThat(controller).isNotNull(); | |||
assertThat(controller.path()).isEqualTo("api/qprofiles"); | |||
assertThat(controller.description()).isNotEmpty(); | |||
assertThat(controller.actions()).hasSize(1); | |||
assertThat(controller.actions()).hasSize(6); | |||
} | |||
@Test | |||
public void define_restore_default_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("restore_default"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isSameAs(qProfileBackupWsHandler); | |||
assertThat(restoreProfiles.since()).isEqualTo("4.4"); | |||
assertThat(restoreProfiles.isPost()).isFalse(); | |||
assertThat(restoreProfiles.isInternal()).isFalse(); | |||
assertThat(restoreProfiles.handler()).isNotNull(); | |||
assertThat(restoreProfiles.params()).hasSize(1); | |||
} | |||
@Test | |||
public void define_list_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("list"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(restoreProfiles.responseExampleAsString()).isNotEmpty(); | |||
assertThat(restoreProfiles.params()).hasSize(2); | |||
} | |||
@Test | |||
public void define_backup_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("backup"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(restoreProfiles.params()).hasSize(2); | |||
} | |||
@Test | |||
public void define_restore_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("restore"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(restoreProfiles.params()).hasSize(1); | |||
} | |||
@Test | |||
public void define_destroy_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("destroy"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(restoreProfiles.params()).hasSize(2); | |||
} | |||
@Test | |||
public void define_set_as_default_action() throws Exception { | |||
WebService.Controller controller = tester.controller("api/qprofiles"); | |||
WebService.Action restoreProfiles = controller.action("set_as_default"); | |||
assertThat(restoreProfiles).isNotNull(); | |||
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class); | |||
assertThat(restoreProfiles.params()).hasSize(2); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.server.tester; | |||
import javax.annotation.ParametersAreNonnullByDefault; |