Skip to content
Snippets Groups Projects
Commit be99b8f6 authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

fix check if dateTim is valid

parent c746eccb
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ import org.springframework.stereotype.Service; ...@@ -16,6 +16,9 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException.BadRequest; import org.springframework.web.client.HttpClientErrorException.BadRequest;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -108,6 +111,10 @@ public class MappingService { ...@@ -108,6 +111,10 @@ public class MappingService {
return distributionStrings; return distributionStrings;
} }
private static OffsetDateTime parseDateTimeLiteral(String literal) {
return OffsetDateTime.parse(literal, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}
public String write(String indentifier, String value) { public String write(String indentifier, String value) {
value = value.replaceAll("[\\r\\n]+", " ").replaceAll("\"", "\\\\\""); value = value.replaceAll("[\\r\\n]+", " ").replaceAll("\"", "\\\\\"");
String property = ""; String property = "";
...@@ -125,7 +132,17 @@ public class MappingService { ...@@ -125,7 +132,17 @@ public class MappingService {
break; break;
case "dct:issued": case "dct:issued":
case "dct:modified": case "dct:modified":
property += indentifier + " \"" + value + "\"^^xsd:dateTime;\n"; try {
OffsetDateTime offsetDateTime = parseDateTimeLiteral(value);
if (offsetDateTime.getYear() < 1000) {
break;
} else {
property += indentifier + " \"" + value + "\"^^xsd:dateTime;\n";
}
} catch (DateTimeParseException e) {
break;
}
break; break;
case "dct:publisher": case "dct:publisher":
property += indentifier + "[ a foaf:Agent; foaf:name \"" + value + "\"];\n"; property += indentifier + "[ a foaf:Agent; foaf:name \"" + value + "\"];\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment