this.contentHandler.startElement(URI,
BLOG_NODE_NAME,
PREFIX + ':' + BLOG_NODE_NAME,
attributes);
ServiceSelector selector = null;
SiteManager siteManager = null;
try {
Request request = ObjectModelHelper.getRequest(this.objectModel);
Session session = RepositoryUtil.getSession(this.manager, request);
DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);
Publication publication = PublicationUtil.getPublication(this.manager, request);
selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
Document[] docs = siteManager.getDocuments(map, publication, area);
Arrays.sort((Object[]) docs, new Comparator() {
public int compare(Object o1, Object o2) {
try {
Date d1 = new Date(((Document) o2).getLastModified());
Date d2 = new Date(((Document) o1).getLastModified());
return d2.compareTo(d1);
}
catch (DocumentException e) {
throw new RuntimeException(e);
}
}
});
for (int i = 0; i < docs.length; i++) {
if (numrecent > 0 && numrecent <= i)
break;
String path = docs[i].getPath();
if (path.startsWith("/entries/")) {
attributes.clear();
attributes.addAttribute("", PATH_ATTR_NAME, PATH_ATTR_NAME, "CDATA", path);
attributes.addAttribute("",
LASTMOD_ATTR_NAME,
LASTMOD_ATTR_NAME,
"CDATA",
String.valueOf(docs[i].getLastModified()));
this.contentHandler.startElement(URI, ENTRY_NODE_NAME, PREFIX + ':'
+ ENTRY_NODE_NAME, attributes);
this.contentHandler.endElement(URI, ENTRY_NODE_NAME, PREFIX + ':'
+ ENTRY_NODE_NAME);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (selector != null) {
if (siteManager != null) {
selector.release(siteManager);
}
this.manager.release(selector);
}
}