cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 28724] - FragmentExtractor always returns same fragment
Date Thu, 02 Dec 2004 23:10:30 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28724>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28724





------- Additional Comments From dean.cording@kaz-group.com  2004-12-03 00:10 -------
Try using this code instead:

      org.apache.cocoon.environment.Request request = 
ObjectModelHelper.getRequest(objectModel);
      String queryString = "";

      java.util.Enumeration names = request.getParameterNames();
      java.util.TreeSet sortedNames = new java.util.TreeSet();

      while (names.hasMoreElements()) {
        sortedNames.add((String)names.nextElement());
      }

      java.util.Iterator namesList = sortedNames.iterator();
      String name;
      String[] parameters;
      while (namesList.hasNext()) {
        name = (String)(namesList.next());
        parameters = request.getParameterValues(name);
        java.util.Arrays.sort(parameters);

        for (int index = 0; index < parameters.length; index++) {
          queryString += name + "=" + parameters[index] + "&";
        }
      }
      this.requestURI = ObjectModelHelper.getRequest(objectModel).getSitemapURI
()
  + "?" + queryString;



This will include all parameters from either a POST or a GET.  It also sorts 
the parameters by alphabetical order so it doesn't matter which order they are 
sent in.

I have been giving some thought to the caching issue.  The assumption with 
caching is that if the cache keys are the same the output will be the same.  
The FragmentExtractorTransformer will always extract the same fragments for a 
given output, ie it is not dependant on the input parameters.  Therefore a 
timebased fragment id would be sufficient.  This is because it is really up to 
the other components, especially the one that generated the fragments to be 
extracted, to determine the cache key depending on their inputs. If they 
produce the same cache key then the cached result will be returned (with the 
previous fragment id) and FragmentExtractorTransformer will not be called.


Try changing the line in endElement from:

String id = Long.toHexString((hashCode()^HashUtil.hash(requestURI)) + 
fragmentID);

to:

String id = Long.toHexString(System.currentTimeMillis()) + fragmentId;

and remove the code I suggested at the start.

This will also cover time dependent data because it shouldn't be generated in a 
caching pipeline anyway.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message