public void addTozip(ContentItem inContent, String inName, ZipOutputStream finalZip) throws IOException { InputStream is = inContent.getInputStream(); if (is == null) { log.error("Couldn't add file to zip: " + inContent.getAbsolutePath()); return; } ZipEntry entry = null; if (getFolderToStripOnZip() != null) { if (inName.contains(getFolderToStripOnZip())) { String stripped = inName.substring(getFolderToStripOnZip().length(), inName.length()); entry = new ZipEntry(stripped); } else { entry = new ZipEntry(inName); } } else { entry = new ZipEntry(inName); } entry.setSize(inContent.getLength()); entry.setTime(inContent.lastModified().getTime()); finalZip.putNextEntry(entry); try { new OutputFiller().fill(is, finalZip); } finally { is.close(); } finalZip.closeEntry(); }
/** * This only works if inSourcePath has an extension, i.e. newassets/admin/118/picture.jpg * * @param inSourcePath * @return */ public String getDataAssetsPath(String inSourcePath) { String prefix = "/WEB-INF/data" + getMediaArchive().getCatalogHome() + "/originals/"; String path = prefix + inSourcePath; Page page = getPageManager().getPage(path); ContentItem content = page.getContentItem(); return content.getAbsolutePath(); }