diff --git a/src/main/java/org/olat/core/commons/modules/bc/commands/CmdDownloadZip.java b/src/main/java/org/olat/core/commons/modules/bc/commands/CmdDownloadZip.java index 6c8150e876b037c2c77bae6b94848717bfa149c6..6d3e747ad590bd63ccfde5c2ec21656bb99c23c0 100644 --- a/src/main/java/org/olat/core/commons/modules/bc/commands/CmdDownloadZip.java +++ b/src/main/java/org/olat/core/commons/modules/bc/commands/CmdDownloadZip.java @@ -197,6 +197,13 @@ public class CmdDownloadZip implements FolderCommand { ZipUtil.addToZip(item, "", zout); } zout.flush(); + } catch (IOException e) { + String className = e.getClass().getSimpleName(); + if("ClientAbortException".equals(className)) { + log.debug("client browser probably abort when downloading zipped files", e); + } else { + log.error("client browser probably abort when downloading zipped files", e); + } } catch (Exception e) { log.error("", e); } diff --git a/src/main/java/org/olat/core/dispatcher/mapper/MapperDispatcher.java b/src/main/java/org/olat/core/dispatcher/mapper/MapperDispatcher.java index 13b219ef8cb1a95cff216256306908389ed2860e..9d6b6ae9e69985dae76c81058aa8db9c357f14f1 100644 --- a/src/main/java/org/olat/core/dispatcher/mapper/MapperDispatcher.java +++ b/src/main/java/org/olat/core/dispatcher/mapper/MapperDispatcher.java @@ -97,19 +97,23 @@ public class MapperDispatcher implements Dispatcher { //an anonymous mapper? m = mapperService.getMapperById(null, smappath); if(m == null) { - log.warn("Call to mapped resource, but mapper does not exist for path::" + smappath); + log.warn("Call to mapped resource, but mapper does not exist for path::{}", smappath); hres.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } } String mod = slashPos > 0 ? subInfo.substring(slashPos) : ""; if (mod.indexOf("..") != -1) { - log.warn("Illegal mapper path::" + mod + " contains '..'"); + log.warn("Illegal mapper path::{} contains '..'", mod); hres.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } // /bla/blu.html MediaResource mr = m.handle(mod, hreq); - ServletUtil.serveResource(hreq, hres, mr); + if(mr != null) { + ServletUtil.serveResource(hreq, hres, mr); + } else { + hres.setStatus(HttpServletResponse.SC_NO_CONTENT); + } } } \ No newline at end of file diff --git a/src/main/java/org/olat/core/gui/control/winmgr/MediaResourceMapper.java b/src/main/java/org/olat/core/gui/control/winmgr/MediaResourceMapper.java index dd99686b0bfe8c2d122d1bcdc28e6fbb9c9bb6bf..2eca3b00480749f1744e5c38d1042f8828958773 100644 --- a/src/main/java/org/olat/core/gui/control/winmgr/MediaResourceMapper.java +++ b/src/main/java/org/olat/core/gui/control/winmgr/MediaResourceMapper.java @@ -40,14 +40,15 @@ import org.olat.core.logging.AssertException; * @author Felix Jost */ public class MediaResourceMapper implements Mapper { - MediaResource mediaResource; + + private MediaResource mediaResource; public MediaResourceMapper() { - // + // } + @Override public MediaResource handle(String relPath, HttpServletRequest request) { - if (mediaResource == null) throw new AssertException("mr already served, relPath =" + relPath + ","); MediaResource r = mediaResource; mediaResource = null; return r; @@ -60,5 +61,4 @@ public class MediaResourceMapper implements Mapper { if (this.mediaResource != null) throw new AssertException("mediaresource not yet served!"); this.mediaResource = mediaResource; } - } \ No newline at end of file diff --git a/src/main/java/org/olat/core/util/ZipUtil.java b/src/main/java/org/olat/core/util/ZipUtil.java index e09036d903d83d4eeaf1f57dabee3b1ac0c0866f..c82e88beb933d8b243cb62441cc1145ad574c2fe 100644 --- a/src/main/java/org/olat/core/util/ZipUtil.java +++ b/src/main/java/org/olat/core/util/ZipUtil.java @@ -109,7 +109,7 @@ public class ZipUtil { xxunzip(in, targetDir.getAbsolutePath()); return true; } catch (IOException e) { - log.error("I/O failure while unzipping "+zipFile.getAbsolutePath()+" to "+targetDir.getAbsolutePath()); + handleIOException("I/O failure while unzipping " + zipFile.getAbsolutePath() + " to " + targetDir.getAbsolutePath(), e); return false; } } @@ -128,7 +128,7 @@ public class ZipUtil { xxunzip(in, outdir); return true; } catch (IOException e) { - log.error("I/O failure while unzipping "+zipLeaf.getName()+" to "+outdir); + handleIOException("I/O failure while unzipping " + zipLeaf.getName() + " to " + outdir, e); return false; } } @@ -150,7 +150,7 @@ public class ZipUtil { xxunzip (in, outdir); return true; } catch (IOException e) { - log.error("I/O failure while unzipping "+zipFile.getName()+" to "+outdir); + handleIOException("I/O failure while unzipping " + zipFile.getName() + " to " + outdir, e); return false; } } @@ -171,7 +171,7 @@ public class ZipUtil { try(InputStream in = zipLeaf.getInputStream()) { unzipped = unzip(in, targetDir, identity, versioning); } catch(Exception e) { - log.error("", e); + handleIOException("", e); } return unzipped; } @@ -268,7 +268,7 @@ public class ZipUtil { try(OutputStream out = newEntry.getOutputStream(false)) { return FileUtils.copy(oZip, out); } catch(Exception e) { - log.error("", e); + handleIOException("", e); return false; } } @@ -288,7 +288,7 @@ public class ZipUtil { try(InputStream in = zipLeaf.getInputStream()) { unzipped = unzipNonStrict(in, targetDir, identity, versioning); } catch(IOException e) { - log.error("", e); + handleIOException("", e); } return unzipped; } @@ -299,7 +299,7 @@ public class ZipUtil { InputStream bin = new BufferedInputStream(in, FileUtils.BSIZE)) { unzipped = unzipNonStrict(bin, targetDir, identity, versioning); } catch(IOException e) { - log.error("", e); + handleIOException("", e); } return unzipped; } @@ -382,7 +382,7 @@ public class ZipUtil { try(InputStream in = new ShieldInputStream(oZip)) { return VFSManager.copyContent(in, newEntry); } catch(Exception e) { - log.error("", e); + handleIOException("", e); return false; } } @@ -391,7 +391,7 @@ public class ZipUtil { try(OutputStream sout = new ShieldOutputStream(out)) { return VFSManager.copyContent(leaf, sout); } catch(Exception e) { - log.error("", e); + handleIOException("", e); return false; } } @@ -635,7 +635,7 @@ public class ZipUtil { zip(container, out); return true; } catch(IOException e) { - log.error("", e); + handleIOException("", e); return false; } } @@ -656,7 +656,7 @@ public class ZipUtil { } return true; } catch(IOException e) { - log.error("", e); + handleIOException("", e); return false; } } @@ -718,7 +718,7 @@ public class ZipUtil { if (vfsItem instanceof LocalImpl) { name = ((LocalImpl)vfsItem).getBasefile().getAbsolutePath(); } - log.error("I/O error while adding "+name+" to zip:"+ioe); + handleIOException("I/O error while adding " + name + " to zip:", ioe); return false; } return success; @@ -771,7 +771,7 @@ public class ZipUtil { } }); } catch (IOException e) { - log.error("", e); + handleIOException("", e); } } @@ -787,7 +787,7 @@ public class ZipUtil { FileUtils.copy(source, exportStream); exportStream.closeEntry(); } catch(IOException e) { - log.error("", e); + handleIOException("", e); } } @@ -797,7 +797,7 @@ public class ZipUtil { FileUtils.copy(source, exportStream); exportStream.closeEntry(); } catch(IOException e) { - log.error("", e); + handleIOException("", e); } } @@ -822,7 +822,7 @@ public class ZipUtil { try(InputStream in=Files.newInputStream(file)) { FileUtils.copy(in, exportStream); } catch (Exception e) { - log.error("", e); + handleIOException("", e); } exportStream.closeEntry(); @@ -831,7 +831,7 @@ public class ZipUtil { } }); } catch (IOException e) { - log.error("", e); + handleIOException("", e); } } @@ -878,7 +878,20 @@ public class ZipUtil { FileUtils.cpio(new BufferedInputStream(zis), bos, "unzip:" + of.getName()); bos.flush(); } catch(IOException e) { - log.error("", e); + handleIOException("", e); + } + } + + private static final void handleIOException(String msg, Exception e) { + try { + String className = e.getClass().getSimpleName(); + if("ClientAbortException".equals(className)) { + log.debug("client browser probably abort during operaation", e); + } else { + log.error(msg, e); + } + } catch (Exception e1) { + log.error("", e1); } } }