mcardle 2005/08/26 17:20:34 CEST
Modified files:
core/src/java/org/jahia/services/esi JesiObject.java
Fragment.java
Template.java
core/src/java/org/jahia/taglibs/esi JesiCodeblockTag.java
JesiTemplateTag.java
JesiTag.java
JesiFragmentTag.java
JesiBodyTag.java
core/src/java/org/jahia/bin/filters ESIFilter.java
Log:
various updates
Revision Changes Path
1.4 +13 -5 jahia/core/src/java/org/jahia/bin/filters/ESIFilter.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/bin/filters/ESIFilter.java.diff?r1=1.3&r2=1.4&f=h
1.3 +13 -8 jahia/core/src/java/org/jahia/services/esi/Fragment.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/Fragment.java.diff?r1=1.2&r2=1.3&f=h
1.3 +11 -1
jahia/core/src/java/org/jahia/services/esi/JesiObject.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/JesiObject.java.diff?r1=1.2&r2=1.3&f=h
1.3 +4 -0 jahia/core/src/java/org/jahia/services/esi/Template.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/Template.java.diff?r1=1.2&r2=1.3&f=h
1.2 +74 -63
jahia/core/src/java/org/jahia/taglibs/esi/JesiBodyTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiBodyTag.java.diff?r1=1.1&r2=1.2&f=h
1.2 +6 -6
jahia/core/src/java/org/jahia/taglibs/esi/JesiCodeblockTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiCodeblockTag.java.diff?r1=1.1&r2=1.2&f=h
1.3 +44 -44
jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java.diff?r1=1.2&r2=1.3&f=h
1.2 +43 -29 jahia/core/src/java/org/jahia/taglibs/esi/JesiTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiTag.java.diff?r1=1.1&r2=1.2&f=h
1.2 +31 -31
jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java.diff?r1=1.1&r2=1.2&f=h
Index: JesiObject.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/JesiObject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JesiObject.java 23 Aug 2005 16:51:16 -0000 1.2
+++ JesiObject.java 26 Aug 2005 15:20:33 -0000 1.3
@@ -11,12 +11,14 @@
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(JesiObject.class);
- String objType;
+ public String objType;
public HashMap fields = new HashMap();
public HashMap ctns = new HashMap();
public HashMap ctnlists = new HashMap();
public HashMap pages = new HashMap();
+ public String header = null;
+
public int siteID = -1;
public int pageID = -1;
public String URL = null;//might not be accurate since each
user/mode/group will have it in a different URL...
@@ -42,6 +44,14 @@
//TODO : Replace strings like "user" and "group" with Jahia constants
call
+ public String getHeader() {
+ return header;
+ }
+
+ public void setHeader(String header) {
+ this.header = header;
+ }
+
/**
* parse various components from the current URL, such as host, path,
query params etc...
*
Index: Fragment.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/Fragment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Fragment.java 23 Aug 2005 16:51:16 -0000 1.2
+++ Fragment.java 26 Aug 2005 15:20:33 -0000 1.3
@@ -24,8 +24,8 @@
org.apache.log4j.Logger.getLogger(Fragment.class);
public int fragID =-1;
- public String frag_user = null;//holds the 'user' value in the query
string, not in the path part of URL.
- public String frag_group = null;//holds the 'group' value in the query
string, not in the path part of URL.
+ public String fragUser = null;//holds the 'user' value in the query
string, not in the path part of URL.
+ public String fragGroup = null;//holds the 'group' value in the query
string, not in the path part of URL.
Fragment (int siteID, int pageID, int fragID, String URL) {
@@ -44,14 +44,14 @@
int pos = query.indexOf("user=");
if (pos != -1) {
int posPlus = query.indexOf("+",pos + "user=".length());
- frag_user = query.substring(pos,
+ fragUser = query.substring(pos,
(posPlus==-1)?query.length():posPlus );
//since user= might be the last parameter
}
//extract group part of url query string
pos = query.indexOf("group=");
if (pos != -1) {
int posPlus = query.indexOf("+",pos + "group=".length());
- frag_group = query.substring(pos,
+ fragGroup = query.substring(pos,
(posPlus==-1)?query.length():posPlus ); //since group= might be the last
parameter
}
}
@@ -136,14 +136,19 @@
result.append(site);
result.append(" ");
- result.append("| frag_user: ");
- result.append(frag_user);
+ result.append("| fragUser: ");
+ result.append(fragUser);
result.append(" ");
- result.append("| frag_group: ");
- result.append(frag_group);
+ result.append("| fragGroup: ");
+ result.append(fragGroup);
result.append(" ");
+ result.append("| Content Header: ");
+ result.append(header);
+ result.append(" ");
+
+
result.append(" ");
result.append("}");
Index: Template.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/Template.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Template.java 23 Aug 2005 16:51:16 -0000 1.2
+++ Template.java 26 Aug 2005 15:20:33 -0000 1.3
@@ -106,6 +106,10 @@
result.append(site);
result.append(" ");
+ result.append("| Content Header: ");
+ result.append(header);
+ result.append(" ");
+
result.append("}");
return result.toString();
Index: JesiCodeblockTag.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiCodeblockTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JesiCodeblockTag.java 23 Aug 2005 16:51:17 -0000 1.1
+++ JesiCodeblockTag.java 26 Aug 2005 15:20:33 -0000 1.2
@@ -17,9 +17,9 @@
execute = null;
}
- public void setExecute(String s)
+ public void setExecute(String toggle)
{
- execute = s;
+ execute = toggle;
}
public String getExecute()
@@ -36,8 +36,8 @@
}
- HttpServletRequest httpservletrequest =
(HttpServletRequest)pageContext.getRequest();
- if(!JesiTag.requestFromSurrogate_10(httpservletrequest))
+ HttpServletRequest req =
(HttpServletRequest)pageContext.getRequest();
+ if(!JesiTag.requestFromSurrogate_10(req))
return javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE; //1;
if(execute == null || execute.equals(""))
{
@@ -59,10 +59,10 @@
JahiaResourceBundle.getResource("","org.jahia.esi.out_template",
Jahia.getThreadParamBean().getLocale(), Jahia.getThreadParamBean())
);
if(execute.equalsIgnoreCase("template"))
- return templatetag.getRequestFragment() !=
JesiConst.NO_FRAGMENTS ?
+ return templatetag.getRequestedFragment() !=
JesiConst.NO_FRAGMENTS ?
javax.servlet.jsp.tagext.Tag.SKIP_BODY :
javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE; //-1 ? 0 : 1;
if(execute.equalsIgnoreCase("fragment"))
- return templatetag.getRequestFragment() ==
JesiConst.NO_FRAGMENTS ?
+ return templatetag.getRequestedFragment() ==
JesiConst.NO_FRAGMENTS ?
javax.servlet.jsp.tagext.Tag.SKIP_BODY :
javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE;
else
return javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE; //1;
Index: JesiTemplateTag.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JesiTemplateTag.java 23 Aug 2005 16:51:17 -0000 1.1
+++ JesiTemplateTag.java 26 Aug 2005 15:20:33 -0000 1.2
@@ -21,17 +21,17 @@
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(JesiTemplateTag.class);
- int fragmentTagCount;
- int requestFragment;
- String requestFragmentBody;
+ int fragmentCount;
+ int requestedFragment;
+ String requestedFragmentBody;
boolean controlSet;
String URL;
public JesiTemplateTag()
{
- fragmentTagCount = 0;
- requestFragment = JesiConst.NO_FRAGMENTS;
- requestFragmentBody = null;
+ fragmentCount = 0;
+ requestedFragment = JesiConst.NO_FRAGMENTS;
+ requestedFragmentBody = null;
controlSet = false;
//URL=null;
}
@@ -63,8 +63,8 @@
if(pageContext.getAttribute("jesitag.controltag",
PageContext.REQUEST_SCOPE) != null)
controlSet = true;
- HttpServletRequest httpservletrequest =
(HttpServletRequest)pageContext.getRequest();
- requestFragment = JesiConst.NO_FRAGMENTS;//-1
+ HttpServletRequest req =
(HttpServletRequest)pageContext.getRequest();
+ requestedFragment = JesiConst.NO_FRAGMENTS;//-1
try
{
@@ -72,7 +72,7 @@
}
catch(IOException ioexception) { }
- this.URL =
httpservletrequest.getAttribute("esi.request.url").toString();
+ this.URL = req.getAttribute("esi.request.url").toString();
//add template to invalidation hashmap
//we want to do this even when ESI isn't supported for this request,
so that all compiled
//pages register their templates with the ESI cache, since future
requests with ESI-support
@@ -84,19 +84,19 @@
//System.err.println("wwww Template.URL : "+this.URL);
//If no support for ESI, then skip this tag and just return its body
- if(!JesiTag.requestFromSurrogate_10(httpservletrequest))
+ if(!JesiTag.requestFromSurrogate_10(req))
return javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE;//1
//Is request asking for a Fragment?
try
{
//Yes
- requestFragment =
Integer.parseInt(httpservletrequest.getParameter(JesiConst.FRAGMENT_URL_MARKER));
+ requestedFragment =
Integer.parseInt(req.getParameter(JesiConst.FRAGMENT_URL_MARKER));
}
catch(Exception exception)
{
//No
- requestFragment = JesiConst.NO_FRAGMENTS;//-1
+ requestedFragment = JesiConst.NO_FRAGMENTS;//-1
/* //adding /tpl/ to URL so that invalidation protocol cannot just
eliminate won't
int posgroup = String3.indexOf("/group/");
@@ -109,7 +109,7 @@
}*/
}
//If it's not requesting a fragment and Control tag isn't present,
then set HTTP ESI headers
- if(requestFragment == JesiConst.NO_FRAGMENTS && !controlSet)
+ if(requestedFragment == JesiConst.NO_FRAGMENTS && !controlSet)
((HttpServletResponse)pageContext.getResponse()).setHeader(JesiConst.SURROGATE_CONTROL_HEADER,
makeSurrogateControl());
//If it's requesting a fragment, then don't buffer the body
@@ -117,7 +117,7 @@
//Tag.EVAL_BODY_INCLUDE Body is evaluated and
passed through to current out.
//BodyTag.EVAL_BODY_BUFFERED Creates a BodyContent object that
captures the processing of the body, for manipulation by the tag handler.
return
- requestFragment !=
+ requestedFragment !=
JesiConst.NO_FRAGMENTS ?
javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_BUFFERED
: javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE;
@@ -137,23 +137,23 @@
ServicesRegistry.getInstance().getEsiService().deleteOldFragments (
Jahia.getThreadParamBean().getSiteID(), //could get this
info from Template obj in tagStack
Jahia.getThreadParamBean().getPageID(), //could get this
info from Template obj in tagStack
- getFragmentTagCount());
+ getFragmentCount());
- HttpServletRequest httpservletrequest =
(HttpServletRequest)pageContext.getRequest();
+ HttpServletRequest req =
(HttpServletRequest)pageContext.getRequest();
//If ESI supported and it's requesting a fragment, then output the
Fragment body
- if(JesiTag.requestFromSurrogate_10(httpservletrequest) &&
requestFragment != JesiConst.NO_FRAGMENTS)
+ if(JesiTag.requestFromSurrogate_10(req) && requestedFragment !=
JesiConst.NO_FRAGMENTS)
try
{
-
getBodyContent().getEnclosingWriter().print(requestFragmentBody);
+
getBodyContent().getEnclosingWriter().print(requestedFragmentBody);
getBodyContent().clearBody();
}
catch(IOException ioexception)
{
throw new JspTagException(ioexception.toString());
}
- if(JesiTag.requestFromSurrogate_10(httpservletrequest) &&
requestFragment == JesiConst.NO_FRAGMENTS) {
+ if(JesiTag.requestFromSurrogate_10(req) && requestedFragment ==
JesiConst.NO_FRAGMENTS) {
//calculate next update time
String UpdateTime = null;
if (!JesiConst.UNSET.equals(expiration)) {
@@ -186,35 +186,35 @@
public void release()
{
- fragmentTagCount = 0;
- requestFragment = JesiConst.NO_FRAGMENTS;//-1
+ fragmentCount = 0;
+ requestedFragment = JesiConst.NO_FRAGMENTS;//-1
controlSet = false;
super.release();
}
- public int getFragmentTagCount()
+ public int getFragmentCount()
{
- return fragmentTagCount;
+ return fragmentCount;
}
- void incrementFragmentTagCount()
+ void incrementFragmentCount()
{
- fragmentTagCount++;
+ fragmentCount++;
}
- int getRequestFragment()
+ int getRequestedFragment()
{
- return requestFragment;
+ return requestedFragment;
}
- void setRequestFragmentBody(String s)
+ void setRequestedFragmentBody(String s)
{
- requestFragmentBody = s;
+ requestedFragmentBody = s;
}
- String getRequestFragmentBody()
+ String getRequestedFragmentBody()
{
- return requestFragmentBody;
+ return requestedFragmentBody;
}
}
Index: JesiTag.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JesiTag.java 23 Aug 2005 16:51:17 -0000 1.1
+++ JesiTag.java 26 Aug 2005 15:20:33 -0000 1.2
@@ -19,6 +19,8 @@
protected String expiration;
protected String maxRemovalDelay;
+ protected String tagHeader = null; //the header for this tag
+
public JesiTag()
{
control = null;
@@ -27,9 +29,17 @@
maxRemovalDelay = JesiConst.UNSET ;
}
- public void setCache(String s)
+ public String getTagHeader() {
+ return tagHeader;
+ }
+
+ public void setTagHeader(String tagHeader) {
+ this.tagHeader = tagHeader;
+ }
+
+ public void setCache(String cacheStatus)
{
- cache = s;
+ cache = cacheStatus;
}
public String getCache()
@@ -37,9 +47,9 @@
return cache;
}
- public void setExpiration(String s)
+ public void setExpiration(String timeInSeconds)
{
- expiration = s;
+ expiration = timeInSeconds;
}
public String getExpiration()
@@ -47,9 +57,9 @@
return expiration;
}
- public void setMaxRemovalDelay(String s)
+ public void setMaxRemovalDelay(String timeInSeconds)
{
- maxRemovalDelay = s;
+ maxRemovalDelay = timeInSeconds;
}
public String getMaxRemovalDelay()
@@ -57,9 +67,9 @@
return maxRemovalDelay;
}
- public void setControl(String s)
+ public void setControl(String headerParam)
{
- control = s;
+ control = headerParam;
}
public String getControl()
@@ -67,20 +77,21 @@
return control;
}
- public static boolean requestFromESI_10(HttpServletRequest
httpservletrequest)
+ public static boolean requestFromESI_10(HttpServletRequest req)
{
- String s =
httpservletrequest.getHeader(JesiConst.SURROGATE_CAPABILITY_HEADER);
- if(s != null)
- return s.indexOf(JesiConst.ESI_10) > 0;
+ String capabilityHeader =
req.getHeader(JesiConst.SURROGATE_CAPABILITY_HEADER);
+ if(capabilityHeader != null)
+ return capabilityHeader.indexOf(JesiConst.ESI_10) > 0;
else
return false;
}
- static boolean requestFromSurrogate_10(HttpServletRequest
httpservletrequest)
+ static boolean requestFromSurrogate_10(HttpServletRequest req)
{
- String s =
httpservletrequest.getHeader(JesiConst.SURROGATE_CAPABILITY_HEADER);
- if(s != null)
- return s.indexOf(JesiConst.SURROGATE_10) > 0 ||
s.indexOf(JesiConst.ESI_10) > 0;
+ String capabilityHeader =
req.getHeader(JesiConst.SURROGATE_CAPABILITY_HEADER);
+ if(capabilityHeader != null)
+ return capabilityHeader.indexOf(JesiConst.SURROGATE_10) > 0
+ || capabilityHeader.indexOf(JesiConst.ESI_10) > 0;
else
return false;
}
@@ -91,7 +102,7 @@
((HttpServletResponse)pagecontext.getResponse()).setHeader(JesiConst.SURROGATE_CONTROL_HEADER,
JesiConst.CONTENT_ESI_10);
}
- protected String makeSurrogateControl()
+ public String makeSurrogateControl()
throws JspTagException
{
if(expiration == null || expiration.equals(""))
@@ -119,33 +130,33 @@
JahiaResourceBundle.getResource("",
"org.jahia.esi.negative_value", Jahia.getThreadParamBean().getLocale(),
Jahia.getThreadParamBean())
);
}
- catch(NumberFormatException numberformatexception)
+ catch(NumberFormatException excep)
{
release();
- ((Throwable) numberformatexception).printStackTrace();
- throw new JspTagException(numberformatexception.toString());
+ ((Throwable) excep).printStackTrace();
+ throw new JspTagException(excep.toString());
}
- String s = JesiConst.CONTENT_ESI_10;
+ String contentHeader = JesiConst.CONTENT_ESI_10;
if(!expiration.equals(JesiConst.UNSET))
{
if(maxRemovalDelay.equals(JesiConst.UNSET))
maxRemovalDelay = JesiConst.DEFAULT_DELAY;
- s = s + ",max-age=" + expiration + "+" + maxRemovalDelay;
+ contentHeader = contentHeader + ",max-age=" + expiration + "+" +
maxRemovalDelay;
} else
if(!maxRemovalDelay.equals(JesiConst.UNSET))
- s = s + ",max-age="+JesiConst.DEFAULT_EXPIRATION+"+" +
maxRemovalDelay;
+ contentHeader = contentHeader +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+" + maxRemovalDelay;
if(cache != null)
if(cache.equalsIgnoreCase("yes"))
{
- if(s.indexOf("max-age") == -1)
- s = s +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+"+JesiConst.DEFAULT_DELAY;
+ if(contentHeader.indexOf("max-age") == -1)
+ contentHeader = contentHeader +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+"+JesiConst.DEFAULT_DELAY;
} else
if(cache.equalsIgnoreCase("no"))
- s = s + ",no-store";
+ contentHeader = contentHeader + ",no-store";
else
if(cache.equalsIgnoreCase("no-remote"))
{
- s = s + ",no-store-remote";
+ contentHeader = contentHeader + ",no-store-remote";
} else
{
release();
@@ -154,8 +165,11 @@
);
}
if(control != null)
- s = s + "," + control;
- return s;
+ contentHeader = contentHeader + "," + control;
+
+ setTagHeader(contentHeader);
+
+ return contentHeader;
}
public void release()
Index: JesiFragmentTag.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JesiFragmentTag.java 25 Aug 2005 18:32:35 -0000 1.2
+++ JesiFragmentTag.java 26 Aug 2005 15:20:33 -0000 1.3
@@ -22,8 +22,8 @@
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(JesiFragmentTag.class);
- private int tagCount = 0; //current Fragment number
- private int requestFragment = JesiConst.NO_FRAGMENTS; //ID of requested
Fragment
+ private int fragCount = 0; //current Fragment number
+ private int requestedFragment = JesiConst.NO_FRAGMENTS; //ID of
requested Fragment
private JesiTemplateTag parentTemplate = null;
public int doStartTag()
@@ -41,14 +41,13 @@
release();
throw new JspTagException(
JahiaResourceBundle.getResource("",
"org.jahia.esi.nested_fragment", Jahia.getThreadParamBean().getLocale(),
Jahia.getThreadParamBean())
- //JesiBodyTag.msgs.getString( "nested_fragment" )
);
}
else
{
pageContext.setAttribute( JesiConst.FRAGMENT_IN_USE, this,
PageContext.REQUEST_SCOPE );
setTagCountInfo();
- HttpServletRequest HttpServletRequest1 = (HttpServletRequest)
pageContext.getRequest();
+ HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
//had to move this here from below due to addFragment below
which needs the URL
//independly of whether ESI is supported or this IS/IS NOT a
fragment request
@@ -59,12 +58,12 @@
//pages register their fragments with the ESI cache, since
future requests with ESI-support
//will need this information.
//TODO: But could still ignore this if ESI is globally disabled
in server
- logger.debug("Detected Fragment " + tagCount + " on page:" +
Jahia.getThreadParamBean().getPageID());
+ logger.debug("Detected Fragment " + fragCount + " on page:" +
Jahia.getThreadParamBean().getPageID());
ServicesRegistry.getInstance().getEsiService().addFragment(Jahia.getThreadParamBean().getSiteID(),
-
Jahia.getThreadParamBean().getPageID(),tagCount, this.URL);
+
Jahia.getThreadParamBean().getPageID(),fragCount, this.URL);
//If ESI not supported, just return the fragment tag body
- if( !org.jahia.taglibs.esi.JesiTag.requestFromESI_10(
HttpServletRequest1 ) )
+ if( !org.jahia.taglibs.esi.JesiTag.requestFromESI_10( req ) )
return
javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_INCLUDE;//1; //should be
EVAL_BODY_BUFFERED
else //Supports ESI
{
@@ -76,12 +75,12 @@
try
{
//If requested Fragment is the current Fragment, Set ESI
headers and buffer the body
- if( requestFragment == getCurrentTagCount() ) {
+ if( requestedFragment == getCurrentFragCount() ) {
((HttpServletResponse)
pageContext.getResponse()).setHeader( JesiConst.SURROGATE_CONTROL_HEADER,
makeSurrogateControl() );
return EVAL_BODY_BUFFERED;
}
//If no fragments are requested, skip the body and just
include a ESI:include tag
- if(requestFragment == JesiConst.NO_FRAGMENTS) {
+ if(requestedFragment == JesiConst.NO_FRAGMENTS) {
//this.URL = getUrl(); MOVE IT ABOVE, but see if
can put it back here
pageContext.getOut().write("<esi:include src=\"" +
this.URL + "\"/>");
@@ -89,10 +88,10 @@
return Tag.SKIP_BODY; //Skips body if include
ESI:include, or if currently requested fragment isn't this one
}
- catch( IOException IOException2 )
+ catch( IOException excep )
{
release();
- throw new JspTagException( IOException2.toString() );
+ throw new JspTagException( excep.toString() );
}
}
}
@@ -105,9 +104,9 @@
return javax.servlet.jsp.tagext.Tag.EVAL_PAGE;//6;
}
- public int getCurrentTagCount()
+ public int getCurrentFragCount()
{
- return tagCount;
+ return fragCount;
}
void setTagCountInfo()
@@ -119,63 +118,63 @@
JahiaResourceBundle.getResource("",
"org.jahia.esi.out_template", Jahia.getThreadParamBean().getLocale(),
Jahia.getThreadParamBean()) );
else
{
- parentTemplate.incrementFragmentTagCount();
- tagCount = parentTemplate.getFragmentTagCount();
- requestFragment = parentTemplate.getRequestFragment();
+ parentTemplate.incrementFragmentCount();
+ fragCount = parentTemplate.getFragmentCount();
+ requestedFragment = parentTemplate.getRequestedFragment();
return;
}
}
- String getUrl()
+ public String getUrl()
{
- HttpServletRequest HttpServletRequest1 = (HttpServletRequest)
pageContext.getRequest();
+ HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
- String String3 =
HttpServletRequest1.getAttribute("esi.request.url").toString() ;
+ String reqUrl = req.getAttribute("esi.request.url").toString() ;
//save queryparams part of original page request and reinsert later
//TODO: add facility to accept or reject queryparams of original page
request in fragments
// so that fragments will be the same whatever queryparams are
submitted
- /*int posquery = String3.indexOf("?");
+ /*int posquery = reqUrl.indexOf("?");
String origQuery = "unset";
if (posquery != -1) {
- origQuery = String3.substring( posquery+1,
String3.length() );
- String3 = String3.substring( 0, posquery );
+ origQuery = reqUrl.substring( posquery+1,
reqUrl.length() );
+ reqUrl = reqUrl.substring( 0, posquery );
}
*/
//Get rid of queryparameters
//TODO: do we really want to get rid of all query params?
- int posquery = String3.indexOf("?");
+ int posquery = reqUrl.indexOf("?");
if (posquery != -1) {
- String3 = String3.substring( 0, posquery );
+ reqUrl = reqUrl.substring( 0, posquery );
}
//need to get rid of template's ESI params in http request since
each fragment might have different ESI settings
- int posuser = String3.indexOf("/"+JesiConst.USER+"/");
+ int posuser = reqUrl.indexOf("/"+JesiConst.USER+"/");
if (posuser != -1) {
- String s_end = String3.substring( posuser +
("/"+JesiConst.USER+"/").length() );
+ String s_end = reqUrl.substring( posuser +
("/"+JesiConst.USER+"/").length() );
int posenduser = s_end.indexOf("/");
s_end = s_end.substring( posenduser );
- String s_start = String3.substring( 0, posuser );
- String3 = s_start + s_end;
+ String s_start = reqUrl.substring( 0, posuser );
+ reqUrl = s_start + s_end;
}
- int posgroup = String3.indexOf("/"+JesiConst.GROUP+"/");
+ int posgroup = reqUrl.indexOf("/"+JesiConst.GROUP+"/");
if (posgroup != -1) {
- String s_end = String3.substring( posgroup +
("/"+JesiConst.GROUP+"+/").length() );
+ String s_end = reqUrl.substring( posgroup +
("/"+JesiConst.GROUP+"+/").length() );
int posendgroup = s_end.indexOf("/");
s_end = s_end.substring( posendgroup );
- String s_start = String3.substring( 0, posgroup );
- String3 = s_start + s_end;
+ String s_start = reqUrl.substring( 0, posgroup );
+ reqUrl = s_start + s_end;
}
- String3 += "?" + JesiConst.FRAGMENT_URL_MARKER + "=" +
getCurrentTagCount()
+ reqUrl += "?" + JesiConst.FRAGMENT_URL_MARKER + "=" +
getCurrentFragCount()
//+ ( "unset".equals(origQuery) ? "" :
"&"+origQuery )
+ ( JesiConst.UNSET.equals(user) ? "" : ( new
String("&"+JesiConst.USER+"=" + user) ) )
+ ( JesiConst.UNSET.equals(group) ? "" : ( new
String("&"+JesiConst.GROUP+"=" + group) ) );
logger.debug("JesiFragmentTag.getURL() group: "+group + " -
user:"+user);
//logger.debug("------------------------ END debug
JesiFragmentTag");
- return JesiBodyTag.copyParams( HttpServletRequest1, String3, true,
null );
+ return JesiBodyTag.copyParams( req, reqUrl, true, null );
}
public int doEndTag()
@@ -188,11 +187,11 @@
}
- HttpServletRequest HttpServletRequest1 = (HttpServletRequest)
pageContext.getRequest();
+ HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
//If ESI supported and requested fragment is current fragment
//Then output fragment content to Template
- if( JesiTag.requestFromESI_10( HttpServletRequest1 ) &&
requestFragment == getCurrentTagCount() ) {
+ if( JesiTag.requestFromESI_10( req ) && requestedFragment ==
getCurrentFragCount() ) {
//Only display fragment decoration if selected in settings
if
(Jahia.getThreadParamBean().settings().getEsiDisplayFragmentDelimiters()) {
@@ -201,23 +200,24 @@
if (!JesiConst.UNSET.equals(expiration)) {
Date now = (new Date());
now.setTime( now.getTime() +
(Long.parseLong(expiration))*1000 ); //since expiration in seconds
- UpdateTime = "<b>ESI Fragment #"+getCurrentTagCount()+"
: Next update time at " + DateFormat.getTimeInstance().format(now);
- } else UpdateTime = "<b>ESI Fragment
#"+getCurrentTagCount()+" : No Expiration Delay set.</b>";
+ UpdateTime = "<b>ESI Fragment #"+getCurrentFragCount()+"
: Next update time at " + DateFormat.getTimeInstance().format(now);
+ } else UpdateTime = "<b>ESI Fragment
#"+getCurrentFragCount()+" : No Expiration Delay set.</b>";
// UpdateTime = "<fieldset style='border-width: 1px;
border-color: navy; border: solid'><b>ESI Fragment : Next update time at " +
DateFormat.getTimeInstance().format(now) + "</fieldset>";
// } else UpdateTime = "<fieldset style='border-width: 1px;
border-color: navy; border: solid'><b>ESI Fragment : No Expiration Delay
set.</b></fieldset>";
- parentTemplate.setRequestFragmentBody("<fieldset
style='border-width: 1px; border-color: navy; "
- +"border:
"+(((getCurrentTagCount()%2)==0)?"inset":"outset")
+ parentTemplate.setRequestedFragmentBody("<fieldset
style='border-width: 1px; border-color: navy; "
+ //+"border:
"+(((getCurrentFragCount()%2)==0)?"inset":"outset")
+ +"border: outset"
+"'>" + getBodyContent().getString() + UpdateTime +
"</fieldset>" );
}
- else
parentTemplate.setRequestFragmentBody(getBodyContent().getString() );
+ else
parentTemplate.setRequestedFragmentBody(getBodyContent().getString() );
}
//We are now outside the scope of this enclosing JesiFragmentTag
//so we are removing it from the current tagStack
//From now on, any content access (i.e. getContainer() ) will add
itself
//to the previous tag in the tagStack.
-
ServicesRegistry.getInstance().getEsiService().tagStackPop("Fragment",
tagCount);
+
ServicesRegistry.getInstance().getEsiService().tagStackPop("Fragment",
fragCount);
pageContext.removeAttribute( JesiConst.FRAGMENT_IN_USE,
PageContext.REQUEST_SCOPE );
release();
@@ -226,8 +226,8 @@
public void release()
{
- tagCount = 0;
- requestFragment = -1;
+ fragCount = 0;
+ requestedFragment = -1;
parentTemplate = null;
super.release();
}
Index: JesiBodyTag.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiBodyTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JesiBodyTag.java 23 Aug 2005 16:51:17 -0000 1.1
+++ JesiBodyTag.java 26 Aug 2005 15:20:33 -0000 1.2
@@ -6,7 +6,6 @@
import java.util.*;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -32,6 +31,7 @@
protected String group;
protected String siteID;
protected String URL = null;//should be protected
+ protected String tagHeader = null; //the header for this tag
public JesiBodyTag()
{
@@ -46,9 +46,17 @@
URL = JesiConst.UNSET;
}
- public void setCache(String s)
+ public String getTagHeader() {
+ return tagHeader;
+ }
+
+ public void setTagHeader(String tagHeader) {
+ this.tagHeader = tagHeader;
+ }
+
+ public void setCache(String yesOrNo)
{
- cache = s;
+ cache = yesOrNo;
}
public String getCache()
@@ -56,9 +64,9 @@
return cache;
}
- public void setExpiration(String s)
+ public void setExpiration(String timeInSeconds)
{
- expiration = s;
+ expiration = timeInSeconds;
}
public String getExpiration()
@@ -66,9 +74,9 @@
return expiration;
}
- public void setMaxRemovalDelay(String s)
+ public void setMaxRemovalDelay(String timeInSeconds)
{
- maxRemovalDelay = s;
+ maxRemovalDelay = timeInSeconds;
}
public String getMaxRemovalDelay()
@@ -76,9 +84,9 @@
return maxRemovalDelay;
}
- public void setControl(String s)
+ public void setControl(String controlHeader)
{
- control = s;
+ control = controlHeader;
}
public String getControl()
@@ -118,32 +126,32 @@
);
}
}
- catch(NumberFormatException numberformatexception)
+ catch(NumberFormatException excep)
{
release();
- throw new JspTagException(numberformatexception.toString());
+ throw new JspTagException(excep.toString());
}
- String s = JesiConst.CONTENT_ESI_10;
+ String contentHeader = JesiConst.CONTENT_ESI_10;
if(!expiration.equals(JesiConst.UNSET))
{
if(maxRemovalDelay.equals(JesiConst.UNSET))
maxRemovalDelay = JesiConst.DEFAULT_DELAY;
- s = s + ",max-age=" + expiration + "+" + maxRemovalDelay;
+ contentHeader = contentHeader + ",max-age=" + expiration + "+" +
maxRemovalDelay;
} else
if(!maxRemovalDelay.equals(JesiConst.UNSET))
- s = s + ",max-age="+JesiConst.DEFAULT_EXPIRATION+"+" +
maxRemovalDelay;
+ contentHeader = contentHeader +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+" + maxRemovalDelay;
if(cache != null)
if(cache.equalsIgnoreCase("yes"))
{
- if(s.indexOf("max-age") == -1)
- s = s +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+"+JesiConst.DEFAULT_DELAY;
+ if(contentHeader.indexOf("max-age") == -1)
+ contentHeader = contentHeader +
",max-age="+JesiConst.DEFAULT_EXPIRATION+"+"+JesiConst.DEFAULT_DELAY;
} else
if(cache.equalsIgnoreCase("no"))
- s = s + ",no-store";
+ contentHeader = contentHeader + ",no-store";
else
if(cache.equalsIgnoreCase("no-remote"))
{
- s = s + ",no-store-remote";
+ contentHeader = contentHeader + ",no-store-remote";
} else
{
release();
@@ -152,56 +160,59 @@
);
}
if(control != null)
- s = s + "," + control;
- return s;
+ contentHeader = contentHeader + "," + control;
+
+ setTagHeader(contentHeader);
+
+ return contentHeader;
}
- static String copyParams(HttpServletRequest httpservletrequest, String
s, boolean flag, Vector vector)
+ static String copyParams(HttpServletRequest req, String url, boolean
includeOriginalParams, Vector newQueryParams)
{
//TODO: add facility to accept or reject queryparams of original
page request in fragments
// so that fragments will be the same whatever queryparams are
submitted
- HttpServletRequest request = httpservletrequest;
- logger.debug("JesiBodyTag.copyParams() flag:"+flag + "
vector:"+vector + " s:" + s);
+ HttpServletRequest request = req;
+ logger.debug("JesiBodyTag.copyParams()
includeOriginalParams:"+includeOriginalParams + "
newQueryParams:"+newQueryParams + " url:" + url);
- if (s==null) {
+ if (url ==null) {
return "MARCERROR";
}
- int i = s.lastIndexOf("?");
- String s1_pagead = i >= 0 ? s.substring(0, i) : s;
+ int i = url.lastIndexOf("?");
+ String urlNoQuery = i >= 0 ? url.substring(0, i) : url;
- //s1_pagead = "http://192.168.2.178:7779/jahia/Jahia/cache/off";
+ //urlNoQuery = "http://192.168.2.178:7779/jahia/Jahia/cache/off";
StringBuffer stringbuffer = new StringBuffer();
- String s2_query = null;
+ String urlQuery = null;
- if(i >= 0 && s.length() > i + 1)
- s2_query = s.substring(i + 1);
+ if(i >= 0 && url.length() > i + 1)
+ urlQuery = url.substring(i + 1);
- if(s2_query != null)
+ if(urlQuery != null)
{
- StringTokenizer stringtokenizer = new StringTokenizer(s2_query,
" ", true);
- String s4 = null;
- String s6 = null;
- while(stringtokenizer.hasMoreTokens())
+ StringTokenizer tokenizer = new StringTokenizer(urlQuery, " ",
true);
+ String paramName = null;
+ String paramVal = null;
+ while(tokenizer.hasMoreTokens())
{
try
{
- s4 = null;
- s6 = null;
- s4 = stringtokenizer.nextToken("=");
- stringtokenizer.nextToken();
- s6 = stringtokenizer.nextToken("&"); //CurrentTagCount
number
- stringtokenizer.nextToken();
+ paramName = null;
+ paramVal = null;
+ paramName = tokenizer.nextToken("=");
+ tokenizer.nextToken();
+ paramVal = tokenizer.nextToken("&"); //CurrentTagCount
number
+ tokenizer.nextToken();
}
catch(NoSuchElementException nosuchelementexception) {
}
- if(s4 != null) {
+ if(paramName != null) {
try {
- stringbuffer.append("&").append(URLEncoder.encode(s4,
+
stringbuffer.append("&").append(URLEncoder.encode(paramName,
enc)).append("=").
- append(s6 == null ? "" :
- URLEncoder.encode(s6, enc));
+ append(paramVal == null ? "" :
+ URLEncoder.encode(paramVal, enc));
} catch (UnsupportedEncodingException e) {
logger.error("Encoding Scheme ["+enc+"] is incorrect
: " + e);
}
@@ -209,11 +220,11 @@
}
}
}
- if(vector != null)
+ if(newQueryParams != null)
{
- for(int j = 0; j < vector.size(); j++)
+ for(int j = 0; j < newQueryParams.size(); j++)
{
- String as[] = (String[])vector.elementAt(j);
+ String as[] = (String[])newQueryParams.elementAt(j);
try {
stringbuffer.append("&").append(URLEncoder.encode(as[0],
enc));
@@ -225,14 +236,14 @@
}
}
- if(flag)
+ if(includeOriginalParams)
{
- for(Enumeration enumeration =
httpservletrequest.getParameterNames(); enumeration.hasMoreElements();)
+ for(Enumeration en = req.getParameterNames();
en.hasMoreElements();)
{
- String s5 = (String)enumeration.nextElement();
+ String s5 = (String)en.nextElement();
if(JesiConst.RESERVED_PARAM_NAMES.get(s5) == null)
{
- String as1[] = httpservletrequest.getParameterValues(s5);
+ String as1[] = req.getParameterValues(s5);
for(int k = 0; k < as1.length; k++) {
try {
stringbuffer.append("&").append(URLEncoder.encode(
@@ -247,18 +258,18 @@
}
}
- String s3 = null;
+ String newQuery = null;
if(stringbuffer.length() > 0)
- s3 = stringbuffer.substring(1);
- if(s3 != null)
- return s1_pagead + "?" + s3;
+ newQuery = stringbuffer.substring(1);
+ if(newQuery != null)
+ return urlNoQuery + "?" + newQuery;
else
- return s;
+ return url;
}
- public void setUser(String s)
+ public void setUser(String userName)
{
- user = s;
+ user = userName;
if(!group.equals(JesiConst.UNSET)) {
logger.debug("Trying to set JesiBodyTag.user attribute while
JesiBodyTag.group is already set." +
" Therefore, deleting JesiBodyTag.group attribute
since JesiBodyTag.user attribute takes precedence.");
@@ -272,9 +283,9 @@
return user;
}
- public void setGroup(String s)
+ public void setGroup(String groupName)
{
- group = s;
+ group = groupName;
if(!user.equals(JesiConst.UNSET)) {
logger.debug("Trying to set JesiBodyTag.group attribute while
JesiBodyTag.user is already set." +
" Therefore, deleting JesiBodyTag.group attribute
since JesiBodyTag.user attribute takes precedence.");
@@ -295,9 +306,9 @@
return siteID;
}
- public void setURL(String s)
+ public void setURL(String url)
{
- URL = s;
+ URL = url;
}
public String getURL()
{
Index: ESIFilter.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/bin/filters/ESIFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ESIFilter.java 25 Aug 2005 18:32:34 -0000 1.3
+++ ESIFilter.java 26 Aug 2005 15:20:33 -0000 1.4
@@ -64,13 +64,19 @@
if (
getUrl(httpRequest).indexOf(JesiConst.FRAGMENT_URL_MARKER) != -1) {
cacheinfo = "(FRAGMENT detected)";
}
- if ( getUrl(httpRequest).indexOf("pid") != -1)
- logger.debug ("\nAt " + (new java.util.Date()
).toString() + " ***** "+httpRequest.getMethod()+" on " + getUrl(httpRequest)+
" ******* "+ cacheinfo +"\n" );
+ if ( getUrl(httpRequest).indexOf("pid") != -1) {
+ //logger.info ("\nAt " + (new java.util.Date()
).toString() + " ***** "+httpRequest.getMethod()+" on " + getUrl(httpRequest)+
" ******* "+ cacheinfo +"\n" );
+ logger.info ("\n***** "+httpRequest.getMethod()+" on " +
getUrl(httpRequest)+ " ******* "+ cacheinfo +"\n" );
+ logger.debug ("Request headers :\n" +
printHeaders(httpRequest));
+ }
+ else
+ logger.info ("\n***** "+httpRequest.getMethod()+" on " +
getUrl(httpRequest)+ " ******* "+ cacheinfo +"\n" );
//Hack: used by JesiFragmentTag since current Tomcat doesn't
seem to forward original requestURL
httpRequest.setAttribute("esi.request.url",getUrl(httpRequest));
- //printHeaders(httpRequest);
+ logger.debug ("Request headers :\n" +
printHeaders(httpRequest));
+
}
chain.doFilter (request, response );
//System.out.println( "RESPONSE: " + response.toString() ) ;
//useful to see generated ESI code
@@ -85,10 +91,11 @@
}
- private void printHeaders(HttpServletRequest httpRequest) {
+ private String printHeaders(HttpServletRequest httpRequest) {
String name;
String value;
// Get all request headers
+ StringBuffer stringBuffer = new StringBuffer();
Enumeration Enum = httpRequest.getHeaderNames();
for (; Enum.hasMoreElements(); ) {
// Get the name of the request header
@@ -106,8 +113,9 @@
//System.out.println(" "+value);
}
- logger.info(" "+name+ " : " + value);
+ stringBuffer.append(" "+name+ " : " + value +"\n");
}
+ return stringBuffer.toString();
}
}