// FIXME: Should also use events! public void deleteAttachment(Attachment att) throws ProviderException { if (m_provider == null) return; m_provider.deleteAttachment(att); m_engine.getSearchManager().pageRemoved(att); m_engine.getReferenceManager().clearPageEntries(att.getName()); }
/** * Stores an attachment directly from a stream. If the attachment did not exist previously, this * method will create it. If it did exist, it stores a new version. * * @param att Attachment to store this under. * @param in InputStream from which the attachment contents will be read. * @throws IOException If writing the attachment failed. * @throws ProviderException If something else went wrong. */ public void storeAttachment(Attachment att, InputStream in) throws IOException, ProviderException { if (m_provider == null) { return; } // // Checks if the actual, real page exists without any modifications // or aliases. We cannot store an attachment to a non-existant page. // if (!m_engine.getPageManager().pageExists(att.getParentName())) { // the caller should catch the exception and use the exception text as an i18n key throw new ProviderException("attach.parent.not.exist"); } m_provider.putAttachmentData(att, in); m_engine.getReferenceManager().updateReferences(att.getName(), new java.util.Vector()); WikiPage parent = new WikiPage(m_engine, att.getParentName()); m_engine.updateReferences(parent); m_engine.getSearchManager().reindexPage(att); }