mcardle 2005/08/23 18:58:29 CEST
Modified files:
core/src/java/org/jahia/params ParamBean.java
Log:
adds ESI param to URL
Revision Changes Path
1.29 +98 -1 jahia/core/src/java/org/jahia/params/ParamBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/params/ParamBean.java.diff?r1=1.28&r2=1.29&f=h
Index: ParamBean.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/params/ParamBean.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- ParamBean.java 23 Aug 2005 15:54:53 -0000 1.28
+++ ParamBean.java 23 Aug 2005 16:58:29 -0000 1.29
@@ -1790,10 +1790,12 @@
theUrl.append(getSiteURLPart(site.getSiteKey()));
theUrl.append(getOpModeURLPart(opMode));
theUrl.append(getCacheModeURLPart(cacheStatus));
+ theUrl.append(getESITemplParam(pageID));
if (languageCode != null) {
theUrl.append(condAppendURL(LANGUAGE_CODE, languageCode));
}
theUrl.append(getPageURLPart(pageID));
+
try {
return encodeURL(theUrl.toString());
} catch (NullPointerException npe) {
@@ -1801,6 +1803,98 @@
}
}
+
+ public static final String ALL_ESI = "all";
+ public static final String INDIV_ESI = "indiv";
+ public static final String DEFAULT_ESI_USER = ALL_ESI;
+ public static final String DEFAULT_ESI_GROUP = ALL_ESI;
+
+ /**
+ * Return identifier of template used for in ESI caching Hashmap
+ */
+ private String getESITemplParam(int pageID) {
+
+ StringBuffer result = new StringBuffer();
+
+ //-get user ESI key (user either Marc's JahiaUserDB.getUserESIKey or
existing JahiaUSer.hashCode() )
+ //theUser.hashCode();
+ String ESIuserVal = theUser.getName(); //TODO: check user exists -
resolveUser()
+
+ //JahiaPageDefinition template;
+
+ //TODO : Read ESIuser and ESIgroup setting for each template from an
XML
+ String ESIuser = ALL_ESI; //= template.getESIuser(); //note
this will always be null as currently not set in template.xml
+ String ESIgroup = ALL_ESI; //= template.getESIgroup(); //note
this will always be null as currently not set in template.xml
+
+ /*
+ try {
+
+
+ //-get template for current page
+ template =
ServicesRegistry.getInstance().getJahiaPageService().lookupPage(pageID, this)
+ .getPageTemplate();
+ //-generate ESI param (make sure ESI fragments get rid of them)
+
+
+ String tmplName = template.getName();
+ if ( "Home".equals(template.getName()) ) {
+ ESIuser = ALL_ESI;//INDIV_ESI;
+ }
+ else if ( "Default home".equals(template.getName()) ) {
+ ESIuser = ALL_ESI;//INDIV_ESI;
+ }
+ else if ( "Faq".equals(template.getName()) ) {
+ ESIuser = INDIV_ESI;
+ }
+ else if ( "Categories browsing".equals(template.getName()) ) {
+ ESIgroup = "admin";
+ }
+ //Blog - Blog listing - Categories browsing - Directories Files
+ //Directories Links - Directories Main - Directories People
+ //Directories Project - Document Detail - Document Listing
+ //Double - Faq - HTML file clipping - Home - Portal - Simple
+
+ //default behaviour if template has no initial ESI settings
+ else {
+ //do nothing
+ }
+
+
+ } catch (JahiaException e) {
+ //Do something else here, this is a shit way to handle error
+ logger.fatal("Cannot find template for current page");
+ e.printStackTrace();
+ }*/
+
+ //if ESIuser set, then add to result
+ if ( !INDIV_ESI.equals(ESIuser) ) {
+ //result.append("/user/");
+ //result.append(ESIuserVal);
+ result.append("/esi/");
+ result.append("user_" + ESIuserVal);
+ }
+ //if ESIgroup set, then add to result
+ else if ( !ALL_ESI.equals(ESIgroup) ) {
+ if ( theUser.isMemberOfGroup(siteID,ESIgroup) ) {
+ //result.append("/group/");
+ //result.append(ESIgroup);
+ result.append("/esi/");//shouldn't have both group and
user set at same time, so no need for check
+ result.append("group_" + ESIgroup);
+ }
+ }
+ else return ""; //return empty string if no ESI params present
for current page's template
+
+ return result.toString();
+
+ //TODO: add ESI tag generation to other URL composition fcts such as
compuseEngineURL
+
+ //-get template ESI settings from XML file (need to read it once and
save it in memory)
+ //-check that ESI template settings are correct: i.e. user has access
to template
+ //and belongs to specified group (if applicable
+ //--------> ABOVE is all done in JahiaPageDefinition
+
+ }
+
/**
* Deprecated
* returns the url of the page whose id is given as parameter
@@ -2566,7 +2660,10 @@
//-------------------------------------------------------------------------
// SH 12 Oct. 2001 : Original implementation
protected final String getCacheModeURLPart (String mode) {
- return condAppendURL(CACHE_MODE_PARAMETER, mode);
+ //Ignore cache mode URL parameter when ESI is active
+ if (!settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED)) {
+ return condAppendURL(CACHE_MODE_PARAMETER, mode);
+ } else return "";
}
//--------------------------------------------------------------------------