]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7917 Drop WS api/dashboards/show
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 26 Jul 2016 14:11:54 +0000 (16:11 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 28 Jul 2016 07:14:54 +0000 (09:14 +0200)
server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/resources/org/sonar/server/dashboard/ws/show-example.json [deleted file]

diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java
deleted file mode 100644 (file)
index 706d1a9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.dashboard.ws;
-
-import org.sonar.api.server.ws.WebService;
-
-public class DashboardsWs implements WebService {
-
-  private final DashboardsWsAction[] actions;
-
-  public DashboardsWs(DashboardsWsAction... actions) {
-    this.actions = actions;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context.createController("api/dashboards");
-    controller.setSince("5.0");
-    controller.setDescription("Manage dashboards and widgets.");
-
-    for (DashboardsWsAction action : actions) {
-      action.define(controller);
-    }
-    controller.done();
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWsAction.java
deleted file mode 100644 (file)
index 240ea2e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.dashboard.ws;
-
-import org.sonar.server.ws.WsAction;
-
-public interface DashboardsWsAction extends WsAction {
-
-  // Marker interface
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java
deleted file mode 100644 (file)
index 8de5860..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.dashboard.ws;
-
-import com.google.common.collect.ListMultimap;
-import java.util.Collection;
-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.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.dashboard.DashboardDto;
-import org.sonar.db.dashboard.WidgetDto;
-import org.sonar.db.dashboard.WidgetPropertyDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.user.UserSession;
-
-public class ShowAction implements DashboardsWsAction {
-
-  private static final String PARAM_KEY = "key";
-
-  private final DbClient dbClient;
-  private final UserSession userSession;
-
-  public ShowAction(DbClient dbClient, UserSession userSession) {
-    this.dbClient = dbClient;
-    this.userSession = userSession;
-  }
-
-  @Override
-  public void define(WebService.NewController newController) {
-    WebService.NewAction action = newController.createAction("show")
-      .setDescription("Get details of a dashboard (name, description, layout and widgets).")
-      .setInternal(true)
-      .setSince("5.0")
-      .setResponseExample(getClass().getResource("show-example.json"))
-      .setHandler(this);
-    action.createParam(PARAM_KEY)
-      .setDescription("Dashboard key")
-      .setExampleValue("12345")
-      .setRequired(true);
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    DbSession dbSession = dbClient.openSession(false);
-    try {
-      Integer userId = userSession.getUserId();
-      DashboardDto dashboard = dbClient.dashboardDao().selectAllowedByKey(dbSession, request.mandatoryParamAsLong(PARAM_KEY),
-        userId != null ? userId.longValue() : null);
-      if (dashboard == null) {
-        throw new NotFoundException();
-      }
-
-      JsonWriter json = response.newJsonWriter();
-      json.beginObject();
-      json.prop("key", dashboard.getKey());
-      json.prop("name", dashboard.getName());
-      json.prop("layout", dashboard.getColumnLayout());
-      json.prop("desc", dashboard.getDescription());
-      json.prop("global", dashboard.getGlobal());
-      json.prop("shared", dashboard.getShared());
-      if (dashboard.getUserId() != null) {
-        UserDto user = dbClient.userDao().selectUserById(dashboard.getUserId());
-        if (user != null) {
-          json.name("owner").beginObject();
-          // TODO to be shared and extracted from here
-          json.prop("login", user.getLogin());
-          json.prop("name", user.getName());
-          json.endObject();
-        }
-      }
-      // load widgets and related properties
-      json.name("widgets").beginArray();
-      Collection<WidgetDto> widgets = dbClient.widgetDao().findByDashboard(dbSession, dashboard.getKey());
-      ListMultimap<Long, WidgetPropertyDto> propertiesByWidget = WidgetPropertyDto.groupByWidgetId(
-        dbClient.widgetPropertyDao().selectByDashboard(dbSession, dashboard.getKey()));
-      for (WidgetDto widget : widgets) {
-        json.beginObject();
-        json.prop("id", widget.getId());
-        json.prop("key", widget.getWidgetKey());
-        json.prop("name", widget.getName());
-        json.prop("desc", widget.getDescription());
-        json.prop("col", widget.getColumnIndex());
-        json.prop("row", widget.getRowIndex());
-        json.prop("configured", widget.getConfigured());
-        json.prop("componentId", widget.getResourceId());
-        json.name("props").beginArray();
-        for (WidgetPropertyDto prop : propertiesByWidget.get(widget.getId())) {
-          json.beginObject();
-          json.prop("key", prop.getPropertyKey());
-          json.prop("val", prop.getTextValue());
-          json.endObject();
-        }
-        json.endArray().endObject();
-      }
-
-      json.endArray();
-      json.endObject();
-      json.close();
-    } finally {
-      dbSession.close();
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/package-info.java
deleted file mode 100644 (file)
index c47aaf0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.dashboard.ws;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
index 75620ab5bfb0cbd642a35f1ae699a6012cac5a11..fd273db83d65a2fe3dac7cd4b53c809b657d03f4 100644 (file)
@@ -79,7 +79,6 @@ import org.sonar.server.dashboard.widget.TimeMachineWidget;
 import org.sonar.server.dashboard.widget.TimelineWidget;
 import org.sonar.server.dashboard.widget.TreemapWidget;
 import org.sonar.server.dashboard.widget.WelcomeWidget;
-import org.sonar.server.dashboard.ws.DashboardsWs;
 import org.sonar.server.debt.DebtModelBackup;
 import org.sonar.server.debt.DebtModelPluginRepository;
 import org.sonar.server.debt.DebtModelService;
@@ -328,8 +327,6 @@ public class PlatformLevel4 extends PlatformLevel {
       BatchWsModule.class,
 
       // Dashboard
-      DashboardsWs.class,
-      org.sonar.server.dashboard.ws.ShowAction.class,
       GlobalDefaultDashboard.class,
       AlertsWidget.class,
       CoverageWidget.class,
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/ws/show-example.json b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/ws/show-example.json
deleted file mode 100644 (file)
index 2c63c08..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-}