import org.sonar.api.utils.text.JsonWriter;
import org.sonar.api.web.page.Page;
import org.sonar.core.config.WebConstants;
-import org.sonar.core.permission.GlobalPermissions;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.user.UserSession;
@Override
public void handle(Request request, Response response) throws Exception {
- boolean isAdmin = userSession.hasPermission(GlobalPermissions.SYSTEM_ADMIN);
+ boolean isRoot = userSession.isRoot();
JsonWriter json = response.newJsonWriter().beginObject();
- json.prop("showUpdateCenter", isAdmin && settings.getBoolean(WebConstants.SONAR_UPDATECENTER_ACTIVATE));
+ json.prop("showUpdateCenter", isRoot && settings.getBoolean(WebConstants.SONAR_UPDATECENTER_ACTIVATE));
json.name("extensions").beginArray();
- if (isAdmin) {
+ if (isRoot) {
for (Page page : pageRepository.getGlobalPages(true)) {
json.beginObject()
.prop("key", page.getKey())
import org.sonar.api.web.page.Page;
import org.sonar.api.web.page.PageDefinition;
import org.sonar.core.config.WebConstants;
-import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.platform.PluginRepository;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ui.PageRepository;
@Test
public void empty() throws Exception {
init();
- userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+ userSessionRule.logIn().setRoot();
executeAndVerify("empty.json");
}
@Test
public void with_pages() throws Exception {
init(createPages());
- userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+ userSessionRule.logIn().setRoot();
executeAndVerify("with_pages.json");
}
public void with_update_center() throws Exception {
init();
settings.setProperty(WebConstants.SONAR_UPDATECENTER_ACTIVATE, true);
- userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+ userSessionRule.logIn().setRoot();
executeAndVerify("with_update_center.json");
}
@Test
- public void with_views_and_update_center_but_not_admin() throws Exception {
+ public void with_views_and_update_center_but_not_root_administrator() throws Exception {
init(createPages());
settings.setProperty(WebConstants.SONAR_UPDATECENTER_ACTIVATE, true);
+ userSessionRule.logIn().setNonRoot();
executeAndVerify("empty.json");
}