(LibraryResource record)
| 239 | } |
| 240 | |
| 241 | private void openLibraryResource(LibraryResource record) { |
| 242 | boolean loadFailed = false; |
| 243 | try { |
| 244 | libraryBrowser.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
| 245 | String target = record.getAbsoluteTarget(); |
| 246 | if (!ResourceLoader.isHTTP(target)) { |
| 247 | target = ResourceLoader.getURIPath(XML.getResolvedPath(record.getTarget(), record.getBasePath())); |
| 248 | } |
| 249 | // download comPADRE targets to osp cache |
| 250 | if (target.indexOf("document/ServeFile.cfm?") >= 0) { |
| 251 | String fileName = record.getProperty("download_filename"); |
| 252 | try { |
| 253 | target = ResourceLoader.downloadToOSPCache(target, fileName, false).toURI().toString(); |
| 254 | } catch (Exception ex) { |
| 255 | loadFailed = true; |
| 256 | } |
| 257 | } |
| 258 | if (target == null) { |
| 259 | loadFailed = true; |
| 260 | } |
| 261 | if (loadFailed) { |
| 262 | String name = record.getName(); |
| 263 | if (name == null || "".equals(name)) |
| 264 | name = "Unknown"; |
| 265 | String s = "No resource could be downloaded for node " + name; |
| 266 | JOptionPane.showMessageDialog(libraryBrowser, s, "Error", |
| 267 | JOptionPane.WARNING_MESSAGE); |
| 268 | return; |
| 269 | } |
| 270 | if (!isZip(target)) { |
| 271 | String msg = XML.getName(target)+ " is not a zip file."; |
| 272 | JOptionPane.showMessageDialog(frame, msg, "Wrong File Type", |
| 273 | JOptionPane.WARNING_MESSAGE); |
| 274 | return; |
| 275 | } |
| 276 | else { |
| 277 | // check target to make sure it is a readable zip file |
| 278 | Map<String, ZipEntry> contents = ResourceLoader.getZipContents(target, true); |
| 279 | if (contents.isEmpty()) { |
| 280 | String msg = XML.getName(target)+ " is empty."; |
| 281 | JOptionPane.showMessageDialog(frame, msg, "Empty File", |
| 282 | JOptionPane.WARNING_MESSAGE); |
| 283 | return; |
| 284 | } |
| 285 | // loadIntoEditor(target); |
| 286 | new AsyncLoader(target).executeAsync(); |
| 287 | return; |
| 288 | } |
| 289 | } finally { |
| 290 | libraryBrowser.setCursor(Cursor.getDefaultCursor()); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | private boolean loadIntoEditor(String path) { |
| 295 | Map<String, ZipEntry> contents = ResourceLoader.getZipContents(path, true); |
no test coverage detected