|
37 | 37 | import java.time.ZonedDateTime; |
38 | 38 | import java.time.format.DateTimeFormatter; |
39 | 39 | import java.util.ArrayList; |
| 40 | +import java.util.Arrays; |
40 | 41 | import java.util.Date; |
41 | 42 | import java.util.List; |
42 | 43 | import java.util.regex.Matcher; |
@@ -131,8 +132,7 @@ public IRecords findRecords(int start, int max, Date from, Date to, String searc |
131 | 132 | HttpPost post = createRecordsPostRequest(capabilites.get_getRecordsPostURL(), requestBody); |
132 | 133 |
|
133 | 134 | HttpClientContext context = cred!=null && !cred.isEmpty()? createHttpClientContext(baseUrl, cred): null; |
134 | | - try (CloseableHttpResponse httpResponse = httpClient.execute(post,context); |
135 | | - InputStream responseInputStream = httpResponse.getEntity().getContent();) { |
| 135 | + try (CloseableHttpResponse httpResponse = httpClient.execute(post,context); InputStream responseInputStream = httpResponse.getEntity().getContent();) { |
136 | 136 | if (httpResponse.getStatusLine().getStatusCode()>=400) { |
137 | 137 | throw new HttpResponseException(httpResponse.getStatusLine().getStatusCode(), httpResponse.getStatusLine().getReasonPhrase()); |
138 | 138 | } |
@@ -167,16 +167,7 @@ public String readMetadata(String id) throws Exception { |
167 | 167 |
|
168 | 168 | // perform transformation |
169 | 169 | StringWriter writer = new StringWriter(); |
170 | | - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); |
171 | | - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
172 | | - builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); |
173 | | - builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); |
174 | | - builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
175 | | - builderFactory.setXIncludeAware(false); |
176 | | - builderFactory.setExpandEntityReferences(false); |
177 | | - DocumentBuilder builder = builderFactory.newDocumentBuilder(); |
178 | | - Document inputDoc = builder.parse(contentStream); |
179 | | - transformer.transform(new DOMSource(inputDoc), new StreamResult(writer)); |
| 170 | + transformer.transform(new StreamSource(contentStream), new StreamResult(writer)); |
180 | 171 |
|
181 | 172 | String intermediateResult = writer.toString(); |
182 | 173 |
|
@@ -316,32 +307,21 @@ private List<IRecord> readRecords(InputStream contentStream) throws IOException, |
316 | 307 |
|
317 | 308 | // perform transformation |
318 | 309 | StringWriter writer = new StringWriter(); |
319 | | - |
320 | | - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); |
321 | | - builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
322 | | - builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); |
323 | | - builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); |
324 | | - builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
325 | | - builderFactory.setXIncludeAware(false); |
326 | | - builderFactory.setExpandEntityReferences(false); |
327 | | - DocumentBuilder builder = builderFactory.newDocumentBuilder(); |
328 | | - Document inputDoc = builder.parse(contentStream); |
329 | | - |
330 | | - transformer.transform(new DOMSource(inputDoc), new StreamResult(writer)); |
| 310 | + transformer.transform(new StreamSource(contentStream), new StreamResult(writer)); |
331 | 311 |
|
332 | 312 | LOG.trace(String.format("Received records:\n%s", writer.toString())); |
333 | 313 |
|
334 | 314 | try (ByteArrayInputStream transformedContentStream = new ByteArrayInputStream(writer.toString().getBytes("UTF-8"))) { |
335 | 315 |
|
336 | 316 | // create internal request DOM |
337 | | -// DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); |
338 | | -// builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
339 | | -// builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); |
340 | | -// builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); |
341 | | -// builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
342 | | -// builderFactory.setXIncludeAware(false); |
343 | | -// builderFactory.setExpandEntityReferences(false); |
344 | | -// DocumentBuilder builder = builderFactory.newDocumentBuilder(); |
| 317 | + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); |
| 318 | + builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
| 319 | + builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); |
| 320 | + builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); |
| 321 | + builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
| 322 | + builderFactory.setXIncludeAware(false); |
| 323 | + builderFactory.setExpandEntityReferences(false); |
| 324 | + DocumentBuilder builder = builderFactory.newDocumentBuilder(); |
345 | 325 | Document resultDom = builder.parse(new InputSource(transformedContentStream)); |
346 | 326 |
|
347 | 327 | // create xpath |
|
0 commit comments