Skip to content

Commit

Permalink
SHIBUI-2571
Browse files Browse the repository at this point in the history
Added database to output
  • Loading branch information
chasegawa committed Jun 2, 2023
1 parent e63884f commit bd12650
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -278,8 +279,9 @@ public String getBeaconCronValue(BeaconConfigurationRepository repo)
@Bean
public IBeaconDataService getBeaconDataService(@Value("${shibui.beacon.productName:ShibUi}") String productName, InfoEndpoint info, @Value("#{environment.TIERVERSION}") String tierVersion,
EntityDescriptorRepository entityDescriptorRepository, MetadataResolverRepository metadataResolverRepository, FilterRepository filterRepository,
GroupsRepository groupsRepository, RoleRepository roleRepository, BeaconConfigurationRepository beaconConfigurationRepository, UserService userService) {
BeaconDataServiceImpl result = new BeaconDataServiceImpl(productName, info, tierVersion, entityDescriptorRepository, metadataResolverRepository, filterRepository, groupsRepository, roleRepository, beaconConfigurationRepository, userService);
GroupsRepository groupsRepository, RoleRepository roleRepository, BeaconConfigurationRepository beaconConfigurationRepository,
UserService userService, HealthEndpoint healthEndpoint) {
BeaconDataServiceImpl result = new BeaconDataServiceImpl(productName, info, tierVersion, entityDescriptorRepository, metadataResolverRepository, filterRepository, groupsRepository, roleRepository, beaconConfigurationRepository, userService, healthEndpoint);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.internet2.tier.shibboleth.admin.ui.beacon.BeaconDetail;
import edu.internet2.tier.shibboleth.admin.ui.beacon.ShibuiDetail;
import edu.internet2.tier.shibboleth.admin.ui.service.beacon.BeaconDetail;
import edu.internet2.tier.shibboleth.admin.ui.service.beacon.ShibuiDetail;
import edu.internet2.tier.shibboleth.admin.ui.domain.BeaconConfiguration;
import edu.internet2.tier.shibboleth.admin.ui.repository.BeaconConfigurationRepository;
import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository;
Expand All @@ -14,16 +14,19 @@
import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.boot.actuate.info.InfoEndpoint;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class BeaconDataServiceImpl implements IBeaconDataService {
private ObjectMapper mapper;
private String productName;
private String tierVersion;
private String version;
private String db;

private EntityDescriptorRepository entityDescriptorRepository;
private MetadataResolverRepository metadataResolverRepository;
Expand All @@ -35,12 +38,15 @@ public class BeaconDataServiceImpl implements IBeaconDataService {

public BeaconDataServiceImpl(String productName, InfoEndpoint info, String tierVersion, EntityDescriptorRepository entityDescriptorRepository,
MetadataResolverRepository metadataResolverRepository, FilterRepository filterRepository, GroupsRepository groupsRepository,
RoleRepository roleRepository, BeaconConfigurationRepository beaconConfigurationRepository, UserService userService) {
RoleRepository roleRepository, BeaconConfigurationRepository beaconConfigurationRepository, UserService userService,
HealthEndpoint health) {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // skip any null values

this.productName = productName;
this.version = info.info().get("build") == null ? "unknown" : ((Map)info.info().get("build")).get("version").toString();
this.db = StringUtils.substringBetween(health.healthForPath("db").toString(), "database=", ",");

this.tierVersion = StringUtils.isBlank(tierVersion) ? "NA" : tierVersion;

this.entityDescriptorRepository = entityDescriptorRepository;
Expand Down Expand Up @@ -72,6 +78,7 @@ private ShibuiDetail getShibuiDetailData() {
.dailyLogins(userService.getDailyLoginCount())
.numberOfGroups((int) groupsRepository.count())
.numberOfRoles((int) roleRepository.count())
.db(this.db)
.build();
return detail;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.internet2.tier.shibboleth.admin.ui.beacon;
package edu.internet2.tier.shibboleth.admin.ui.service.beacon;

import lombok.Data;
import lombok.experimental.Accessors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.internet2.tier.shibboleth.admin.ui.beacon;
package edu.internet2.tier.shibboleth.admin.ui.service.beacon;

import lombok.Builder;
import lombok.Data;
Expand All @@ -9,6 +9,7 @@
@Builder
public class ShibuiDetail {
private List<String> authMechanisms;
private String db;
private int numberOfMetadataSources;
private int numberOfMetadataProviders;
private int numberOfFilters;
Expand Down

0 comments on commit bd12650

Please sign in to comment.