bpapez 2005/12/06 13:12:35 CET
Modified files:
core/src/java/org/jahia/services/pages ContentPage.java
Log:
* New method to force creating a new object from DB and putting it to the
cache:
public static ContentObject getChildInstance (String IDInType, boolean
forceLoadFromDB)
* New method to force creating a new object from DB and putting it to the
cache:
public static synchronized ContentPage getPage(int pageID,
boolean withTemplate, boolean forceLoadFromDB)
throws JahiaException
* Don't just swallow the exception in
activeDeletedEntries, activeNonDeletedEntries and activeReferringContent
but log with error (not debug) and rethrow or simply add a throws
JahiaException to these methods
* New method invalidateHtmlCache (refactored from commitChanges)
Revision Changes Path
1.44 +75 -39
jahia/core/src/java/org/jahia/services/pages/ContentPage.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/pages/ContentPage.java.diff?r1=1.43&r2=1.44&f=h
Index: ContentPage.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/pages/ContentPage.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- ContentPage.java 29 Nov 2005 13:12:26 -0000 1.43
+++ ContentPage.java 6 Dec 2005 12:12:34 -0000 1.44
@@ -142,6 +142,15 @@
return null;
}
+ public static ContentObject getChildInstance (String IDInType, boolean
forceLoadFromDB) {
+ try {
+ return getPage (Integer.parseInt (IDInType), true,
forceLoadFromDB);
+ } catch (JahiaException je) {
+ logger.debug ("Error retrieving page instance for id : " +
IDInType, je);
+ }
+ return null;
+ }
+
//-------------------------------------------------------------------------
/**
* ContentPage constructor. This method is responsible for building
@@ -252,6 +261,50 @@
public void setACL(JahiaBaseACL mACL) {
this.mACL = mACL;
}
+
+ /**
+ * Flush all the caches corresponding to a page update (useful for
example when we have
+ * modified a page title that will be display on multiple other pages).
+ *
+ * @throws JahiaException raised if there were problems either updating
+ * the persistant data or flushing the cache.
+ */
+ public synchronized void invalidateHtmlCache() throws JahiaException {
+ // We need to check if there is still some page infos.
+ // it could be empty when called this method after deleting a page
+ // that exists only in staging
+ if (mPageInfos.size() > 0) {
+ // let's flush the cache of all the pages referencing this one.
+ int siteID = getJahiaID();
+ JahiaSite site = ServicesRegistry.getInstance()
+ .getJahiaSitesService().getSite(siteID);
+ if (site == null) {
+ logger.debug("Invalid site for page, cannot flush cache.");
+ } else {
+ Set refPages =
ContentPageXRefManager.getInstance().getPageIDs(
+ getID());
+ Iterator refPagesIter = refPages.iterator();
+
+ // Get the cache instance and invalidate the related page
+ // entries
+ HtmlCache htmlCache = ServicesRegistry.getInstance()
+ .getCacheService().getHtmlCacheInstance();
+ if (htmlCache == null)
+ logger.warn("Could not get the HTML cache instance!!");
+
+ while (refPagesIter.hasNext()) {
+ Integer curPageID = (Integer) refPagesIter.next();
+
+ if (htmlCache != null)
+
htmlCache.invalidatePageEntries(curPageID.toString());
+ }
+ // let's flush this page's cache...
+ if (htmlCache != null)
+
htmlCache.invalidatePageEntries(Integer.toString(getID()));
+ }
+ }
+ }
+
//-------------------------------------------------------------------------
/**
* Commit the changes made in the page object to the database.
@@ -269,37 +322,7 @@
throws JahiaException {
logger.debug ("called.");
if (flushCaches) {
-
- // We need to check if there is still some page infos.
- // it could be empty when called this method after deleting a
page
- //that exists only in staging
- if (mPageInfos.size () > 0) {
- // let's flush the cache of all the pages referencing this
one.
- int siteID = getJahiaID ();
- JahiaSite site = ServicesRegistry.getInstance
().getJahiaSitesService ().getSite (
- siteID);
- if (site == null) {
- logger.debug ("Invalid site for page, cannot flush
cache.");
- } else {
- Set refPages = ContentPageXRefManager.getInstance
().getPageIDs (getID ());
- Iterator refPagesIter = refPages.iterator ();
-
- // Get the cache instance and invalidate the related
page entries
- HtmlCache htmlCache =
ServicesRegistry.getInstance().getCacheService().getHtmlCacheInstance();
- if (htmlCache == null)
- logger.warn ("Could not get the HTML cache
instance!!");
-
- while (refPagesIter.hasNext ()) {
- Integer curPageID = (Integer) refPagesIter.next ();
-
- if (htmlCache != null)
- htmlCache.invalidatePageEntries
(curPageID.toString ());
- }
- // let's flush this page's cache...
- if (htmlCache != null)
- htmlCache.invalidatePageEntries (Integer.toString
(getID ()));
- }
- }
+ invalidateHtmlCache();
}
Iterator pageInfoIter = mPageInfos.iterator ();
@@ -646,16 +669,24 @@
}
}
+ public static synchronized ContentPage getPage(int pageID,
+ boolean withTemplate, boolean forceLoadFromDB)
+ throws JahiaException {
+ return ServicesRegistry.getInstance().getJahiaPageService()
+ .lookupContentPage(pageID, withTemplate, forceLoadFromDB);
+ }
+
+
public static synchronized ContentPage getPage (int pageID, boolean
withTemplate)
throws JahiaException {
return ServicesRegistry.getInstance ().getJahiaPageService
().lookupContentPage (
- pageID, withTemplate);
+ pageID, withTemplate, false);
}
public static synchronized ContentPage getPage (int pageID)
throws JahiaException {
return ServicesRegistry.getInstance ().getJahiaPageService
().lookupContentPage (
- pageID, true);
+ pageID, true, false);
}
/**
@@ -1501,9 +1532,9 @@
// Deleted
Vector langs = this.getSite ().getLanguageSettings ();
SiteLanguageSettings siteLanguageMapping = null;
- Enumeration enumeration = langs.elements ();
- while (enumeration.hasMoreElements ()) {
- siteLanguageMapping = (SiteLanguageSettings)
enumeration.nextElement ();
+ Enumeration langEnum = langs.elements ();
+ while (langEnum.hasMoreElements ()) {
+ siteLanguageMapping = (SiteLanguageSettings)
langEnum.nextElement ();
ContentObjectEntryState entryState =
new ContentObjectEntryState (
ContentObjectEntryState.WORKFLOW_STATE_ACTIVE,
@@ -2776,7 +2807,7 @@
}
private boolean activeNonDeletedEntries (Set languageCodes,
- JahiaSaveVersion saveVersion) {
+ JahiaSaveVersion saveVersion) throws JahiaException {
boolean result = false;
// now we must find which active versions to backup, by figuring
// out what has changed. Here we only do the activation parts. The
@@ -3017,6 +3048,10 @@
}
} catch ( Throwable t ){
logger.debug("Error activating
container list ",t);
+ throw new JahiaException(
+ "Error in workflow,
container list on page can not be activated",
+ "Error activating
container list ", JahiaException.OBJECT_ERROR,
+
JahiaException.ERROR_SEVERITY, t);
}
}
} else {
@@ -3032,7 +3067,7 @@
}
private boolean activeDeletedEntries (Set languageCodes,
- JahiaSaveVersion saveVersion) {
+ JahiaSaveVersion saveVersion) throws JahiaException {
boolean result = false;
// now we must find which active versions to backup, by figuring
// out what has changed.
@@ -3098,9 +3133,10 @@
// too...
pageManager.deletePageInfo (curPageInfo);
} catch (JahiaException je) {
- logger.debug (
+ logger.error (
"Error while trying to activate staging
version",
je);
+ throw je;
}
}
}