diff --git a/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java b/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java index ddb4a48e2c8b0270b9c3c4610fcfa4dd69ab067c..c8433b4e15a10cd3c20c5873d33e91af3fc82420 100644 --- a/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java +++ b/src/main/java/de/landsh/opendata/csw2dcat/CswInterface.java @@ -1,5 +1,6 @@ package de.landsh.opendata.csw2dcat; +import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.hc.client5.http.classic.methods.HttpPost; @@ -16,7 +17,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -45,11 +45,6 @@ public class CswInterface { private String[] typeInclude; private CloseableHttpClient httpClient = HttpClients.createMinimal(); private String dumpCswResponse = null; - - public void setVerboseLogging(String verboseLogging) { - this.verboseLogging = verboseLogging; - } - /** * Name of a directory. If set all incoming messages will be logged into files in this directory. */ @@ -75,6 +70,10 @@ public class CswInterface { typeInclude = settings.typeInclude; } + public void setVerboseLogging(String verboseLogging) { + this.verboseLogging = verboseLogging; + } + public void setTypeExclude(String[] typeExclude) { this.typeExclude = typeExclude; } @@ -193,7 +192,7 @@ public class CswInterface { fw.close(); } - if( verboseLogging != null) { + if (verboseLogging != null) { // Write the response into file final File dir = new File(verboseLogging); @@ -300,7 +299,7 @@ public class CswInterface { filter.append(" <ogc:PropertyIsEqualTo>" + " <ogc:PropertyName>operatesOn</ogc:PropertyName>" + " <ogc:Literal>") - .append(id) + .append(StringEscapeUtils.escapeXml11(id)) .append("</ogc:Literal>") .append(" </ogc:PropertyIsEqualTo>\n"); @@ -314,7 +313,7 @@ public class CswInterface { final String xmlRequest = "<csw:GetRecords xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:ogc=\"http://www.opengis.net/ogc\"\n" + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ows=\"http://www.opengis.net/ows\"\n" + - "xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\" "+ + "xmlns:apiso=\"http://www.opengis.net/cat/apiso/1.0\" " + "outputSchema=\"http://www.isotc211.org/2005/gmd\" outputFormat=\"application/xml\" version=\"2.0.2\" service=\"CSW\" resultType=\"results\"\n" + "maxRecords=\"999\" xsi:schemaLocation=\"http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd\">\n" + " <csw:Query typeNames=\"csw:Record\">\n" + diff --git a/src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java b/src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java index 84026a25a705621dec174cfa6f5fea642f1f9191..00bdc61e71a52c9a902eb148280651fe6dad6ebf 100644 --- a/src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java +++ b/src/main/java/de/landsh/opendata/csw2dcat/MDMetadata2Dataset.java @@ -797,7 +797,13 @@ public class MDMetadata2Dataset { // add coupled services if (cswInterface != null && searchId != null) { - final List<Element> services = cswInterface.findOperatesOn(searchId); + List<Element> services ; + try { + services = cswInterface.findOperatesOn(searchId); + } catch (Exception e) { + log.error("Error searching for coupled services of dataset {}: {}", id, e.getMessage()); + services = Collections.emptyList(); + } for (Element service : services) { try { for (Resource dist : convertServiceToDistributions(service)) {