use of org.apache.wiki.pages.PageManager in project jspwiki by apache.
the class WeblogPlugin method findBlogEntries.
/**
* Attempts to locate all pages that correspond to the
* blog entry pattern. Will only consider the days on the dates; not the hours and minutes.
*
* @param engine Engine which is used to get the pages
* @param baseName The basename (e.g. "Main" if you want "Main_blogentry_xxxx")
* @param start The date which is the first to be considered
* @param end The end date which is the last to be considered
* @return a list of pages with their FIRST revisions.
*/
public List<Page> findBlogEntries(final Engine engine, String baseName, final Date start, final Date end) {
final PageManager mgr = engine.getManager(PageManager.class);
final Set<String> allPages = engine.getManager(ReferenceManager.class).findCreated();
final ArrayList<Page> result = new ArrayList<>();
baseName = makeEntryPage(baseName);
for (final String pageName : allPages) {
if (pageName.startsWith(baseName)) {
try {
final Page firstVersion = mgr.getPageInfo(pageName, 1);
final Date d = firstVersion.getLastModified();
if (d.after(start) && d.before(end)) {
result.add(firstVersion);
}
} catch (final Exception e) {
log.debug("Page name :" + pageName + " was suspected as a blog entry but it isn't because of parsing errors", e);
}
}
}
return result;
}
use of org.apache.wiki.pages.PageManager in project jspwiki by apache.
the class VersioningFileProviderTest method testDelete.
@Test
public void testDelete() throws Exception {
engine.saveText(NAME1, "v1");
engine.saveText(NAME1, "v2");
engine.saveText(NAME1, "v3");
final PageManager mgr = engine.getManager(PageManager.class);
final PageProvider provider = mgr.getProvider();
provider.deletePage(NAME1);
final File f = new File(files, NAME1 + AbstractFileProvider.FILE_EXT);
Assertions.assertFalse(f.exists(), "file exists");
}
use of org.apache.wiki.pages.PageManager in project jspwiki by apache.
the class VersioningFileProviderTest method testDeleteVersion.
@Test
public void testDeleteVersion() throws Exception {
engine.saveText(NAME1, "v1\r\n");
engine.saveText(NAME1, "v2\r\n");
engine.saveText(NAME1, "v3\r\n");
final PageManager mgr = engine.getManager(PageManager.class);
final PageProvider provider = mgr.getProvider();
List<Page> l = provider.getVersionHistory(NAME1);
Assertions.assertEquals(3, l.size(), "wrong # of versions");
provider.deleteVersion(NAME1, 2);
l = provider.getVersionHistory(NAME1);
Assertions.assertEquals(2, l.size(), "wrong # of versions");
Assertions.assertEquals("v1\r\n", provider.getPageText(NAME1, 1), "v1");
Assertions.assertEquals("v3\r\n", provider.getPageText(NAME1, 3), "v3");
try {
provider.getPageText(NAME1, 2);
Assertions.fail("v2");
} catch (final NoSuchVersionException e) {
// This is expected
}
}
Aggregations