if (_book == null) {
if (_src == null) {
return null;
}
try {
Importer importer = _importer;
if (importer == null) {
importer = new ExcelImporter();
}
Book book = null;
if (importer instanceof ExcelImporter) {
URL url = null;
if (_src.startsWith("/")) {// try to load by application
// context.
WebApp wapp = Executions.getCurrent().getDesktop().getWebApp();
String path = wapp.getRealPath(_src);
if (path != null) {
File file = new File(path);
// if (file.isDirectory())
// throw new IllegalArgumentException("Your input source is a directory, not a vaild file");
if (file.exists())
url = file.toURI().toURL();
} else
url = wapp.getResource(_src);
}
if (url == null) {// try to load from class loader
url = new ClassLocator().getResource(_src);
}
if (url == null) {// try to load from file
File f = new File(_src);
if (f.exists()) {
url = f.toURI().toURL();
}
}
if (url == null) {
throw new UiException("resource for " + _src + " not found.");
}
book = ((ExcelImporter) importer).importsFromURL(url);
} else {
book = importer.imports(_src);
}
initBook(book); //will set _book inside this method
} catch (Exception ex) {
throw UiException.Aide.wrap(ex);