private Set<String> getReferencesToChange(WikiPage fromPage, WikiEngine engine) { Set<String> referrers = new TreeSet<String>(); Collection<String> r = engine.getReferenceManager().findReferrers(fromPage.getName()); if (r != null) referrers.addAll(r); try { Collection<Attachment> attachments = engine.getAttachmentManager().listAttachments(fromPage); for (Attachment att : attachments) { Collection<String> c = engine.getReferenceManager().findReferrers(att.getName()); if (c != null) referrers.addAll(c); } } catch (ProviderException e) { // We will continue despite this error log.error("Provider error while fetching attachments for rename", e); } return referrers; }
protected void exportPage(WikiEngine engine, Attachment att) throws IOException, ProviderException { exportPageHeader(att.getName(), att.getWiki(), att.getAuthor(), att.getLastModified(), true); m_out.println(" <sv:property sv:name='" + att.getFileName() + "' sv:type='" + BINARY + "'>"); m_out.print("<sv:value>"); InputStream binary = engine.getAttachmentManager().getAttachmentStream(att); Base64.InputStream base64 = new Base64.InputStream(binary, Base64.ENCODE); FileUtil.copyContents(new InputStreamReader(base64), m_out); binary.close(); m_out.println("</sv:value>"); m_out.println("</sv:property>"); exportPageFooter(); }