cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/util NetUtils.java
Date Thu, 23 Aug 2001 02:42:06 GMT
vgritsenko    01/08/22 19:42:06

  Modified:    src/org/apache/cocoon Main.java
               src/org/apache/cocoon/util NetUtils.java
  Log:
  reorder parameters in alphabetical order
  
  Revision  Changes    Path
  1.15      +14 -9     xml-cocoon2/src/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Main.java	2001/08/22 03:51:05	1.14
  +++ Main.java	2001/08/23 02:42:06	1.15
  @@ -41,6 +41,7 @@
   import java.util.Arrays;
   import java.util.Collection;
   import java.util.HashMap;
  +import java.util.TreeMap;
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
  @@ -50,7 +51,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.14 $ $Date: 2001/08/22 03:51:05 $
  + * @version CVS $Revision: 1.15 $ $Date: 2001/08/23 02:42:06 $
    */
   
   public class Main {
  @@ -487,11 +488,12 @@
           log.info("Processing URI: " + uri);
   
           // Get parameters, deparameterized URI and path from URI
  -        final HashMap parameters = new HashMap();
  -        parameters.put("user-agent", userAgent);
  -        parameters.put("accept", accept);
  +        final TreeMap parameters = new TreeMap();
           final String deparameterizedURI = NetUtils.deparameterize(uri, parameters);
           final String path = NetUtils.getPath(uri);
  +        final String suri = NetUtils.parameterize(deparameterizedURI, parameters);
  +        parameters.put("user-agent", userAgent);
  +        parameters.put("accept", accept);
   
           // Get file name from URI (without path)
           String pageURI = deparameterizedURI;
  @@ -500,20 +502,19 @@
               if(pageURI.length() == 0) pageURI = "./";
           }
   
  -        String filename = (String)allTranslatedLinks.get(uri);
  +        String filename = (String)allTranslatedLinks.get(suri);
           if(filename == null){
  -            filename = mangle(uri);
  +            filename = mangle(suri);
               final String type = getType(deparameterizedURI, parameters);
               final String ext = NetUtils.getExtension(filename);
               final String defaultExt = MIMEUtils.getDefaultExtension(type);
               if ((ext == null) || (!ext.equals(defaultExt))) {
                   filename += defaultExt;
               }
  -            allTranslatedLinks.put(uri, filename);
           }
   
           // Store processed URI list to avoid eternal loop
  -        allProcessedLinks.put(uri, filename);
  +        allProcessedLinks.put(suri, filename);
   
           // Process links
           final ArrayList absoluteLinks = new ArrayList();
  @@ -527,7 +528,11 @@
                   relativeLink = pageURI + relativeLink;
               }
   
  -            final String absoluteLink = NetUtils.normalize(NetUtils.absolutize(path, relativeLink));
  +            String absoluteLink = NetUtils.normalize(NetUtils.absolutize(path, relativeLink));
  +            {
  +                final TreeMap p = new TreeMap();
  +                absoluteLink = NetUtils.parameterize(NetUtils.deparameterize(absoluteLink,
p), p);
  +            }
               String translatedAbsoluteLink = (String)allTranslatedLinks.get(absoluteLink);
               if(translatedAbsoluteLink == null){
                   translatedAbsoluteLink = this.translateURI(absoluteLink);
  
  
  
  1.5       +20 -1     xml-cocoon2/src/org/apache/cocoon/util/NetUtils.java
  
  Index: NetUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/util/NetUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NetUtils.java	2001/08/20 13:55:18	1.4
  +++ NetUtils.java	2001/08/23 02:42:06	1.5
  @@ -9,13 +9,14 @@
   package org.apache.cocoon.util;
   
   import java.util.Map;
  +import java.util.Iterator;
   
   /**
    * A collection of <code>File</code>, <code>URL</code> and filename
    * utility methods
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2001/08/20 13:55:18 $
  + * @version CVS $Revision: 1.5 $ $Date: 2001/08/23 02:42:06 $
    */
   
   public class NetUtils {
  @@ -188,5 +189,23 @@
               parameters.put(name, value);
           }
           return uri.substring(0, i);
  +    }
  +
  +    public static String parameterize(String uri, Map parameters) {
  +        if (parameters.size() == 0) {
  +            return uri;
  +        }
  +        StringBuffer buffer = new StringBuffer(uri);
  +        buffer.append('?');
  +        for (Iterator i = parameters.entrySet().iterator(); i.hasNext();) {
  +            Map.Entry entry = (Map.Entry)i.next();
  +            buffer.append(entry.getKey());
  +            buffer.append('=');
  +            buffer.append(entry.getValue());
  +            if (i.hasNext()) {
  +                buffer.append('&');
  +            }
  +        }
  +        return buffer.toString();
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message