bpapez 2005/12/06 13:11:25 CET
Modified files:
core/src/java/org/jahia/services/pages
JahiaPageBaseService.java
JahiaPageService.java
Log:
add lookupContentPage methods with forceLoadFromDB parameter
Revision Changes Path
1.25 +106 -46
jahia/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java.diff?r1=1.24&r2=1.25&f=h
1.9 +26 -0
jahia/core/src/java/org/jahia/services/pages/JahiaPageService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/pages/JahiaPageService.java.diff?r1=1.8&r2=1.9&f=h
Index: JahiaPageBaseService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- JahiaPageBaseService.java 22 Nov 2005 18:01:44 -0000 1.24
+++ JahiaPageBaseService.java 6 Dec 2005 12:11:24 -0000 1.25
@@ -1587,7 +1587,7 @@
JahiaPageNotFoundException,
JahiaTemplateNotFoundException {
return lookupContentPage(pageID, EntryLoadRequest.CURRENT,
- withTemplates);
+ withTemplates, false);
}
/**
@@ -1596,6 +1596,30 @@
* language version of a page.
*
* @param pageID the identifier of the page to load.
+ * @param withTemplates specifies whether page templates should be also
+ * loaded or not.
+ * @param forceLoadFromDB false if page can be read from cache
+ * @return a ContentPage object.
+ * @throws JahiaException
+ * @throws JahiaPageNotFoundException
+ * @throws JahiaTemplateNotFoundException
+ */
+ public ContentPage lookupContentPage (int pageID,
+ boolean withTemplates,
+ boolean forceLoadFromDB)
+ throws JahiaException,
+ JahiaPageNotFoundException,
+ JahiaTemplateNotFoundException {
+ return lookupContentPage(pageID, EntryLoadRequest.CURRENT,
+ withTemplates, forceLoadFromDB);
+ }
+
+ /**
+ * Retrieves the page content object, that represents all the page
versions
+ * both active and staging. This object also contains all the multiple
+ * language version of a page.
+ *
+ * @param pageID the identifier of the page to load.
* @param loadRequest specifies the EntryLoadRequest to specify which
* contains the entry to be loaded, such as
deleted, versioned (with
* version ID, etc...)
@@ -1612,27 +1636,62 @@
throws JahiaException,
JahiaPageNotFoundException,
JahiaTemplateNotFoundException {
- //logger.debug(" lookup page id=" + pageID );
+ return lookupContentPage(pageID, loadRequest,
+ withTemplates, false);
+ }
+
+ /**
+ * Retrieves the page content object, that represents all the page
+ * versions both active and staging. This object also contains all the
+ * multiple language version of a page.
+ *
+ * @param pageID
+ * the identifier of the page to load.
+ * @param loadRequest
+ * specifies the EntryLoadRequest to specify which contains
+ * the entry to be loaded, such as deleted, versioned (with
+ * version ID, etc...)
+ * @param withTemplates
+ * specifies whether page templates should be also loaded or
+ * not.
+ * @param forceLoadFromDB
+ * false if page can be read from cache
+ * @return a ContentPage object.
+ * @throws JahiaException
+ * @throws JahiaPageNotFoundException
+ * @throws JahiaTemplateNotFoundException
+ */
+ public ContentPage lookupContentPage(int pageID,
+ EntryLoadRequest loadRequest, boolean withTemplates,
+ boolean forceLoadFromDB) throws JahiaException,
+ JahiaPageNotFoundException, JahiaTemplateNotFoundException {
+ ContentPage contentPage = null;
Integer entryKey = new Integer(pageID);
- ContentPage contentPage = (ContentPage)
mContentPageCache.get(entryKey);
+
+ if (!forceLoadFromDB) {
+ contentPage = (ContentPage) mContentPageCache.get(entryKey);
+ }
+
if (contentPage != null) {
JahiaBaseACL acl = new JahiaBaseACL(contentPage.getAclID());
if (acl == null) {
- throw new JahiaException("Page ACL not found.",
- "The ACL [" +
contentPage.getAclID() +
- "] could not be found in the" +
- " database for page [" + pageID +
"]",
- JahiaException.PAGE_ERROR,
- JahiaException.ERROR_SEVERITY);
+ throw new JahiaException("Page ACL not found.", "The ACL ["
+ + contentPage.getAclID()
+ + "] could not be found in the"
+ + " database for page [" + pageID + "]",
+ JahiaException.PAGE_ERROR,
+ JahiaException.ERROR_SEVERITY);
}
contentPage.setACL(acl);
return contentPage;
}
// Get the raw page infos
- List activePageInfoVector = lookupPageInfos(pageID,
EntryLoadRequest.CURRENT);
- List archivePageInfoVector = lookupPageInfos(pageID,
EntryLoadRequest.VERSIONED);
+ List activePageInfoVector = lookupPageInfos(pageID,
+ EntryLoadRequest.CURRENT);
+ List archivePageInfoVector = lookupPageInfos(pageID,
+ EntryLoadRequest.VERSIONED);
if (archivePageInfoVector == null) {
archivePageInfoVector = new Vector();
}
@@ -1641,12 +1700,12 @@
throw new JahiaPageNotFoundException(pageID);
}
- if (activePageInfoVector.size() == 0 &&
- archivePageInfoVector.size() == 0) {
+ if (activePageInfoVector.size() == 0
+ && archivePageInfoVector.size() == 0) {
throw new JahiaPageNotFoundException(pageID);
}
- if(loadRequest.isStaging() && activePageInfoVector.size()==0) {
+ if (loadRequest.isStaging() && activePageInfoVector.size() == 0) {
throw new JahiaPageNotFoundException(pageID);
}
@@ -1654,41 +1713,41 @@
pageInfoVector.addAll(activePageInfoVector);
pageInfoVector.addAll(archivePageInfoVector);
- JahiaPageInfo sharedPageInfo = (JahiaPageInfo)
pageInfoVector.elementAt(
- 0);
-//
-//
//////////////////////////////////////////////////////////////////////////////////////
-// // FIXME -Fulco-
-// //
-// // this check should be removed the day we decide to make of
links real objects and
-// // not a special case of a page.
-// //
-//
//////////////////////////////////////////////////////////////////////////////////////
-//
-// // If the page is of DIRECT type, try to get the page Template
-// // reference. If the page is not of this type, the page template
-// // is not needed and so the page template reference will be set to
null.
-// JahiaPageDefinition pageTemplate = null;
-//
-// if (withTemplates) { // AK. only if templates are requested.
-// int pageType = sharedPageInfo.getPageType();
-// if ((pageType == JahiaPageInfo.TYPE_DIRECT) ||
-// (pageType == JahiaPageInfo.TYPE_LINK)) {
-// pageTemplate = templateService.lookupPageTemplate(
-// sharedPageInfo.getPageTemplateID());
-// }
-// }
+ JahiaPageInfo sharedPageInfo = (JahiaPageInfo) pageInfoVector
+ .elementAt(0);
+ //
+ //
//////////////////////////////////////////////////////////////////////////////////////
+ // // FIXME -Fulco-
+ // //
+ // // this check should be removed the day we decide to make of links
+ // real objects and
+ // // not a special case of a page.
+ // //
+ //
//////////////////////////////////////////////////////////////////////////////////////
+ //
+ // // If the page is of DIRECT type, try to get the page Template
+ // // reference. If the page is not of this type, the page template
+ // // is not needed and so the page template reference will be set to
+ // null.
+ // JahiaPageDefinition pageTemplate = null;
+ //
+ // if (withTemplates) { // AK. only if templates are requested.
+ // int pageType = sharedPageInfo.getPageType();
+ // if ((pageType == JahiaPageInfo.TYPE_DIRECT) ||
+ // (pageType == JahiaPageInfo.TYPE_LINK)) {
+ // pageTemplate = templateService.lookupPageTemplate(
+ // sharedPageInfo.getPageTemplateID());
+ // }
+ // }
// Get the ACL object associated to the page, if the ACL is not
found,
// report the error.
JahiaBaseACL acl = new JahiaBaseACL(sharedPageInfo.getAclID());
if (acl == null) {
- throw new JahiaException("Page ACL not found.",
- "The ACL [" + sharedPageInfo.getAclID()
+
- "] could not be found in the" +
- " database for page [" + pageID + "]",
- JahiaException.PAGE_ERROR,
- JahiaException.ERROR_SEVERITY);
+ throw new JahiaException("Page ACL not found.", "The ACL ["
+ + sharedPageInfo.getAclID() + "] could not be found in
the"
+ + " database for page [" + pageID + "]",
+ JahiaException.PAGE_ERROR,
JahiaException.ERROR_SEVERITY);
}
// Looks like everything is going well, let's create the page facade
!
@@ -1697,8 +1756,9 @@
return contentPage;
}
-
//-------------------------------------------------------------------------
- // AK 03.05.2001 lookup page whitout checks on templates... by passing
new boolean (false).
+ //
-------------------------------------------------------------------------
+ // AK 03.05.2001 lookup page whitout checks on templates... by passing
new
+ // boolean (false).
public JahiaPage lookupPage(int pageID, EntryLoadRequest loadRequest,
String operationMode, JahiaUser user,
boolean withTemplates)
Index: JahiaPageService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/pages/JahiaPageService.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JahiaPageService.java 19 Aug 2005 15:53:49 -0000 1.8
+++ JahiaPageService.java 6 Dec 2005 12:11:24 -0000 1.9
@@ -598,6 +598,32 @@
* language version of a page.
*
* @param pageID the identifier of the page to load.
+
+
+
+ * @param withTemplates specifies whether page templates should be also
+ * loaded or not.
+ * @param forceLoadFromDB false if page can be read from cache
+ *
+ * @return a ContentPage object.
+ *
+ * @throws JahiaException
+ * @throws JahiaPageNotFoundException
+ * @throws JahiaTemplateNotFoundException
+ */
+ public abstract ContentPage lookupContentPage (int pageID,
+ boolean withTemplates, boolean forceLoadFromDB)
+ throws JahiaException,
+ JahiaPageNotFoundException,
+ JahiaTemplateNotFoundException;
+
+
+ /**
+ * Retrieves the page content object, that represents all the page
versions
+ * both active and staging. This object also contains all the multiple
+ * language version of a page.
+ *
+ * @param pageID the identifier of the page to load.
* @param loadRequest specifies the EntryLoadRequest to specify which
* contains the entry to be loaded, such as
deleted, versioned (with
* version ID, etc...)