use of org.apache.wiki.attachment.Attachment in project jspwiki by apache.
the class WikiEngine method deletePage.
/**
* Deletes a page or an attachment completely, including all versions. If the page
* does not exist, does nothing.
*
* @param pageName The name of the page.
* @throws ProviderException If something goes wrong.
*/
public void deletePage(String pageName) throws ProviderException {
WikiPage p = getPage(pageName);
if (p != null) {
if (p instanceof Attachment) {
m_attachmentManager.deleteAttachment((Attachment) p);
} else {
Collection<String> refTo = m_referenceManager.findRefersTo(pageName);
if (m_attachmentManager.hasAttachments(p)) {
Collection attachments = m_attachmentManager.listAttachments(p);
for (Iterator atti = attachments.iterator(); atti.hasNext(); ) {
Attachment attachment = (Attachment) atti.next();
refTo.remove(attachment.getName());
m_attachmentManager.deleteAttachment(attachment);
}
}
m_pageManager.deletePage(p);
firePageEvent(WikiPageEvent.PAGE_DELETED, pageName);
}
}
}
use of org.apache.wiki.attachment.Attachment in project jspwiki by apache.
the class DefaultAclManager method getPermissions.
/**
* Returns the access control list for the page.
* If the ACL has not been parsed yet, it is done
* on-the-fly. If the page has a parent page, then that is tried also.
* This method was moved from Authorizer;
* it was consolidated with some code from AuthorizationManager.
* This method is guaranteed to return a non-<code>null</code> Acl.
*
* @param page the page
* @return the Acl representing permissions for the page
* @since 2.2.121
*/
public Acl getPermissions(WikiPage page) {
//
// Does the page already have cached ACLs?
//
Acl acl = page.getAcl();
log.debug("page=" + page.getName() + "\n" + acl);
if (acl == null) {
//
if (page instanceof Attachment) {
WikiPage parent = m_engine.getPage(((Attachment) page).getParentName());
acl = getPermissions(parent);
} else {
//
// Or, try parsing the page
//
WikiContext ctx = new WikiContext(m_engine, page);
ctx.setVariable(RenderingManager.VAR_EXECUTE_PLUGINS, Boolean.FALSE);
m_engine.getHTML(ctx, page);
if (page.getAcl() == null) {
page.setAcl(new AclImpl());
}
acl = page.getAcl();
}
}
return acl;
}
Aggregations