mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
Merge branch 'master' of https://projekte.kosit.org/kosit/validator
This commit is contained in:
commit
c9abbfdf0a
4 changed files with 57 additions and 33 deletions
4
NOTICE
4
NOTICE
|
|
@ -1,5 +1,5 @@
|
||||||
KoSIT Validator
|
KoSIT Validaor
|
||||||
Copyright 2017 Koordinierungsstelle für IT-Standards (KoSIT)
|
Copyright 2019 Koordinierungsstelle für IT-Standards
|
||||||
|
|
||||||
This product includes software developed by
|
This product includes software developed by
|
||||||
Koordinierungsstelle für IT-Standards (https://www.kosit.de/).
|
Koordinierungsstelle für IT-Standards (https://www.kosit.de/).
|
||||||
|
|
|
||||||
24
README.md
24
README.md
|
|
@ -67,7 +67,7 @@ Eine zu prüfende Datei durchläuft die folgenden Schritte
|
||||||
# Verwendung
|
# Verwendung
|
||||||
|
|
||||||
Das Prüftool steht in zwei Varianten zur Verfügung:
|
Das Prüftool steht in zwei Varianten zur Verfügung:
|
||||||
- als [Standalone-Version](#verwendung-als-anwendung), die von der Kommandozeile aus aufgerufen werden kann
|
- als [Standalone-Version](#verwendung-als-standalone-anwendung), die von der Kommandozeile aus aufgerufen werden kann
|
||||||
- als [Bibliothek](#verwendung-als-bibliothek), die in eigene Anwendungen integriert werden kann
|
- als [Bibliothek](#verwendung-als-bibliothek), die in eigene Anwendungen integriert werden kann
|
||||||
|
|
||||||
## Voraussetzungen
|
## Voraussetzungen
|
||||||
|
|
@ -168,6 +168,26 @@ erzeugen lässt. Die InputFactory erzeugt für jedes Eingabe-Objekt eine Prüfsu
|
||||||
verwendete Algorithmus ist über die `read`-Methoden der `InputFactory` definierbar. Standardmäßig wird _SHA-256_ des JDK
|
verwendete Algorithmus ist über die `read`-Methoden der `InputFactory` definierbar. Standardmäßig wird _SHA-256_ des JDK
|
||||||
verwendet
|
verwendet
|
||||||
|
|
||||||
|
## Verwendung des Daemon-Mode
|
||||||
|
Das Prüftool stellt auch eine HTTP-Schnittstelle bereit, über die die Funktionalität angesprochen werden kann. Dazu wird die Anwendung
|
||||||
|
im _Daemon-Mode_ gestartet:
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
java -jar validationtool-<version>-standalone.jar -s <scenario-config-file> -D
|
||||||
|
```
|
||||||
|
|
||||||
|
In der Default-Konfiguration stellt dieser Aufruf einen HTTP-Server unter _localhost_ und Port 8080 bereit.
|
||||||
|
|
||||||
|
Host und Port lassen sich anpassen:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
java -jar validationtool-<version>-standalone.jar -s <scenario-config-file> -D -H 192.168.1.x -P 8081
|
||||||
|
```
|
||||||
|
|
||||||
|
Im Daemon-Mode nimmt der HTTP-Server POST-Anfragen unter `/` entgegen, verarbeitet den darüber bereitgestellten Prüfling und gibt das Ergebnis-Dokument als Antwort zurück.
|
||||||
|
Zur Integration in Monitoring-Systeme wird eine Health-Check angeboten. Dieser ist über einen GET-Request unter `/health` erreichbar.
|
||||||
|
|
||||||
# Build-Anweisungen
|
# Build-Anweisungen
|
||||||
|
|
||||||
Das Projekt wird mit Apache Maven gebaut.
|
Das Projekt wird mit Apache Maven gebaut.
|
||||||
|
|
@ -226,7 +246,7 @@ Die Erstellung dieser Empfehlung kann *je Prüfszenario* konfiguriert werden, in
|
||||||
```
|
```
|
||||||
|
|
||||||
In diesem Beispiel werden die Fehlercodes `BR-15` (Teil der EN) und `BR-DE-3` (Teil der CIUS XRechnung) für den
|
In diesem Beispiel werden die Fehlercodes `BR-15` (Teil der EN) und `BR-DE-3` (Teil der CIUS XRechnung) für den
|
||||||
Bewertungsschritt von ihrem eigentlicher Rolle *error* auf *warning* geändert. Ein Dokument, welches eine oder
|
Bewertungsschritt von ihrer eigentlicher Rolle *error* auf *warning* geändert. Ein Dokument, welches eine oder
|
||||||
beide dieser Regeln verletzt (und ansonsten keine *error*-Meldungen erzeugt) erhielte damit abweichend vom
|
beide dieser Regeln verletzt (und ansonsten keine *error*-Meldungen erzeugt) erhielte damit abweichend vom
|
||||||
Standardverhalten die Bewertung *accept*.
|
Standardverhalten die Bewertung *accept*.
|
||||||
|
|
||||||
|
|
|
||||||
3
pom.xml
3
pom.xml
|
|
@ -95,6 +95,7 @@
|
||||||
<groupId>org.glassfish.jaxb</groupId>
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
<artifactId>jaxb-runtime</artifactId>
|
<artifactId>jaxb-runtime</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
|
|
@ -229,7 +230,7 @@
|
||||||
<descriptor>src/assembly/assembly-full.xml</descriptor>
|
<descriptor>src/assembly/assembly-full.xml</descriptor>
|
||||||
</descriptors>
|
</descriptors>
|
||||||
<attach>true</attach>
|
<attach>true</attach>
|
||||||
<appendAssemblyId>true</appendAssemblyId>
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
<outputDirectory>target/</outputDirectory>
|
<outputDirectory>target/</outputDirectory>
|
||||||
<workDirectory>target/assembly/full</workDirectory>
|
<workDirectory>target/assembly/full</workDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import de.kosit.validationtool.impl.tasks.CreateReportAction;
|
||||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||||
import de.kosit.validationtool.impl.tasks.ScenarioSelectionAction;
|
import de.kosit.validationtool.impl.tasks.ScenarioSelectionAction;
|
||||||
import de.kosit.validationtool.impl.tasks.SchemaValidationAction;
|
import de.kosit.validationtool.impl.tasks.SchemaValidationAction;
|
||||||
|
import de.kosit.validationtool.impl.tasks.SchematronValidationAction;
|
||||||
import de.kosit.validationtool.impl.tasks.ValidateReportInputAction;
|
import de.kosit.validationtool.impl.tasks.ValidateReportInputAction;
|
||||||
import de.kosit.validationtool.model.reportInput.CreateReportInput;
|
import de.kosit.validationtool.model.reportInput.CreateReportInput;
|
||||||
import de.kosit.validationtool.model.reportInput.DocumentIdentificationType;
|
import de.kosit.validationtool.model.reportInput.DocumentIdentificationType;
|
||||||
|
|
@ -56,40 +57,42 @@ public class DefaultCheck implements Check {
|
||||||
private static final String ENGINE_VERSION = "1.0.0";
|
private static final String ENGINE_VERSION = "1.0.0";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private ScenarioRepository repository;
|
private final ScenarioRepository repository;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private ContentRepository contentRepository;
|
private final ContentRepository contentRepository;
|
||||||
|
|
||||||
private ConversionService conversionService;
|
private final ConversionService conversionService;
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private List<CheckAction> checkSteps;
|
private final List<CheckAction> checkSteps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erzeugt eine neue Instanz mit der angegebenen Konfiguration.
|
* Erzeugt eine neue Instanz mit der angegebenen Konfiguration.
|
||||||
*
|
*
|
||||||
* @param configuration die Konfiguration
|
* @param configuration die Konfiguration
|
||||||
*/
|
*/
|
||||||
public DefaultCheck(CheckConfiguration configuration) {
|
public DefaultCheck(final CheckConfiguration configuration) {
|
||||||
Processor processor = ObjectFactory.createProcessor();
|
final Processor processor = ObjectFactory.createProcessor();
|
||||||
conversionService = new ConversionService();
|
this.conversionService = new ConversionService();
|
||||||
contentRepository = new ContentRepository(processor, configuration.getScenarioRepository());
|
this.contentRepository = new ContentRepository(processor, configuration.getScenarioRepository());
|
||||||
repository = new ScenarioRepository(processor, contentRepository);
|
this.repository = new ScenarioRepository(processor, this.contentRepository);
|
||||||
repository.initialize(configuration);
|
this.repository.initialize(configuration);
|
||||||
checkSteps = new ArrayList<>();
|
this.checkSteps = new ArrayList<>();
|
||||||
checkSteps.add(this::createDocumentIdentification);
|
this.checkSteps.add(DefaultCheck::createDocumentIdentification);
|
||||||
checkSteps.add(new DocumentParseAction());
|
this.checkSteps.add(new DocumentParseAction());
|
||||||
checkSteps.add(new ScenarioSelectionAction(repository));
|
this.checkSteps.add(new ScenarioSelectionAction(this.repository));
|
||||||
checkSteps.add(new SchemaValidationAction());
|
this.checkSteps.add(new SchemaValidationAction());
|
||||||
checkSteps.add(new ValidateReportInputAction(conversionService, contentRepository.getReportInputSchema()));
|
this.checkSteps.add(new SchematronValidationAction(configuration.getScenarioRepository()));
|
||||||
checkSteps.add(new CreateReportAction(processor, conversionService, repository, configuration.getScenarioRepository()));
|
this.checkSteps.add(new ValidateReportInputAction(this.conversionService, this.contentRepository.getReportInputSchema()));
|
||||||
|
this.checkSteps
|
||||||
|
.add(new CreateReportAction(processor, this.conversionService, this.repository, configuration.getScenarioRepository()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static CreateReportInput createReport() {
|
protected static CreateReportInput createReport() {
|
||||||
CreateReportInput type = new CreateReportInput();
|
final CreateReportInput type = new CreateReportInput();
|
||||||
EngineType e = new EngineType();
|
final EngineType e = new EngineType();
|
||||||
e.setName(ENGINE_NAME);
|
e.setName(ENGINE_NAME);
|
||||||
type.setEngine(e);
|
type.setEngine(e);
|
||||||
type.setTimestamp(ObjectFactory.createTimestamp());
|
type.setTimestamp(ObjectFactory.createTimestamp());
|
||||||
|
|
@ -98,16 +101,16 @@ public class DefaultCheck implements Check {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XdmNode checkInput(Input input) {
|
public XdmNode checkInput(final Input input) {
|
||||||
CheckAction.Bag t = new CheckAction.Bag(input, createReport());
|
final CheckAction.Bag t = new CheckAction.Bag(input, createReport());
|
||||||
return runCheckInternal(t);
|
return runCheckInternal(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected XdmNode runCheckInternal(CheckAction.Bag t) {
|
protected XdmNode runCheckInternal(final CheckAction.Bag t) {
|
||||||
long started = System.currentTimeMillis();
|
final long started = System.currentTimeMillis();
|
||||||
log.info("Checking content of {}", t.getInput().getName());
|
log.info("Checking content of {}", t.getInput().getName());
|
||||||
for (final CheckAction action : checkSteps) {
|
for (final CheckAction action : this.checkSteps) {
|
||||||
long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
if (!action.isSkipped(t)) {
|
if (!action.isSkipped(t)) {
|
||||||
action.check(t);
|
action.check(t);
|
||||||
}
|
}
|
||||||
|
|
@ -124,9 +127,9 @@ public class DefaultCheck implements Check {
|
||||||
return t.getReport();
|
return t.getReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createDocumentIdentification(CheckAction.Bag transporter) {
|
private static boolean createDocumentIdentification(final CheckAction.Bag transporter) {
|
||||||
DocumentIdentificationType i = new DocumentIdentificationType();
|
final DocumentIdentificationType i = new DocumentIdentificationType();
|
||||||
DocumentIdentificationType.DocumentHash h = new DocumentIdentificationType.DocumentHash();
|
final DocumentIdentificationType.DocumentHash h = new DocumentIdentificationType.DocumentHash();
|
||||||
h.setHashAlgorithm(transporter.getInput().getDigestAlgorithm());
|
h.setHashAlgorithm(transporter.getInput().getDigestAlgorithm());
|
||||||
h.setHashValue(transporter.getInput().getHashCode());
|
h.setHashValue(transporter.getInput().getHashCode());
|
||||||
i.setDocumentHash(h);
|
i.setDocumentHash(h);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue