diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java index 7f199abe4..eb4d1ba11 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java @@ -321,7 +321,8 @@ private void rewriteFbrManifestation(Document document) { expressionEli.getVersion(), expressionEli.getLanguage(), verkuendungsDate, - expressionEli.getSubtype() + expressionEli.getSubtype(), + "xml" ); fRBRManifestationThis.setAttribute(VALUE, manifestationEli.toString()); fRBRManifestationUri.setAttribute(VALUE, manifestationEli.toString()); diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormService.java index d1fd84167..0e8783842 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormService.java @@ -53,7 +53,11 @@ public CreateNewExpressionResult createNewExpression(Norm norm, LocalDate date) date, newExpression.getExpressionEli().getLanguage() ); - var newManifestationEli = ManifestationEli.fromExpressionEli(newExpressionEli, LocalDate.now()); + var newManifestationEli = ManifestationEli.fromExpressionEli( + newExpressionEli, + LocalDate.now(), + "xml" + ); setNewExpressionMetadata(newExpression, newExpressionEli); setNewManifestationMetadata(newExpression, newManifestationEli); @@ -85,7 +89,8 @@ public Norm createNewManifestation(Norm norm, LocalDate pointInTimeManifestation var newManifestation = new Norm(norm); var newManifestationEli = ManifestationEli.fromExpressionEli( newManifestation.getExpressionEli(), - pointInTimeManifestation + pointInTimeManifestation, + "xml" ); setNewManifestationMetadata(newManifestation, newManifestationEli); diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEli.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEli.java index 7837e7b80..14392a063 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEli.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEli.java @@ -15,7 +15,7 @@ * European legislation identifier on manifestation level * *

This class can be used to extract the eli from a path that includes a section like - * "/eli/bund/{agent}/{year}/{naturalIdentifier}/{pointInTime}/{version}/{language}/{pointInTimeManifestation}/{subtype}.xml". + * "/eli/bund/{agent}/{year}/{naturalIdentifier}/{pointInTime}/{version}/{language}/{pointInTimeManifestation}/{subtype}.{fileExtension}". */ @Getter @Setter @@ -31,6 +31,7 @@ public final class ManifestationEli implements Eli { private String language; private LocalDate pointInTimeManifestation; private String subtype; + private String format = "xml"; public ManifestationEli( String agent, @@ -39,9 +40,10 @@ public ManifestationEli( LocalDate pointInTime, Integer version, String language, - String subtype + String subtype, + String format ) { - this(agent, year, naturalIdentifier, pointInTime, version, language, null, subtype); + this(agent, year, naturalIdentifier, pointInTime, version, language, null, subtype, format); } /** @@ -56,18 +58,19 @@ public boolean hasPointInTimeManifestation() { @Override public String toString() { if (!hasPointInTimeManifestation()) { - return "eli/bund/%s/%s/%s/%s/%d/%s/%s.xml".formatted( + return "eli/bund/%s/%s/%s/%s/%d/%s/%s.%s".formatted( getAgent(), getYear(), getNaturalIdentifier(), getPointInTime().format(DateTimeFormatter.ISO_LOCAL_DATE), getVersion(), getLanguage(), - getSubtype() + getSubtype(), + getFormat() ); } - return "eli/bund/%s/%s/%s/%s/%d/%s/%s/%s.xml".formatted( + return "eli/bund/%s/%s/%s/%s/%d/%s/%s/%s.%s".formatted( getAgent(), getYear(), getNaturalIdentifier(), @@ -75,7 +78,8 @@ public String toString() { getVersion(), getLanguage(), getPointInTimeManifestation().format(DateTimeFormatter.ISO_LOCAL_DATE), - getSubtype() + getSubtype(), + getFormat() ); } @@ -106,7 +110,8 @@ public ManifestationEli withoutPointInTimeManifestation() { getPointInTime(), getVersion(), getLanguage(), - getSubtype() + getSubtype(), + getFormat() ); } @@ -145,7 +150,7 @@ public WorkEli asWorkEli() { public static ManifestationEli fromString(String manifestationEli) { Matcher matcher = Pattern .compile( - "eli/bund/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)(/(?[^/.]+))?/(?[^/.]+)\\.xml" + "eli/bund/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)/(?[^/]+)(/(?[^/.]+))?/(?[^/.]+)\\.(?[^/.]+)" ) .matcher(manifestationEli); @@ -166,7 +171,8 @@ public static ManifestationEli fromString(String manifestationEli) { matcher.group("pointInTimeManifestation"), DateTimeFormatter.ISO_LOCAL_DATE ), - matcher.group("subtype") + matcher.group("subtype"), + matcher.group("format") ); } @@ -175,11 +181,13 @@ public static ManifestationEli fromString(String manifestationEli) { * * @param expressionEli the expression eli to use as a base * @param pointInTimeManifestation the date the manifestation was created + * @param format the file extension used by this manifestation * @return the eli */ public static ManifestationEli fromExpressionEli( ExpressionEli expressionEli, - LocalDate pointInTimeManifestation + LocalDate pointInTimeManifestation, + String format ) { return new ManifestationEli( expressionEli.getAgent(), @@ -189,7 +197,8 @@ public static ManifestationEli fromExpressionEli( expressionEli.getVersion(), expressionEli.getLanguage(), pointInTimeManifestation, - expressionEli.getSubtype() + expressionEli.getSubtype(), + format ); } diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEliTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEliTest.java index a62536b2a..c743e9a93 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEliTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/eli/ManifestationEliTest.java @@ -87,6 +87,7 @@ void itShouldBeCorrectWithPointInTimeManifestation() { assertThat(eli.getLanguage()).isEqualTo("deu"); assertThat(eli.getPointInTimeManifestation()).isEqualTo("2021-03-03"); assertThat(eli.getSubtype()).isEqualTo("regelungstext-1"); + assertThat(eli.getFormat()).isEqualTo("xml"); } @Test @@ -102,6 +103,7 @@ void itShouldBeCorrectWithoutPointInTimeManifestation() { assertThat(eli.getLanguage()).isEqualTo("deu"); assertThat(eli.getPointInTimeManifestation()).isNull(); assertThat(eli.getSubtype()).isEqualTo("regelungstext-1"); + assertThat(eli.getFormat()).isEqualTo("xml"); } } @@ -150,7 +152,8 @@ class fromExpressionEli { void itShouldCreateFromExpressionEliAndPointInTimeManifestation() { var eli = ManifestationEli.fromExpressionEli( ExpressionEli.fromString("eli/bund/bgbl-1/2021/s4/2021-03-01/1/deu/regelungstext-1"), - LocalDate.parse("2022-01-01") + LocalDate.parse("2022-01-01"), + "xml" ); assertThat(eli) .hasToString("eli/bund/bgbl-1/2021/s4/2021-03-01/1/deu/2022-01-01/regelungstext-1.xml");