aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-10-05 16:18:13 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-10-05 21:39:20 +0200
commit0ce77c4e398676668288ad4e065a1ff7a1e24cf1 (patch)
treecb53bcff5903a0426b3500ff145328e28a426e5a /server
parent59e1f8eca37d7a37e0837e437ab3e6eb38a7dfea (diff)
downloadsonarqube-0ce77c4e398676668288ad4e065a1ff7a1e24cf1.tar.gz
sonarqube-0ce77c4e398676668288ad4e065a1ff7a1e24cf1.zip
SONAR-6834 add property showBackgroundTasks to api/navigation/component
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java27
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java3
2 files changed, 18 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java
index d2122a37184..8482a3fa881 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java
@@ -129,18 +129,6 @@ public class ActivityWsAction implements CeWsAction {
}
}
- private void checkPermissions(CeActivityQuery query) {
- List<String> componentUuids = query.getComponentUuids();
- if (componentUuids != null && componentUuids.size() == 1) {
- if (!userSession.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN) &&
- !userSession.hasComponentUuidPermission(UserRole.ADMIN, componentUuids.get(0))) {
- throw new ForbiddenException("Requires administration permission");
- }
- } else {
- userSession.checkGlobalPermission(UserRole.ADMIN);
- }
- }
-
private CeActivityQuery buildQuery(DbSession dbSession, Request wsRequest) {
String componentUuid = wsRequest.param(PARAM_COMPONENT_UUID);
String componentQuery = wsRequest.param(PARAM_COMPONENT_QUERY);
@@ -179,6 +167,17 @@ public class ActivityWsAction implements CeWsAction {
}
}
+ private void checkPermissions(CeActivityQuery query) {
+ List<String> componentUuids = query.getComponentUuids();
+ if (componentUuids != null && componentUuids.size() == 1) {
+ if (!isAllowedOnComponentUuid(userSession, componentUuids.get(0))) {
+ throw new ForbiddenException("Requires administration permission");
+ }
+ } else {
+ userSession.checkGlobalPermission(UserRole.ADMIN);
+ }
+ }
+
private static RowBounds readMyBatisRowBounds(Request wsRequest) {
int pageIndex = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE);
int pageSize = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE);
@@ -189,4 +188,8 @@ public class ActivityWsAction implements CeWsAction {
private static Long toTime(@Nullable Date date) {
return date == null ? null : date.getTime();
}
+
+ public static boolean isAllowedOnComponentUuid(UserSession userSession, String componentUuid) {
+ return userSession.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN) || userSession.hasComponentUuidPermission(UserRole.ADMIN, componentUuid);
+ }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
index 4a92ec849cb..6fcfa27eb6a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
@@ -49,7 +49,9 @@ import org.sonar.db.dashboard.ActiveDashboardDao;
import org.sonar.db.dashboard.DashboardDto;
import org.sonar.db.property.PropertyDto;
import org.sonar.db.property.PropertyQuery;
+import org.sonar.server.activity.ws.ActivitiesWs;
import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.computation.ws.ActivityWsAction;
import org.sonar.server.ui.ViewProxy;
import org.sonar.server.ui.Views;
import org.sonar.server.user.UserSession;
@@ -138,6 +140,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
.prop("name", component.name())
.prop("isComparable", componentTypeHasProperty(component, PROPERTY_COMPARABLE))
.prop("canBeFavorite", userSession.isLoggedIn())
+ .prop("showBackgroundTasks", ActivityWsAction.isAllowedOnComponentUuid(userSession, component.uuid()))
.prop("isFavorite", isFavourite(session, component, userSession));
List<DashboardDto> dashboards = activeDashboardDao.selectProjectDashboardsForUserLogin(session, userSession.getLogin());