byte[] data = fileCache.getFile(publishingFile, lastModified);
if (data != null) {
try {
// B000041DA
ByteArrayDataSource dataIn = new ByteArrayDataSource(data, publishingFile.getFileName(), contentType);
String designEncoding = (String) database.getAttribute(WGACore.DBATTRIB_DESIGN_ENCODING);
if (designEncoding != null) {
writeData(dataIn, request, response, designEncoding, data.length, database.getDbReference(), true);
}
else {
writeData(dataIn, request, response, null, data.length, database.getDbReference(), true);
}
}
catch (java.net.SocketException exc) {
_log.warn("Dispatch of cached file request failed bc. of socket error: " + exc.getMessage());
}
catch (java.io.IOException exc) {
if (!exc.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
_log.warn("Dispatch of cached file request failed bc. of IO error: " + exc.getMessage());
}
}
return;
}
// In domino native implementations: Change to Master login to retrieve
// data (Workaround for Domino API Bug)
String databaseTypeName = database.getTypeName();
if (databaseTypeName.equals("domino/wgacontentstore/local") || databaseTypeName.equals("domino/custom/local")) {
WGFactory.getInstance().closeSessions();
database = _core.openContentDB(path.getDatabaseKey(), null, true);
}
long fileSize = publishingFile.getFileSize();
// Look if file size is below cache threshold - if so, collect data and
// put into cache, then serve
long threshold = fileCache.getThreshold();
if (fileSize != -1 && threshold >= fileSize) {
// Put into cache
InputStream inputStream = publishingFile.getInputStream();
try {
ByteArrayOutputStream outCache = new ByteArrayOutputStream((int) fileSize);
WGUtils.inToOut(inputStream, outCache, 2048);
data = outCache.toByteArray();
fileCache.putFile(publishingFile, data, lastModified);
}
catch (java.net.SocketException exc) {
_log.warn("Caching of file request failed bc. of socket error: " + exc.getMessage());
}
catch (java.io.IOException exc) {
if (!exc.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
_log.warn("Caching of file request failed bc. of IO error: " + exc.getMessage());
}
}
finally {
if (inputStream != null) {
try {
inputStream.close();
}
catch (Exception e) {
}
}
}
// Writing from cache to out
try {
// B000041DA
ByteArrayDataSource dataIn = new ByteArrayDataSource(data, publishingFile.getFileName(), contentType);
String designEncoding = (String) database.getAttribute(WGACore.DBATTRIB_DESIGN_ENCODING);
if (designEncoding != null) {
writeData(dataIn, request, response, designEncoding, data.length, database.getDbReference(), true);
}
else {