use of org.apache.wiki.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 WikiEngine 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.
* @throws ProviderException If something goes wrong
*/
public List findBlogEntries(WikiEngine engine, String baseName, Date start, Date end) throws ProviderException {
PageManager mgr = engine.getPageManager();
Set allPages = engine.getReferenceManager().findCreated();
ArrayList<WikiPage> result = new ArrayList<WikiPage>();
baseName = makeEntryPage(baseName);
for (Iterator i = allPages.iterator(); i.hasNext(); ) {
String pageName = (String) i.next();
if (pageName.startsWith(baseName)) {
try {
WikiPage firstVersion = mgr.getPageInfo(pageName, 1);
Date d = firstVersion.getLastModified();
if (d.after(start) && d.before(end)) {
result.add(firstVersion);
}
} catch (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.PageManager in project jspwiki by apache.
the class ListLocksPlugin method execute.
/**
* {@inheritDoc}
*/
public String execute(WikiContext context, Map<String, String> params) throws PluginException {
StringBuilder result = new StringBuilder();
PageManager mgr = context.getEngine().getPageManager();
List<PageLock> locks = mgr.getActiveLocks();
ResourceBundle rb = Preferences.getBundle(context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
result.append("<table class=\"wikitable\">\n");
result.append("<tr>\n");
result.append("<th>" + rb.getString("plugin.listlocks.page") + "</th><th>" + rb.getString("plugin.listlocks.locked.by") + "</th><th>" + rb.getString("plugin.listlocks.acquired") + "</th><th>" + rb.getString("plugin.listlocks.expires") + "</th>\n");
result.append("</tr>");
if (locks.size() == 0) {
result.append("<tr><td colspan=\"4\" class=\"odd\">" + rb.getString("plugin.listlocks.no.locks.exist") + "</td></tr>\n");
} else {
int rowNum = 1;
for (Iterator<PageLock> i = locks.iterator(); i.hasNext(); ) {
PageLock lock = i.next();
result.append(rowNum % 2 != 0 ? "<tr class=\"odd\">" : "<tr>");
result.append("<td>" + lock.getPage() + "</td>");
result.append("<td>" + lock.getLocker() + "</td>");
result.append("<td>" + Preferences.renderDate(context, lock.getAcquisitionTime(), Preferences.TimeFormat.DATETIME) + "</td>");
result.append("<td>" + Preferences.renderDate(context, lock.getExpiryTime(), Preferences.TimeFormat.DATETIME) + "</td>");
result.append("</tr>\n");
rowNum++;
}
}
result.append("</table>");
return result.toString();
}
Aggregations