Connection conn = null;
try {
if (this.conn==null) conn = getConn(); else conn = this.conn;
// retrieve document file name...
DetailDocumentVO docVO = bean.loadDocument(
new DocumentPK(vo.getCompanyCodeSys01DOC15(),vo.getProgressiveDoc14DOC15()),
serverLanguageId,username,new ArrayList()
);
// read file from file system...
String appPath = docPath;
appPath = appPath.replace('\\','/');
if (!appPath.endsWith("/"))
appPath += "/";
if (!new File(appPath).isAbsolute()) {
// relative path (to "WEB-INF/classes/" folder)
appPath = this.getClass().getResource("/").getPath().replaceAll("%20"," ")+appPath;
}
String relativePath = FileUtils.getFilePath(appPath,"DOC14",vo.getCreateDateDOC15());
File file = new File(appPath+"DOC"+vo.getProgressiveDoc14DOC15()+"_"+vo.getVersionDOC15()); // retro-compatibility...
if (!file.exists())
file = new File(appPath+relativePath+"DOC"+vo.getProgressiveDoc14DOC15()+"_"+vo.getVersionDOC15());
FileInputStream fis = new FileInputStream(file);
byte[] doc = new byte[(int)file.length()];
fis.read(doc);
fis.close();
// store in application session the document...
String docId = System.currentTimeMillis()+"_"+docVO.getFilenameDOC14().toLowerCase();
Document document = new Document();
document.setDoc(doc);
document.setDocId(docId);
return document;
}