use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class RPCHandlerUTF8 method getAllPages.
public Vector<String> getAllPages() {
checkPermission(PagePermission.VIEW);
final Set<Page> pages = m_engine.getManager(PageManager.class).getRecentChanges();
final Vector<String> result = new Vector<>();
for (final Page p : pages) {
if (!(p instanceof Attachment)) {
result.add(p.getName());
}
}
return result;
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class RPCHandlerUTF8 method parsePageCheckCondition.
/**
* Simple helper method, turns the incoming page name into
* normal Java string, then checks page condition.
*
* @param pagename Page Name as an RPC string (URL-encoded UTF-8)
* @return Real page name, as Java string.
* @throws XmlRpcException, if there is something wrong with the page.
*/
private String parsePageCheckCondition(final String pagename) throws XmlRpcException {
if (!m_engine.getManager(PageManager.class).wikiPageExists(pagename)) {
throw new XmlRpcException(ERR_NOPAGE, "No such page '" + pagename + "' found, o master.");
}
final Page p = m_engine.getManager(PageManager.class).getPage(pagename);
checkPermission(PermissionFactory.getPagePermission(p, PagePermission.VIEW_ACTION));
return pagename;
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class RPCHandlerUTF8 method listLinks.
public Vector<Hashtable<String, String>> listLinks(String pagename) throws XmlRpcException {
pagename = parsePageCheckCondition(pagename);
final Page page = m_engine.getManager(PageManager.class).getPage(pagename);
final String pagedata = m_engine.getManager(PageManager.class).getPureText(page);
final LinkCollector localCollector = new LinkCollector();
final LinkCollector extCollector = new LinkCollector();
final LinkCollector attCollector = new LinkCollector();
final Context context = Wiki.context().create(m_engine, page);
m_engine.getManager(RenderingManager.class).textToHTML(context, pagedata, localCollector, extCollector, attCollector);
final Vector<Hashtable<String, String>> result = new Vector<>();
//
for (final String link : localCollector.getLinks()) {
final Hashtable<String, String> ht = new Hashtable<>();
ht.put("page", link);
ht.put("type", LINK_LOCAL);
if (m_engine.getManager(PageManager.class).wikiPageExists(link)) {
ht.put("href", context.getViewURL(link));
} else {
ht.put("href", context.getURL(ContextEnum.PAGE_EDIT.getRequestContext(), link));
}
result.add(ht);
}
//
for (final String link : attCollector.getLinks()) {
final Hashtable<String, String> ht = new Hashtable<>();
ht.put("page", link);
ht.put("type", LINK_LOCAL);
ht.put("href", context.getURL(ContextEnum.PAGE_ATTACH.getRequestContext(), link));
result.add(ht);
}
//
for (final String link : extCollector.getLinks()) {
final Hashtable<String, String> ht = new Hashtable<>();
ht.put("page", link);
ht.put("type", LINK_EXTERNAL);
ht.put("href", link);
result.add(ht);
}
return result;
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class WikiEngineTest method testOldVersionVars.
/**
* Tests BugReadingOfVariableNotWorkingForOlderVersions
*/
@Test
public void testOldVersionVars() throws Exception {
final Properties props = TestEngine.getTestProperties("/jspwiki-vers-custom.properties");
props.setProperty(CachingManager.PROP_CACHE_ENABLE, "true");
final TestEngine engine = new TestEngine(props);
engine.saveText(NAME1, "[{SET foo=bar}]");
engine.saveText(NAME1, "[{SET foo=notbar}]");
final Page v1 = engine.getManager(PageManager.class).getPage(NAME1, 1);
final Page v2 = engine.getManager(PageManager.class).getPage(NAME1, 2);
Assertions.assertEquals("bar", v1.getAttribute("foo"), "V1");
Assertions.assertEquals("notbar", v2.getAttribute("foo"), "V2");
engine.getManager(PageManager.class).deletePage(NAME1);
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class WikiEngineTest method testChangeNoteOldVersion2.
@Test
public void testChangeNoteOldVersion2() throws Exception {
final Page p = Wiki.contents().page(m_engine, NAME1);
final Context context = Wiki.context().create(m_engine, p);
context.getPage().setAttribute(Page.CHANGENOTE, "Test change");
m_engine.getManager(PageManager.class).saveText(context, "test");
for (int i = 0; i < 5; i++) {
final Page p2 = m_engine.getManager(PageManager.class).getPage(NAME1).clone();
p2.removeAttribute(Page.CHANGENOTE);
context.setPage(p2);
m_engine.getManager(PageManager.class).saveText(context, "test" + i);
}
final Page p3 = m_engine.getManager(PageManager.class).getPage(NAME1, -1);
Assertions.assertNull(p3.getAttribute(Page.CHANGENOTE));
}
Aggregations