Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import com.marklogic.client.io.Format;
Expand Down Expand Up @@ -49,13 +48,9 @@ private static class FailedRequestXMLParser implements FailedRequestParser {
@Override
public FailedRequest parseFailedRequest(int httpStatus, InputStream is) {
FailedRequest failure = new FailedRequest();
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
builder = XmlFactories.getDocumentBuilderFactory().newDocumentBuilder();
Document doc = builder.parse(is);
String statusCode = null;
NodeList statusCodes = doc.getElementsByTagNameNS(ERROR_NS, "status-code");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package com.marklogic.client.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
Expand All @@ -13,12 +14,15 @@
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.marklogic.client.MarkLogicBindingException;
import com.marklogic.client.MarkLogicIOException;
import com.marklogic.client.impl.XmlFactories;
import com.marklogic.client.io.marker.OperationNotSupported;
import com.marklogic.client.io.marker.QueryOptionsListReadHandle;
import com.marklogic.client.query.QueryOptionsListBuilder;
Expand Down Expand Up @@ -89,12 +93,22 @@ protected Class<InputStream> receiveAs() {
@Override
protected void receiveContent(InputStream content) {
try {
optionsHolder = (QueryOptionsListBuilder.OptionsList) unmarshaller.unmarshal(
XMLStreamReader reader = XmlFactories.makeNewInputFactory().createXMLStreamReader(
new InputStreamReader(content, StandardCharsets.UTF_8)
);
optionsHolder = (QueryOptionsListBuilder.OptionsList) unmarshaller.unmarshal(reader);
} catch (XMLStreamException e) {
logger.error("Failed to parse query options list", e);
throw new MarkLogicIOException(e);
} catch (JAXBException e) {
logger.error("Failed to unmarshall query options list",e);
throw new MarkLogicIOException(e);
} finally {
try {
content.close();
} catch (IOException e) {
// ignore.
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.marklogic.client.MarkLogicBindingException;
import com.marklogic.client.MarkLogicIOException;
import com.marklogic.client.impl.TuplesBuilder;
import com.marklogic.client.impl.XmlFactories;
import com.marklogic.client.io.marker.OperationNotSupported;
import com.marklogic.client.io.marker.TuplesReadHandle;
import com.marklogic.client.query.AggregateResult;
Expand Down Expand Up @@ -92,9 +95,13 @@ protected Class<InputStream> receiveAs() {
@Override
protected void receiveContent(InputStream content) {
try {
tuplesHolder = (TuplesBuilder.Tuples) unmarshaller.unmarshal(
XMLStreamReader reader = XmlFactories.makeNewInputFactory().createXMLStreamReader(
new InputStreamReader(content, StandardCharsets.UTF_8)
);
tuplesHolder = (TuplesBuilder.Tuples) unmarshaller.unmarshal(reader);
} catch (XMLStreamException e) {
logger.error("Failed to parse tuples", e);
throw new MarkLogicIOException(e);
} catch (JAXBException e) {
logger.error("Failed to unmarshall tuples",e);
throw new MarkLogicIOException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.marklogic.client.MarkLogicBindingException;
import com.marklogic.client.MarkLogicIOException;
import com.marklogic.client.impl.ValuesBuilder;
import com.marklogic.client.impl.XmlFactories;
import com.marklogic.client.io.marker.OperationNotSupported;
import com.marklogic.client.io.marker.ValuesReadHandle;
import com.marklogic.client.query.AggregateResult;
Expand Down Expand Up @@ -97,9 +100,13 @@ protected Class<InputStream> receiveAs() {
@Override
protected void receiveContent(InputStream content) {
try {
valuesHolder = (ValuesBuilder.Values) unmarshaller.unmarshal(
XMLStreamReader reader = XmlFactories.makeNewInputFactory().createXMLStreamReader(
new InputStreamReader(content, StandardCharsets.UTF_8)
);
valuesHolder = (ValuesBuilder.Values) unmarshaller.unmarshal(reader);
} catch (XMLStreamException e) {
logger.error("Failed to parse values", e);
throw new MarkLogicIOException(e);
} catch (JAXBException e) {
logger.error("Failed to unmarshall values",e);
throw new MarkLogicIOException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.marklogic.client.MarkLogicBindingException;
import com.marklogic.client.MarkLogicIOException;
import com.marklogic.client.impl.ValuesListBuilder;
import com.marklogic.client.impl.XmlFactories;
import com.marklogic.client.io.marker.OperationNotSupported;
import com.marklogic.client.io.marker.ValuesListReadHandle;
import com.marklogic.client.query.ValuesListResults;
Expand Down Expand Up @@ -110,9 +113,13 @@ protected Class<InputStream> receiveAs() {
@Override
protected void receiveContent(InputStream content) {
try {
valuesHolder = (ValuesListBuilder.ValuesList) unmarshaller.unmarshal(
XMLStreamReader reader = XmlFactories.makeNewInputFactory().createXMLStreamReader(
new InputStreamReader(content, StandardCharsets.UTF_8)
);
valuesHolder = (ValuesListBuilder.ValuesList) unmarshaller.unmarshal(reader);
} catch (XMLStreamException e) {
logger.error("Failed to parse values list", e);
throw new MarkLogicIOException(e);
} catch (JAXBException e) {
logger.error("Failed to unmarshall values list",e);
throw new MarkLogicIOException(e);
Expand Down
Loading