* @throws StaticPageServiceException if something goes wrong
*/
public void putStaticPage(StaticPage staticPage) throws StaticPageServiceException {
ContentCache cache = ContentCache.getInstance();
DAOFactory factory = DAOFactory.getConfiguredFactory();
StaticPageDAO dao = factory.getStaticPageDAO();
Blog blog = staticPage.getBlog();
synchronized (blog) {
try {
StaticPage sp = getStaticPageById(blog, staticPage.getId());
if (!staticPage.isPersistent() && sp != null) {
// the static page is new but one exists with the same ID already
// - increment the date/ID and try again
staticPage.setDate(new Date(staticPage.getDate().getTime() + 1));
putStaticPage(staticPage);
} else {
dao.storeStaticPage(staticPage);
staticPage.setPersistent(true);
cache.removeStaticPage(staticPage);
}
staticPage.getBlog().getSearchIndex().index(staticPage);