* @param blog the Blog
* @return a Page instance, or null if the page couldn't be found
* @throws StaticPageServiceException if something goes wrong
*/
public StaticPage getStaticPageById(Blog blog, String pageId) throws StaticPageServiceException {
StaticPage staticPage;
ContentCache cache = ContentCache.getInstance();
try {
staticPage = cache.getStaticPage(blog, pageId);
if (staticPage != null) {
log.debug("Got static page " + pageId+ " from cache");
} else {
log.debug("Loading static page " + pageId+ " from disk");
DAOFactory factory = DAOFactory.getConfiguredFactory();
StaticPageDAO dao = factory.getStaticPageDAO();
staticPage = dao.loadStaticPage(blog, pageId);
if (staticPage != null) {
staticPage.setPersistent(true);
cache.putStaticPage(staticPage);
}
}
} catch (PersistenceException pe) {
throw new StaticPageServiceException(blog, pe);
}
if (staticPage != null) {
staticPage = (StaticPage)staticPage.clone();
}
return staticPage;
}