-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: monitoring endpoint and self-check refactorings
- Loading branch information
Dominick Leppich
committed
Oct 25, 2024
1 parent
bc11fa6
commit e979ddc
Showing
12 changed files
with
238 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
module-core/src/main/java/io/goobi/vocabulary/api/MonitoringController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.goobi.vocabulary.api; | ||
|
||
import io.goobi.vocabulary.maintenance.MonitoringResult; | ||
import io.goobi.vocabulary.service.manager.MaintenanceManager; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/api/v1") | ||
public class MonitoringController { | ||
private final MaintenanceManager maintenanceManager; | ||
|
||
public MonitoringController(MaintenanceManager maintenanceManager) { | ||
this.maintenanceManager = maintenanceManager; | ||
} | ||
|
||
@GetMapping("/monitoring") | ||
public MonitoringResult monitoring() { | ||
return maintenanceManager.getMonitoringResult(); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
module-core/src/main/java/io/goobi/vocabulary/maintenance/FlywayInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
import java.util.Date; | ||
|
||
public record FlywayInformation(String schemaVersion, String description, Date date, int executionTime, boolean success) { | ||
} |
36 changes: 36 additions & 0 deletions
36
module-core/src/main/java/io/goobi/vocabulary/maintenance/ManifestReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
import lombok.Getter; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
import java.util.jar.Attributes; | ||
import java.util.jar.Manifest; | ||
|
||
@Getter | ||
@Service | ||
public class ManifestReader { | ||
private final Manifest manifest; | ||
|
||
private final String revision; | ||
private final String version; | ||
private final String buildDate; | ||
|
||
public ManifestReader() throws IllegalArgumentException, IOException { | ||
manifest = new Manifest(getClass().getResourceAsStream("/META-INF/MANIFEST.MF")); | ||
Attributes mainAttributes = manifest.getMainAttributes(); | ||
revision = getOptionalValue(mainAttributes, "Revision").orElse("unknown"); | ||
version = getOptionalValue(mainAttributes, "Version").orElse("unknown"); | ||
buildDate = getOptionalValue(mainAttributes, "Build-Date").orElse("unknown"); | ||
} | ||
|
||
private Optional<String> getOptionalValue(Attributes attributes, String attributeName) throws IllegalArgumentException { | ||
String result = attributes.getValue(attributeName); | ||
if (StringUtils.isBlank(result)) { | ||
result = null; | ||
} | ||
return Optional.ofNullable(result); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
module-core/src/main/java/io/goobi/vocabulary/maintenance/MonitoringResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
import io.goobi.vocabulary.maintenance.selfcheck.SelfCheckResult; | ||
|
||
public record MonitoringResult(MonitoringState monitoring, VersionsCollection versions, FlywayInformation flyway, SelfCheckResult selfCheck) { | ||
} |
4 changes: 4 additions & 0 deletions
4
module-core/src/main/java/io/goobi/vocabulary/maintenance/MonitoringState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
public record MonitoringState(String database, String selfCheck) { | ||
} |
4 changes: 4 additions & 0 deletions
4
module-core/src/main/java/io/goobi/vocabulary/maintenance/VersionInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
public record VersionInformation(String version, String hash) { | ||
} |
4 changes: 4 additions & 0 deletions
4
module-core/src/main/java/io/goobi/vocabulary/maintenance/VersionsCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.goobi.vocabulary.maintenance; | ||
|
||
public record VersionsCollection(VersionInformation core) { | ||
} |
9 changes: 9 additions & 0 deletions
9
module-core/src/main/java/io/goobi/vocabulary/maintenance/selfcheck/SelfCheckResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.goobi.vocabulary.maintenance.selfcheck; | ||
|
||
import java.util.Date; | ||
|
||
public record SelfCheckResult(Date date, ValidationResult types, ValidationResult vocabularies, ValidationResult schemas, ValidationResult records) { | ||
public boolean success() { | ||
return types.errors().isEmpty() && vocabularies.errors().isEmpty() && schemas.errors().isEmpty() && records.errors().isEmpty(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
module-core/src/main/java/io/goobi/vocabulary/maintenance/selfcheck/ValidationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.goobi.vocabulary.maintenance.selfcheck; | ||
|
||
import java.util.List; | ||
|
||
public record ValidationResult(List<String> errors) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters