"permission", "admin");
new SeleneseTest(
- Selenese.builder().setHtmlTestsInClasspath("project-deletion", "/administration/suite/ProjectAdministrationTest/project-deletion/project-deletion.html").build()
- ).runOn(orchestrator);
+ Selenese.builder().setHtmlTestsInClasspath("project-deletion", "/administration/suite/ProjectAdministrationTest/project-deletion/project-deletion.html").build())
+ .runOn(orchestrator);
} finally {
wsClient.userClient().deactivate(projectAdminUser);
}
import org.sonar.server.qualityprofile.ws.ExportersAction;
import org.sonar.server.qualityprofile.ws.ImportersAction;
import org.sonar.server.qualityprofile.ws.InheritanceAction;
+import org.sonar.server.qualityprofile.ws.OldRestoreAction;
+import org.sonar.server.qualityprofile.ws.ProfilesWs;
import org.sonar.server.qualityprofile.ws.ProjectAssociationActions;
import org.sonar.server.qualityprofile.ws.ProjectsAction;
import org.sonar.server.qualityprofile.ws.QProfilesWs;
IndexDefinitions.class,
IndexCreator.class,
- // Activity
+ // Activity
ActivityService.class,
ActivityIndexDefinition.class,
ActivityIndexer.class,
ActivityIndex.class,
- // batch
+ // batch
BatchWsModule.class,
- // Dashboard
+ // Dashboard
DashboardsWs.class,
org.sonar.server.dashboard.ws.ShowAction.class,
ProjectDefaultDashboard.class,
ProjectIssueFilterWidget.class,
IssueTagCloudWidget.class,
- // update center
+ // update center
UpdateCenterClient.class,
UpdateCenterMatrixFactory.class,
UpdateCenterWs.class,
- // quality profile
+ // quality profile
XMLProfileParser.class,
XMLProfileSerializer.class,
AnnotationProfileParser.class,
ExportAction.class,
ExportersAction.class,
QProfilesWs.class,
+ ProfilesWs.class,
+ OldRestoreAction.class,
RuleActivationActions.class,
BulkRuleActivationActions.class,
ProjectAssociationActions.class,
QProfileReset.class,
RubyQProfileActivityService.class,
- // rule
+ // rule
AnnotationRuleParser.class,
XMLRuleParser.class,
DefaultRuleFinder.class,
RepositoriesAction.class,
org.sonar.server.rule.ws.AppAction.class,
- // languages
+ // languages
Languages.class,
LanguageWs.class,
org.sonar.server.language.ws.ListAction.class,
- // activity
+ // activity
ActivitiesWs.class,
org.sonar.server.activity.ws.SearchAction.class,
ActivityMapping.class,
- // measure
+ // measure
MeasureFilterFactory.class,
MeasureFilterExecutor.class,
MeasureFilterEngine.class,
DefaultMetricFinder.class,
TimeMachineWs.class,
- // quality gates
+ // quality gates
QualityGateDao.class,
QualityGateConditionDao.class,
QualityGates.class,
ProjectQgateAssociationDao.class,
QgateProjectFinder.class,
- org.sonar.server.qualitygate.ws.ListAction.class,
+ org.sonar.server.qualitygate.ws.ListAction.class,
org.sonar.server.qualitygate.ws.SearchAction.class,
org.sonar.server.qualitygate.ws.ShowAction.class,
org.sonar.server.qualitygate.ws.CreateAction.class,
org.sonar.server.qualitygate.ws.AppAction.class,
QGatesWs.class,
- // web services
+ // web services
WebServiceEngine.class,
ListingWs.class,
- // localization
+ // localization
L10nWs.class,
- // authentication
+ // authentication
AuthenticationWs.class,
- // users
+ // users
SecurityRealmFactory.class,
DeprecatedUserFinder.class,
NewUserNotifier.class,
UserIndex.class,
UserUpdater.class,
- // groups
+ // groups
GroupMembershipService.class,
GroupMembershipFinder.class,
UserGroupsModule.class,
- // permissions
+ // permissions
PermissionRepository.class,
PermissionService.class,
PermissionUpdater.class,
PermissionFinder.class,
PermissionsWsModule.class,
- // components
+ // components
ProjectsWsModule.class,
ComponentsWsModule.class,
DefaultComponentFinder.class,
NewAlerts.newMetadata(),
ComponentCleanerService.class,
- // views
+ // views
ViewIndexDefinition.class,
ViewIndexer.class,
ViewIndex.class,
- // issues
+ // issues
IssueIndexDefinition.class,
IssueIndexer.class,
IssueAuthorizationIndexer.class,
EmailNotificationChannel.class,
AlertsEmailTemplate.class,
- IssueFilterWsModule.class,
+ IssueFilterWsModule.class,
- // action plan
+ // action plan
ActionPlanWs.class,
ActionPlanService.class,
- // issues actions
+ // issues actions
AssignAction.class,
PlanAction.class,
SetSeverityAction.class,
AddTagsAction.class,
RemoveTagsAction.class,
- // technical debt
+ // technical debt
DebtModelService.class,
DebtModelOperations.class,
DebtModelLookup.class,
DebtRulesXMLImporter.class,
DebtCharacteristicsXMLImporter.class,
- // source
+ // source
HtmlSourceDecorator.class,
SourceService.class,
SourcesWs.class,
IndexAction.class,
ScmAction.class,
- // Duplications
+ // Duplications
DuplicationsParser.class,
DuplicationsWs.class,
DuplicationsJsonWriter.class,
org.sonar.server.duplication.ws.ShowAction.class,
- // text
+ // text
MacroInterpreter.class,
RubyTextService.class,
- // Notifications
+ // Notifications
EmailSettings.class,
NotificationService.class,
NotificationCenter.class,
DefaultNotificationManager.class,
- // Tests
+ // Tests
CoverageService.class,
TestsWs.class,
CoveredFilesAction.class,
TestIndex.class,
TestIndexer.class,
- // Properties
+ // Properties
PropertiesWs.class,
- TypeValidationModule.class,
+ TypeValidationModule.class,
- // System
+ // System
RestartAction.class,
InfoAction.class,
UpgradesAction.class,
MigrateDbAction.class,
DbMigrationStatusAction.class,
- // Plugins WS
+ // Plugins WS
PluginWSCommons.class,
PluginUpdateAggregator.class,
InstalledAction.class,
CancelAllAction.class,
PluginsWs.class,
- // Compute engine
+ // Compute engine
CeModule.class,
CeQueueModule.class,
CeTaskProcessorModule.class,
CeWsModule.class,
ReportProcessingModule.class,
- // Views plugin
+ // Views plugin
ViewsBootstrap.class,
ViewsStopper.class,
- // UI
+ // UI
GlobalNavigationAction.class,
SettingsNavigationAction.class,
ComponentNavigationAction.class,
--- /dev/null
+/*
+ * 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.qualityprofile.ws;
+
+import com.google.common.base.Preconditions;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.resources.Languages;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.db.qualityprofile.QualityProfileDto;
+import org.sonar.server.qualityprofile.BulkChangeResult;
+import org.sonar.server.qualityprofile.QProfileBackuper;
+import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.WsAction;
+
+@Deprecated
+/**
+ * @deprecated will be deleted once Orchestrator do not rely on this WS
+ * It is duplicated to enable
+ */
+public class OldRestoreAction implements WsAction {
+
+ private static final String PARAM_BACKUP = "backup";
+ private final QProfileBackuper backuper;
+ private final Languages languages;
+ private final UserSession userSession;
+
+ public OldRestoreAction(QProfileBackuper backuper, Languages languages, UserSession userSession) {
+ this.backuper = backuper;
+ this.languages = languages;
+ this.userSession = userSession;
+ }
+
+ @Override
+ public void define(WebService.NewController controller) {
+ controller.createAction("restore")
+ .setSince("5.2")
+ .setDescription("Restore a quality profile using an XML file. The restored profile name is taken from the backup file, "
+ + "so if a profile with the same name and language already exists, it will be overwritten.")
+ .setPost(true)
+ .setInternal(true)
+ .setHandler(this)
+ .createParam(PARAM_BACKUP)
+ .setDescription("A profile backup file in XML format, as generated by api/qualityprofiles/backup " +
+ "or the former api/profiles/backup.")
+ .setRequired(true);
+ }
+
+ @Override
+ public void handle(Request request, Response response) throws Exception {
+ userSession.checkLoggedIn().checkGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN);
+ InputStream backup = request.paramAsInputStream(PARAM_BACKUP);
+ InputStreamReader reader = null;
+
+ try {
+ Preconditions.checkArgument(backup != null, "A backup file must be provided");
+ reader = new InputStreamReader(backup, StandardCharsets.UTF_8);
+ BulkChangeResult result = backuper.restore(reader, null);
+ writeResponse(response.newJsonWriter(), result);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ IOUtils.closeQuietly(backup);
+ }
+ }
+
+ private void writeResponse(JsonWriter json, BulkChangeResult result) {
+ QualityProfileDto profile = result.profile();
+ if (profile != null) {
+ String language = profile.getLanguage();
+ json.beginObject().name("profile").beginObject()
+ .prop("key", profile.getKey())
+ .prop("name", profile.getName())
+ .prop("language", language)
+ .prop("languageName", languages.get(profile.getLanguage()).getName())
+ .prop("isDefault", false)
+ .prop("isInherited", false)
+ .endObject();
+ }
+ json.prop("ruleSuccesses", result.countSucceeded());
+ json.prop("ruleFailures", result.countFailed());
+ json.endObject().close();
+ }
+}
--- /dev/null
+/*
+ * 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.qualityprofile.ws;
+
+import org.sonar.api.server.ws.WebService;
+
+public class ProfilesWs implements WebService {
+
+ public static final String API_ENDPOINT = "api/profiles";
+
+ private final OldRestoreAction restoreAction;
+
+ public ProfilesWs(OldRestoreAction restoreAction) {
+ this.restoreAction = restoreAction;
+ }
+
+ @Override
+ public void define(Context context) {
+ NewController controller = context.createController(API_ENDPOINT)
+ .setDescription("Old Quality Profiles")
+ .setSince("4.4");
+
+ restoreAction.define(controller);
+ controller.done();
+ }
+}