Skip to content

Commit

Permalink
Version 3.7.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asgeir Nilsen committed Mar 18, 2021
1 parent effd9b4 commit 4871187
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Generated by fint-consumer `2.5.0-beta-1` from tag `v3.7.0` on package `organisasjon` and component `administrasjon`.

Based on fint-consumer-skeleton refs/tags/v1.5.1.
Based on fint-consumer-skeleton refs/tags/v1.6.0.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {

compile('io.micrometer:micrometer-registry-prometheus:latest.release')
compile('io.micrometer:micrometer-spring-legacy:latest.release')

testCompile('no.fint:fint-test-utils:0.0.5')
testCompile("cglib:cglib-nodep:${cglibVersion}")
testCompile("org.spockframework:spock-spring:${spockSpringVersion}")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.7.0
version=3.7.1
apiVersion=3.7.0
19 changes: 17 additions & 2 deletions src/main/java/no/fint/consumer/admin/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
Expand All @@ -47,14 +48,14 @@ public class AdminController {

@GetMapping("/health")
public ResponseEntity<Event<Health>> healthCheck(@RequestHeader(HeaderConstants.ORG_ID) String orgId,
@RequestHeader(HeaderConstants.CLIENT) String client) {
@RequestHeader(HeaderConstants.CLIENT) String client) {
log.debug("Health check on {} requested by {} ...", orgId, client);
Event<Health> event = new Event<>(orgId, Constants.COMPONENT, DefaultActions.HEALTH, client);
event.addData(new Health(Constants.COMPONENT_CONSUMER, HealthStatus.SENT_FROM_CONSUMER_TO_PROVIDER));

final Optional<Event<Health>> response = consumerEventUtil.healthCheck(event);

return response.map(health -> {
return response.map(health -> {
log.debug("Health check response: {}", health.getData());
health.addData(new Health(Constants.COMPONENT_CONSUMER, HealthStatus.RECEIVED_IN_CONSUMER_FROM_PROVIDER));
return ResponseEntity.ok(health);
Expand Down Expand Up @@ -90,6 +91,20 @@ public Map<String, Integer> getCaches() {
k -> cacheManager.getCache(k).map(Cache::size).orElse(0)));
}

@GetMapping("/cache/status")
public Map<String, Map<String, CacheEntry>> getCacheStatus() {
return cacheManager
.getKeys()
.stream()
.map(s -> StringUtils.split(s, ':'))
.collect(
Collectors.groupingBy(s -> s[2],
Collectors.toMap(s -> s[3],
s -> cacheManager.getCache(String.join(":", s))
.map(c -> new CacheEntry(new Date(c.getLastUpdated()), c.size()))
.orElse(new CacheEntry(null, null)))));
}

@PostMapping({"/cache/rebuild", "/cache/rebuild/{model}"})
public void rebuildCache(
@RequestHeader(name = HeaderConstants.ORG_ID) String orgid,
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/no/fint/consumer/admin/CacheEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package no.fint.consumer.admin;

import lombok.Data;

import java.util.Date;

@Data
public class CacheEntry {
private final Date lastUpdated;
private final Integer size;
}
3 changes: 2 additions & 1 deletion src/main/java/no/fint/consumer/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.fint.consumer.config;


import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -23,7 +24,7 @@ public class Config {

@PostConstruct
public void init() {
objectMapper.setDateFormat(new ISO8601DateFormat());
objectMapper.setDateFormat(new ISO8601DateFormat()).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}

@Qualifier("linkMapper")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/no/fint/consumer/status/StatusCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public <T extends FintLinks> ResponseEntity handleStatusRequest(String id, Strin
if (event.getOperation() == Operation.VALIDATE) {
fintAuditService.audit(event, Status.SENT_TO_CLIENT);
return ResponseEntity.ok(event.getResponse());
} else if (event.getOperation() == Operation.DELETE) {
fintAuditService.audit(event, Status.SENT_TO_CLIENT);
return ResponseEntity.noContent().build();
}
result = objectMapper.convertValue(event.getData().get(0), valueType);
URI location = UriComponentsBuilder.fromUriString(linker.getSelfHref(result)).build().toUri();
Expand Down

0 comments on commit 4871187

Please sign in to comment.