key = UpdateCenterClient.ACTIVATION_PROPERTY,
defaultValue = "true",
name = "Enable Update Center",
+ category = "Update Center",
project = false,
// hidden from UI
global = false,
- category = "Update Center",
type = PropertyType.BOOLEAN),
@Property(
key = UpdateCenterClient.URL_PROPERTY,
defaultValue = "http://update.sonarsource.org/update-center.properties",
name = "Update Center URL",
+ category = "Update Center",
project = false,
// hidden from UI
- global = false,
- category = "Update Center")
+ global = false)
})
public class UpdateCenterClient {
private final ComponentFinder componentFinder;
public ComponentNavigationAction(DbClient dbClient, Views views, I18n i18n, ResourceTypes resourceTypes, UserSession userSession,
- ComponentFinder componentFinder) {
+ ComponentFinder componentFinder) {
this.dbClient = dbClient;
this.activeDashboardDao = dbClient.activeDashboardDao();
this.views = views;
if (dashboards.isEmpty()) {
dashboards = activeDashboardDao.selectProjectDashboardsForUserLogin(session, ANONYMOUS);
}
- writeDashboards(json, component, dashboards, userSession.locale());
+ writeDashboards(json, dashboards);
if (snapshot != null) {
json.prop("version", snapshot.getVersion())
.prop("snapshotDate", DateUtils.formatDateTime(new Date(snapshot.getCreatedAt())));
- String[] availableMeasures = dbClient.measureDao().selectMetricKeysForSnapshot(session, snapshot.getId()).toArray(new String[0]);
- List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE, component.scope(), component.qualifier(), component.language(), availableMeasures);
+ List<String> availableMeasures = dbClient.measureDao().selectMetricKeysForSnapshot(session, snapshot.getId());
+ List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE, component.scope(), component.qualifier(), component.language(),
+ availableMeasures.toArray(new String[availableMeasures.size()]));
writeExtensions(json, component, pages, userSession.locale());
}
}
}
private String getPageUrl(ViewProxy<Page> page, ComponentDto component) {
- String result = null;
+ String result;
String componentKey = encodeComponentKey(component);
if (page.isController()) {
result = String.format("%s?id=%s", page.getId(), componentKey);
return componentKey;
}
- private void writeDashboards(JsonWriter json, ComponentDto component, List<DashboardDto> dashboards, Locale locale) {
+ private void writeDashboards(JsonWriter json, List<DashboardDto> dashboards) {
json.name("dashboards").beginArray();
for (DashboardDto dashboard : dashboards) {
json.beginObject()
Locale locale = userSession.locale();
json.name("configuration").beginObject();
- writeConfigPageAccess(json, isAdmin, component, userSession);
+ writeConfigPageAccess(json, isAdmin, component);
if (isAdmin) {
json.name("extensions").beginArray();
json.endObject();
}
- private void writeConfigPageAccess(JsonWriter json, boolean isAdmin, ComponentDto component, UserSession userSession) {
+ private void writeConfigPageAccess(JsonWriter json, boolean isAdmin, ComponentDto component) {
boolean isProject = Qualifiers.PROJECT.equals(component.qualifier());
json.prop("showSettings", isAdmin && componentTypeHasProperty(component, PROPERTY_CONFIGURABLE));
private boolean componentTypeHasProperty(ComponentDto component, String resourceTypeProperty) {
ResourceType resourceType = resourceTypes.get(component.qualifier());
- if (resourceType != null) {
- return resourceType.getBooleanProperty(resourceTypeProperty);
- }
- return false;
+ return resourceType != null && resourceType.getBooleanProperty(resourceTypeProperty);
}
private void writePage(JsonWriter json, String url, String name) {