Skip to content
Open
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
2 changes: 1 addition & 1 deletion extensions/expath/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<dependency>
<groupId>org.expath.http.client</groupId>
<artifactId>http-client-java</artifactId>
<version>1.4.1</version>
<version>1.5.2</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@
import org.exist.xquery.XPathException;
import org.exist.xquery.XQueryContext;
import org.exist.xquery.modules.ModuleUtils;
import org.exist.xquery.value.*;
import org.exist.xquery.value.Base64BinaryValueType;
import org.exist.xquery.value.BinaryValueFromFile;
import org.exist.xquery.value.NodeValue;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.StringValue;
import org.exist.xquery.value.Type;
import org.exist.xquery.value.ValueSequence;
import org.expath.httpclient.HttpClientException;
import org.expath.httpclient.HttpResponse;
import org.expath.httpclient.model.Result;
import org.xml.sax.SAXException;

import static org.expath.httpclient.HttpClientError.HC001;

/**
* @author <a href="mailto:[email protected]">Adam Retter</a>
*/
Expand Down Expand Up @@ -78,7 +86,7 @@ public void add(final Reader reader, final Charset charset) throws HttpClientExc
builder.append(cbuf, 0, read);
}
} catch(final IOException ioe) {
throw new HttpClientException("Unable to add string value to result: " + ioe.getMessage(), ioe);
throw new HttpClientException(HC001, "Unable to add string value to result: " + ioe.getMessage(), ioe);
} finally {
try {
reader.close();
Expand All @@ -101,7 +109,7 @@ public void add(final InputStream is) throws HttpClientException {

result.add(BinaryValueFromFile.getInstance(context, new Base64BinaryValueType(), tempFile, (isClosed, file) -> temporaryFileManager.returnTemporaryFile(file), null));
} catch(final XPathException | IOException xpe) {
throw new HttpClientException("Unable to add binary value to result:" + xpe.getMessage(), xpe);
throw new HttpClientException(HC001, "Unable to add binary value to result:" + xpe.getMessage(), xpe);
} finally {
try {
is.close();
Expand All @@ -117,7 +125,7 @@ public void add(final Source src) throws HttpClientException {
final NodeValue nodeValue = ModuleUtils.sourceToXML(context, src, null);
result.add(nodeValue);
} catch(final SAXException | IOException saxe) {
throw new HttpClientException("Unable to add Source to result:" + saxe.getMessage(), saxe);
throw new HttpClientException(HC001, "Unable to add Source to result:" + saxe.getMessage(), saxe);
}
}

Expand All @@ -141,7 +149,7 @@ public void add(final HttpResponse response) throws HttpClientException {
result = newResult;
}
} catch (final XPathException xpe) {
throw new HttpClientException("Unable to add HttpResponse to result:" + xpe.getMessage(), xpe);
throw new HttpClientException(HC001, "Unable to add HttpResponse to result:" + xpe.getMessage(), xpe);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

import javax.xml.XMLConstants;

import static org.expath.httpclient.HttpClientError.HC001;

/**
* @author <a href="mailto:[email protected]">Adam Retter</a>
*/
Expand Down Expand Up @@ -93,7 +95,7 @@ public void outputHeaders(HeaderSet headers)
endElem();
}
catch ( ToolsException ex ) {
throw new HttpClientException("Error building the header " + name, ex);
throw new HttpClientException(HC001, "Error building the header " + name, ex);
}
}
}
Expand Down
Loading