use of nl.nn.adapterframework.util.DB2XMLWriter in project iaf by ibissource.
the class JdbcQuerySenderBase method getResult.
protected String getResult(ResultSet resultset, Object blobSessionVar, Object clobSessionVar, HttpServletResponse response, String contentType, String contentDisposition) throws JdbcException, SQLException, IOException, JMSException {
String result = null;
if (isScalar()) {
if (resultset.next()) {
// result = resultset.getString(1);
ResultSetMetaData rsmeta = resultset.getMetaData();
if (JdbcUtil.isBlobType(resultset, 1, rsmeta)) {
if (response == null) {
if (blobSessionVar != null) {
JdbcUtil.streamBlob(resultset, 1, getBlobCharset(), isBlobsCompressed(), getBlobBase64Direction(), blobSessionVar, isCloseOutputstreamOnExit());
return "";
}
} else {
InputStream inputStream = JdbcUtil.getBlobInputStream(resultset, 1, isBlobsCompressed());
if (StringUtils.isNotEmpty(contentType)) {
response.setHeader("Content-Type", contentType);
}
if (StringUtils.isNotEmpty(contentDisposition)) {
response.setHeader("Content-Disposition", contentDisposition);
}
if (getBlobBase64Direction() != null) {
if ("decode".equalsIgnoreCase(getBlobBase64Direction())) {
inputStream = new Base64InputStream(inputStream);
} else if ("encode".equalsIgnoreCase(getBlobBase64Direction())) {
inputStream = new Base64InputStream(inputStream, true);
}
}
OutputStream outputStream = response.getOutputStream();
Misc.streamToStream(inputStream, outputStream);
log.debug(getLogPrefix() + "copied blob input stream [" + inputStream + "] to output stream [" + outputStream + "]");
return "";
}
}
if (clobSessionVar != null && JdbcUtil.isClobType(resultset, 1, rsmeta)) {
JdbcUtil.streamClob(resultset, 1, clobSessionVar, isCloseOutputstreamOnExit());
return "";
}
result = JdbcUtil.getValue(resultset, 1, rsmeta, getBlobCharset(), isBlobsCompressed(), getNullValue(), isTrimSpaces(), isBlobSmartGet(), StringUtils.isEmpty(getBlobCharset()));
if (resultset.wasNull()) {
if (isScalarExtended()) {
result = "[null]";
} else {
result = null;
}
} else {
if (result.length() == 0) {
if (isScalarExtended()) {
result = "[empty]";
}
}
}
} else {
if (isScalarExtended()) {
result = "[absent]";
}
}
} else {
// Create XML and give the maxlength as a parameter
DB2XMLWriter db2xml = new DB2XMLWriter();
db2xml.setNullValue(getNullValue());
db2xml.setTrimSpaces(isTrimSpaces());
db2xml.setBlobCharset(getBlobCharset());
db2xml.setDecompressBlobs(isBlobsCompressed());
db2xml.setGetBlobSmart(isBlobSmartGet());
result = db2xml.getXML(resultset, getMaxRows(), isIncludeFieldDefinition());
}
return result;
}
Aggregations