mcardle 2005/12/22 13:32:20 CET
Modified files:
core/src/java/org/jahia/operations/valves
EsiUrlCookieCheckValve.java
core/src/java/org/jahia/params ParamBean.java
ProcessingContext.java
core/src/java/org/jahia/services/esi EsiInvalidation.java
Log:
* support for UrlKeys in page URLs while using ESI caching (and resolves
http://www.jahia.org/jira/browse/ESI-3) . Jahia's URL generation algo was
changed so that the UrlKeys appear at the end of the URL just as the /pid/xx
does (now). It is imperative to respect this naming convention for
invalidations to work with ESI.
Revision Changes Path
1.6 +11 -2
jahia/core/src/java/org/jahia/operations/valves/EsiUrlCookieCheckValve.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/operations/valves/EsiUrlCookieCheckValve.java.diff?r1=1.5&r2=1.6&f=h
1.46 +30 -33 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.45&r2=1.46&f=h
1.20 +30 -35
jahia/core/src/java/org/jahia/params/ProcessingContext.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/params/ProcessingContext.java.diff?r1=1.19&r2=1.20&f=h
1.9 +78 -30
jahia/core/src/java/org/jahia/services/esi/EsiInvalidation.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/EsiInvalidation.java.diff?r1=1.8&r2=1.9&f=h
Index: EsiUrlCookieCheckValve.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/operations/valves/EsiUrlCookieCheckValve.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EsiUrlCookieCheckValve.java 24 Nov 2005 14:33:59 -0000 1.5
+++ EsiUrlCookieCheckValve.java 22 Dec 2005 12:32:18 -0000 1.6
@@ -12,6 +12,7 @@
import org.jahia.params.ProcessingContext;
import org.jahia.params.ParamBean;
import org.jahia.settings.SettingsBean;
+import org.jahia.taglibs.esi.JesiConst;
import java.net.URL;
import java.net.MalformedURLException;
@@ -135,10 +136,18 @@
String reqUrl = (String)
paramBean.getRealRequest().getAttribute("esi.request.url");
if (reqUrl!=null ) {
- int pos = reqUrl.indexOf("/jesi/");
+ String jesiMarker = "/"+ JesiConst.ESI_MARKER+"/";
+ int pos = reqUrl.indexOf(jesiMarker);
if (pos!=-1) {
- int posSlash = reqUrl.indexOf("/", pos +
"/jesi/".length() );
+ int posSlash = reqUrl.indexOf("/", pos +
jesiMarker.length() );
+ //for URLs of the form
http://localhost:8081/jahia/Jahia/jesi/user_root%3A1?name=val
+ if (posSlash==-1) {
+ posSlash = reqUrl.indexOf("?", pos +
jesiMarker.length() );
+ //for URLs of the form
http://localhost:8081/jahia/Jahia/jesi/user_root%3A1
+ if (posSlash==-1)
+ posSlash = reqUrl.length();
+ }
String currentUrlEsiMarker = reqUrl.substring(pos,
posSlash);
if (currentUrlEsiMarker==null)
Index: ParamBean.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/params/ParamBean.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- ParamBean.java 15 Dec 2005 16:35:38 -0000 1.45
+++ ParamBean.java 22 Dec 2005 12:32:19 -0000 1.46
@@ -1,3 +1,7 @@
+/*
+ * Copyright (c) 2005, Your Corporation. All Rights Reserved.
+ */
+
//
// ____.
// __/\ ______| |__/\. _______
@@ -123,6 +127,7 @@
import org.jahia.tools.files.FileUpload;
import org.jahia.utils.JahiaTools;
import org.jahia.utils.LanguageCodeConverters;
+import org.jahia.taglibs.esi.JesiConst;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -1477,7 +1482,6 @@
try {
final StringTokenizer st = new StringTokenizer(pathInfo,
"/");
- boolean inPageResolving = true;
while (st.hasMoreTokens()) {
final String token = st.nextToken();
if (ENGINE_NAME_PARAMETER.equals(token) ||
@@ -1495,17 +1499,17 @@
RELEASE_LOCK.equals(token) ||
STEAL_LOCK.equals(token) ||
TEMPLATE_PARAMETER.equals(token) ||
- CACHE_MODE_PARAMETER.equals(token)) {
- inPageResolving = false;
+ CACHE_MODE_PARAMETER.equals(token) ||
+ JesiConst.ESI_MARKER.equals(token)
+ ) {
String[] paramValues = new String[1];
paramValues[0] = st.nextToken();
getCustomParameters().put(token, paramValues);
} else if
(token.startsWith(CONTAINER_SCROLL_PREFIX_PARAMETER)) {
- inPageResolving = false;
String[] paramValues = new String[1];
paramValues[0] = st.nextToken();
getCustomParameters().put(token, paramValues);
- } else if (inPageResolving) {
+ } else {
pageURLKeys.add(token);
}
}
@@ -1772,17 +1776,16 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(site.getSiteKey()));
theUrl.append(getOpModeURLPart(opMode));
theUrl.append(getCacheModeURLPart(cacheStatus));
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser, siteID));
//theUrl.append (getLastRequestedPageURLPart (thePage.getID()));
- if (contentPage != null)
+ if (contentPage != null) {
theUrl.append(getPageURLPart(contentPage.getID()));
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
+ }
appendParams(theUrl, params);
@@ -1810,7 +1813,6 @@
throws JahiaException {
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(pageID));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(site.getSiteKey()));
theUrl.append(getOpModeURLPart(opMode));
@@ -1820,6 +1822,7 @@
theUrl.append(condAppendURL(LANGUAGE_CODE, languageCode));
}
theUrl.append(getPageURLPart(pageID));
+ theUrl.append(getPageURLKeyPart(pageID));
try {
return encodeURL(theUrl.toString());
@@ -1854,18 +1857,16 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
if (engineName != null) {
theUrl.append(getEngineURLPart(engineName));
}
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(opMode));
- if (contentPage != null)
+ if (contentPage != null) {
theUrl.append(getPageURLPart(contentPage.getID()));
-
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
+ }
appendAnchor(theUrl);
return encodeURL(theUrl.toString());
@@ -1885,9 +1886,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
//logger.debug("jahiaCoreHttpPath="+theUrl.toString());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
if (engineName != null) {
theUrl.append(getEngineURLPart(engineName));
}
@@ -1895,8 +1893,10 @@
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(opMode));
- if (contentPage != null)
+ if (contentPage != null) {
theUrl.append(getPageURLPart(contentPage.getID()));
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
+ }
appendParams(theUrl, params);
@@ -2196,9 +2196,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
if (operationMode != null) {
@@ -2213,8 +2210,10 @@
else
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser,
siteID));
- if (contentPage != null)
+ if (contentPage != null) {
theUrl.append(getPageURLPart(contentPage.getID()));
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
+ }
appendParams(theUrl, params);
@@ -2238,9 +2237,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
if (operationMode != null) {
@@ -2261,6 +2257,7 @@
}
theUrl.append(this.getShowRevisionDiffURLPart(revisionDiffID));
theUrl.append(getPageURLPart(contentPage.getID()));
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
}
appendParams(theUrl, params);
return encodeURL(theUrl.toString());
@@ -2274,9 +2271,7 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (contentPage != null) {
- theUrl.append(getPageURLKeyPart(contentPage.getID()));
- }
+
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(this.opMode));
@@ -2286,8 +2281,10 @@
else
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser,
siteID));
- if (contentPage != null)
+ if (contentPage != null) {
theUrl.append(getPageURLPart(contentPage.getID()));
+ theUrl.append(getPageURLKeyPart(contentPage.getID()));
+ }
return encodeURL(theUrl.toString());
}
@@ -2328,12 +2325,12 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(site.getHomePageID()));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(site.getSiteKey()));
theUrl.append(getOpModeURLPart(ParamBean.NORMAL));
theUrl.append(EsiURLGenerator.getESITemplURLPart(site.getHomePageID(), this,
theUser, site.getID()));
theUrl.append(getPageURLPart(site.getHomePageID()));
+ theUrl.append(getPageURLKeyPart(site.getHomePageID()));
return encodeURL(theUrl.toString());
}
@@ -2348,12 +2345,12 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(this.site.getHomePageID()));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(this.site.getSiteKey()));
theUrl.append(getOpModeURLPart(ParamBean.NORMAL));
theUrl.append(EsiURLGenerator.getESITemplURLPart(site.getHomePageID(), this,
theUser, siteID));
theUrl.append(getPageURLPart(this.site.getHomePageID()));
+ theUrl.append(getPageURLKeyPart(this.site.getHomePageID()));
return encodeURL(theUrl.toString());
}
@@ -2553,7 +2550,7 @@
}
- protected final String getPageURLKeyPart(final int id) {
+ public final String getPageURLKeyPart(final int id) {
// first we must find all parent pages and their URL keys.
final StringBuffer pageURLKeysPartBuf = new StringBuffer();
final LinkedList pageURLKeys = new LinkedList();
Index: ProcessingContext.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/params/ProcessingContext.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ProcessingContext.java 15 Dec 2005 16:35:38 -0000 1.19
+++ ProcessingContext.java 22 Dec 2005 12:32:19 -0000 1.20
@@ -1,3 +1,7 @@
+/*
+ * Copyright (c) 2005, Your Corporation. All Rights Reserved.
+ */
+
//
// ____.
// __/\ ______| |__/\. _______
@@ -116,6 +120,7 @@
import org.jahia.services.version.StateModificationContext;
import org.jahia.settings.SettingsBean;
import org.jahia.utils.LanguageCodeConverters;
+import org.jahia.taglibs.esi.JesiConst;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
@@ -1311,7 +1316,6 @@
try {
final StringTokenizer st = new StringTokenizer(pathInfo,
"/");
- boolean inPageResolving = true;
while (st.hasMoreTokens()) {
final String token = st.nextToken();
if (ENGINE_NAME_PARAMETER.equals(token) ||
@@ -1329,17 +1333,17 @@
RELEASE_LOCK.equals(token) ||
STEAL_LOCK.equals(token) ||
TEMPLATE_PARAMETER.equals(token) ||
- CACHE_MODE_PARAMETER.equals(token)) {
- inPageResolving = false;
+ CACHE_MODE_PARAMETER.equals(token)||
+ JesiConst.ESI_MARKER.equals(token)
+ ) {
String[] paramValues = new String[1];
paramValues[0] = st.nextToken();
getCustomParameters().put(token, paramValues);
} else if
(token.startsWith(CONTAINER_SCROLL_PREFIX_PARAMETER)) {
- inPageResolving = false;
String[] paramValues = new String[1];
paramValues[0] = st.nextToken();
getCustomParameters().put(token, paramValues);
- } else if (inPageResolving) {
+ } else {
getPageURLKeys().add(token);
}
}
@@ -1593,17 +1597,16 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(getSite().getSiteKey()));
theUrl.append(getOpModeURLPart(getOpMode()));
theUrl.append(getCacheModeURLPart(cacheStatus));
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser, siteID));
//theUrl.append (getLastRequestedPageURLPart (thePage.getID()));
- if (getContentPage() != null)
+ if (getContentPage() != null) {
theUrl.append(getPageURLPart(getContentPage().getID()));
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
+ }
appendParams(theUrl, params);
@@ -1630,7 +1633,6 @@
throws JahiaException {
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(pageID));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(getSite().getSiteKey()));
theUrl.append(getOpModeURLPart(getOpMode()));
@@ -1640,6 +1642,7 @@
theUrl.append(condAppendURL(LANGUAGE_CODE, languageCode));
}
theUrl.append(getPageURLPart(pageID));
+ theUrl.append(getPageURLKeyPart(pageID));
try {
return encodeURL(theUrl.toString());
} catch (NullPointerException npe) {
@@ -1651,7 +1654,6 @@
throws JahiaException {
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(page));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(getSite().getSiteKey()));
theUrl.append(getOpModeURLPart(getOpMode()));
@@ -1661,6 +1663,7 @@
theUrl.append(condAppendURL(LANGUAGE_CODE, languageCode));
}
theUrl.append(getPageURLPart(page));
+ theUrl.append(getPageURLKeyPart(page));
try {
return encodeURL(theUrl.toString());
} catch (NullPointerException npe) {
@@ -1696,17 +1699,16 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
if (engineName != null) {
theUrl.append(getEngineURLPart(engineName));
}
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(getOpMode()));
- if (getContentPage() != null)
+ if (getContentPage() != null) {
theUrl.append(getPageURLPart(getContentPage().getID()));
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
+ }
appendAnchor(theUrl);
@@ -1727,9 +1729,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
//logger.debug("jahiaCoreHttpPath="+theUrl.toString());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
if (engineName != null) {
theUrl.append(getEngineURLPart(engineName));
}
@@ -1737,9 +1736,10 @@
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(getOpMode()));
- if (getContentPage() != null)
+ if (getContentPage() != null) {
theUrl.append(getPageURLPart(getContentPage().getID()));
-
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
+ }
appendParams(theUrl, params);
appendAnchor(theUrl);
@@ -2042,9 +2042,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
if (operationMode != null) {
@@ -2059,9 +2056,10 @@
else
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser,
siteID));
- if (getContentPage() != null)
+ if (getContentPage() != null) {
theUrl.append(getPageURLPart(getContentPage().getID()));
-
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
+ }
appendParams(theUrl, params);
return encodeURL(theUrl.toString());
@@ -2084,9 +2082,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
if (operationMode != null) {
@@ -2107,6 +2102,7 @@
}
theUrl.append(this.getShowRevisionDiffURLPart(revisionDiffID));
theUrl.append(getPageURLPart(getContentPage().getID()));
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
}
appendParams(theUrl, params);
return encodeURL(theUrl.toString());
@@ -2120,9 +2116,6 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- if (getContentPage() != null) {
- theUrl.append(getPageURLKeyPart(getContentPage().getID()));
- }
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart());
theUrl.append(getOpModeURLPart(this.getOpMode()));
@@ -2133,8 +2126,10 @@
else
theUrl.append(EsiURLGenerator.getESIURLPart(this, theUser,
siteID));
- if (getContentPage() != null)
+ if (getContentPage() != null) {
theUrl.append(getPageURLPart(getContentPage().getID()));
+ theUrl.append(getPageURLKeyPart(getContentPage().getID()));
+ }
return encodeURL(theUrl.toString());
}
@@ -2175,12 +2170,12 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(site.getHomePageID()));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(site.getSiteKey()));
theUrl.append(getOpModeURLPart(ProcessingContext.NORMAL));
theUrl.append(EsiURLGenerator.getESITemplURLPart(site.getHomePageID(), this,
theUser, site.getID()));
theUrl.append(getPageURLPart(site.getHomePageID()));
+ theUrl.append(getPageURLKeyPart(site.getHomePageID()));
return encodeURL(theUrl.toString());
}
@@ -2196,12 +2191,12 @@
final StringBuffer theUrl = new StringBuffer();
theUrl.append(this.getJahiaCoreHttpPath());
- theUrl.append(getPageURLKeyPart(this.getSite().getHomePageID()));
theUrl.append(getEngineURLPart(CORE_ENGINE_NAME));
theUrl.append(getSiteURLPart(this.getSite().getSiteKey()));
theUrl.append(getOpModeURLPart(ProcessingContext.NORMAL));
theUrl.append(EsiURLGenerator.getESITemplURLPart(site.getHomePageID(), this,
theUser, siteID));
theUrl.append(getPageURLPart(this.getSite().getHomePageID()));
+ theUrl.append(getPageURLKeyPart(this.getSite().getHomePageID()));
return encodeURL(theUrl.toString());
}
@@ -2426,7 +2421,7 @@
}
- protected String getPageURLKeyPart(final int id) {
+ public String getPageURLKeyPart(final int id) {
// first we must find all parent pages and their URL keys.
final StringBuffer pageURLKeysPartBuf = new StringBuffer();
final LinkedList pageURLKeys = new LinkedList();
Index: EsiInvalidation.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiInvalidation.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EsiInvalidation.java 8 Dec 2005 14:18:26 -0000 1.8
+++ EsiInvalidation.java 22 Dec 2005 12:32:19 -0000 1.9
@@ -5,7 +5,6 @@
import org.jahia.params.ParamBean;
import org.jahia.settings.SettingsBean;
import org.jahia.bin.Jahia;
-import org.apache.commons.lang.StringUtils;
import java.util.HashMap;
import java.util.regex.PatternSyntaxException;
@@ -135,8 +134,12 @@
* @param removalTTL maximum Time-to-Live in secs of invalidated
Fragment on ESI server, i.e. period the stale Fragment can be served while it
is being regenerated
* @return Fragment invalidation string
*/
- public static String getFragmentInvalidationString (final String
uriPrefix, final String[] hosts,
- final String[]
ports, final String pid, final String fragID,
+ public static String getFragmentInvalidationString (ParamBean paramBean,
+ final String
uriPrefix,
+ final String[] hosts,
+ final String[] ports,
+ final String pid,
+ final String fragID,
final String
removalTTL) {
StringBuffer str = new StringBuffer();
@@ -145,6 +148,20 @@
//host = http://192.168.2.178
//port = 7779
+ //are we dealing with a /pid/xx url format or does the page have a
UrlKey?
+ //if so, make sure we invalidate it via its UrlKey
+ logger.info("pid: " + pid);
+ String pageURLKeyPart =
paramBean.getPageURLKeyPart(Integer.parseInt(pid));
+ logger.info("pageURLKeyPart: " + pageURLKeyPart);
+ String pageMarker = pid;
+ String pagePrefix = "/pid/";
+ if (!"".equals(pageURLKeyPart)) {
+ pageMarker = pageURLKeyPart;
+ pagePrefix = "";
+ }
+ logger.info("pageMarker: " + pageMarker);
+ logger.info("pagePrefix: " + pagePrefix);
+
//cycle through each IP/Port combination declared for the current
instance of Jahia
//and create an invalidation entry for each combo:
for (int i = 0; i < hosts.length; i++) {
@@ -154,19 +171,23 @@
str.append("<ADVANCEDSELECTOR
URIPREFIX=\"").append(uriPrefix).append(extraSlash+"\" HOST=\"")
.append(hosts[i]).append(":").append(ports[i]).append("\"");
//make sure this is a fragment i.e. it contains "__esi_fragment"
- str.append( "
URIEXP=\"/pid/").append(pid).append("\\?__esi_fragment=").append(fragID).append("\"
> \n");
+ str.append( "
URIEXP=\"").append(pagePrefix).append(pageMarker).append("\\?__esi_fragment=").append(fragID).append("\"
> \n");
//str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\" VALUE=\"/pid/"
+ pid + "[^0-9]\"/> ");
str.append("</ADVANCEDSELECTOR> \n");
str.append("<ACTION
REMOVALTTL=\"").append(removalTTL).append("\" /> \n");
- str.append("<INFO
VALUE=\"remove-Fragment-on-PID-").append(pid).append("-FID-").append(fragID).append("\"/>
\n");
+ str.append("<INFO
VALUE=\"remove-Fragment-on-PID-").append(pageMarker).append("-FID-").append(fragID).append("\"/>
\n");
str.append("</OBJECT> \n");
}
return str.toString();
}
- public static String getFragmentInvalidationString(final String
uriPrefix, final String[] hosts, final String[] ports, final String pid,
+ public static String getFragmentInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
+ final String[] hosts,
+ final String[] ports,
+ final String pid,
final String fragID) {
- return getFragmentInvalidationString( uriPrefix, hosts, ports, pid,
fragID, "0");
+ return getFragmentInvalidationString(paramBean, uriPrefix, hosts,
ports, pid, fragID, "0");
}
/**
@@ -174,17 +195,19 @@
* SettingsBean (delcared in jahia.properties)
*
*/
- public static String getFragmentInvalidationString(final String
uriPrefix, final String pid,
+ public static String getFragmentInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
+ final String pid,
final String fragID) {
- return getFragmentInvalidationString( uriPrefix, EsiServerIPs,
EsiServerPorts, pid, fragID, "0");
+ return getFragmentInvalidationString(paramBean, uriPrefix,
EsiServerIPs, EsiServerPorts, pid, fragID, "0");
}
/**
* Invalidate only the fragment from a specific ESI Server address
* */
- public static String getFragmentInvalidationString(final String
uriPrefix, final String host, final String port, final String pid,
+ public static String getFragmentInvalidationString(ParamBean paramBean,
final String uriPrefix, final String host, final String port, final String pid,
final String fragID) {
- return getFragmentInvalidationString( uriPrefix, new String[]{host},
new String[]{port}, pid, fragID, "0");
+ return getFragmentInvalidationString(paramBean, uriPrefix, new
String[]{host}, new String[]{port}, pid, fragID, "0");
}
/**
@@ -197,8 +220,12 @@
* @param removalTTL maximum Time-to-Live in secs of invalidated
Template on ESI server, i.e. period the stale Template can be served while it
is being regenerated
* @return Fragment invalidation string
*/
- public static String getTemplateInvalidationString(final String
uriPrefix, final String[] hosts, final String ports[],
- final String pid,
final String removalTTL) {
+ public static String getTemplateInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
+ final String[] hosts,
+ final String ports[],
+ final String pid,
+ final String
removalTTL) {
StringBuffer str = new StringBuffer();
@@ -217,47 +244,67 @@
//(pid/[0-9]*)(\?[^_]|[/\s\r$\n])
//pid/[0-9]*(\?[^_]|[/\s])
- //cycle through each IP/Port combination declared for the current
instance of Jahia
- //and create an invalidation entry for each combo:
- for (int i = 0; i < hosts.length; i++) {
+ //are we dealing with a /pid/xx url format or does the page have a
UrlKey?
+ //if so, make sure we invalidate it via its UrlKey
+ String pageURLKeyPart =
paramBean.getPageURLKeyPart(Integer.parseInt(pid));
+ logger.info("pid: " + pid);
+ logger.info("pageURLKeyPart: " + pageURLKeyPart);
+ String pageMarker = pid;
+ String pagePrefix = "/pid/";
+ if (!"".equals(pageURLKeyPart)) {
+ pageMarker = pageURLKeyPart;
+ pagePrefix = "";
+ }
+ logger.info("pageMarker: " + pageMarker);
+ logger.info("pagePrefix: " + pagePrefix);
+
+ //cycle through each IP/Port combination declared for the
current instance of Jahia
+ //and create an invalidation entry for each combo:
+ for (int i = 0; i < hosts.length; i++) {
str.append("<OBJECT> \n");
str.append("<ADVANCEDSELECTOR
URIPREFIX=\"").append(uriPrefix).append("/\"
HOST=\"").append(hosts[i]).append(":").append(ports[i]).append("\" > \n");
- str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"/pid/").append(pid).append("$\"/> \n");
+ str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"").append(pagePrefix).append(pageMarker).append("$\"/> \n");
str.append("</ADVANCEDSELECTOR> \n");
str.append("<ACTION
REMOVALTTL=\"").append(removalTTL).append("\" /> \n");
- str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pid).append("-InvType_1of3\"/> \n");
+ str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pageMarker).append("-InvType_1of3\"/>
\n");
str.append("</OBJECT> \n");
str.append("<OBJECT> \n");
str.append("<ADVANCEDSELECTOR
URIPREFIX=\"").append(uriPrefix).append("/\"
HOST=\"").append(hosts[i]).append(":").append(ports[i]+"\" > \n");
- str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"/pid/").append(pid).append("/$\"/> \n");
+ str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"").append(pagePrefix).append(pageMarker).append("/$\"/> \n");
str.append("</ADVANCEDSELECTOR> \n");
str.append("<ACTION
REMOVALTTL=\"").append(removalTTL).append("\" /> \n");
- str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pid).append("-InvType_2of3\"/> \n");
+ str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pageMarker).append("-InvType_2of3\"/>
\n");
str.append("</OBJECT> \n");
str.append("<OBJECT> \n");
str.append("<ADVANCEDSELECTOR
URIPREFIX=\"").append(uriPrefix).append("/\" HOST=\"").append(hosts[i]
).append(":").append(ports[i]).append("\" > \n");
- str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"/pid/").append(pid).append("\\?[^_]\"/> \n");
+ str.append("<OTHER NAME=\"URI\" TYPE=\"REGEX\"
VALUE=\"").append(pagePrefix).append(pageMarker).append("\\?[^_]\"/> \n");
str.append("</ADVANCEDSELECTOR> \n");
str.append("<ACTION
REMOVALTTL=\"").append(removalTTL).append("\" /> \n");
- str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pid).append("-InvType_3of3\"/> \n");
+ str.append("<INFO
VALUE=\"remove-Template-on-PID-").append(pageMarker).append("-InvType_3of3\"/>
\n");
str.append("</OBJECT> \n");
}
return str.toString();
}
- public static String getTemplateInvalidationString(final String
uriPrefix, final String[] hosts, final String ports[],
+ public static String getTemplateInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
+ final String[] hosts,
+ final String ports[],
final String pid) {
- return getTemplateInvalidationString( uriPrefix, hosts, ports, pid,
"0");
+ return getTemplateInvalidationString(paramBean, uriPrefix, hosts,
ports, pid, "0");
}
/**
* Invalidate only the template from a specific ESI Server address
* */
- public static String getTemplateInvalidationString(final String
uriPrefix, final String host, final String port,
+ public static String getTemplateInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
+ final String host,
+ final String port,
final String pid) {
- return getTemplateInvalidationString(uriPrefix, new String[]{host} ,
new String[]{port},pid, "0");
+ return getTemplateInvalidationString(paramBean, uriPrefix, new
String[]{host} , new String[]{port},pid, "0");
}
/**
@@ -265,10 +312,11 @@
* SettingsBean (delcared in jahia.properties)
*
*/
- public static String getTemplateInvalidationString(final String
uriPrefix,
+ public static String getTemplateInvalidationString(ParamBean paramBean,
+ final String
uriPrefix,
final String pid) {
- return getTemplateInvalidationString(uriPrefix, EsiServerIPs ,
EsiServerPorts,pid, "0");
+ return getTemplateInvalidationString(paramBean, uriPrefix,
EsiServerIPs , EsiServerPorts,pid, "0");
}
/**
@@ -318,7 +366,7 @@
logger.debug("[esi]: Template URL to Invalidate : "
+ tpl.URL);
str.append(
- getTemplateInvalidationString(tpl.prefix,
Integer.toString(tpl.pageID))
+ getTemplateInvalidationString(paramBean,
tpl.prefix, Integer.toString(tpl.pageID))
);
//getTemplateInvalidationString(tpl.prefix, tpl.host,
tpl.port, Integer.toString(tpl.pageID))
}
@@ -330,7 +378,7 @@
logger.debug("[esi]: Fragment URL to Invalidate : "
+ frg.URL);
str.append(
- getFragmentInvalidationString(frg.prefix,
+ getFragmentInvalidationString(paramBean,
frg.prefix,
Integer.toString(frg.pageID),
Integer.toString(frg.fragID))
);
//getFragmentInvalidationString(frg.prefix, frg.host,