Author: ssmiweve
Date: 2008-04-19 21:06:20 +0200 (Sat, 19 Apr 2008)
New Revision: 6502

Modified:
   trunk/
   
trunk/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObject.java
   trunk/generic.sesam/
   
trunk/generic.sesam/view-control/src/main/java/no/sesat/search/view/navigation/fast/FastNavigationController.java
   trunk/site-spi/src/main/java/no/sesat/search/site/Site.java
   
trunk/site-spi/src/main/java/no/sesat/search/site/config/AbstractResourceLoader.java
   trunk/site-spi/src/main/java/no/sesat/search/site/config/SpiClassLoader.java
   
trunk/site-spi/src/test/java/no/sesat/search/site/config/FileResourceLoader.java
   
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/NavigationConfig.java
   
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/OptionsNavigationConfig.java
   
trunk/view-control-spi/src/main/java/no/sesat/search/view/navigation/OptionNavigationController.java
   trunk/war/src/main/java/no/sesat/search/http/filters/SiteLocatorFilter.java
   trunk/war/src/main/java/no/sesat/search/http/filters/UrlRewriteFilter.java
   trunk/war/src/main/java/no/sesat/search/http/filters/UserFilter.java
   trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml
Log:
Merged revisions 6390-6501 via svnmerge from 
http://sesat.no/svn/sesat-kernel/branches/2.17

................
  r6392 | ssmiweve | 2008-04-10 11:21:04 +0200 (Thu, 10 Apr 2008) | 17 lines
  
  Merged revisions 6338-6391 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6344 | ssmiweve | 2008-04-03 21:44:11 +0200 (Thu, 03 Apr 2008) | 2 lines
    
    http://sesat.no/svn/sesat-kernel
  ........
    r6378 | ssmiweve | 2008-04-07 12:14:14 +0200 (Mon, 07 Apr 2008) | 2 lines
    
    mojo: jump forward a version to reap some bugfixes
  ........
    r6391 | ssmiweve | 2008-04-10 10:47:58 +0200 (Thu, 10 Apr 2008) | 1 line
    
    OPS-178 Prepare Gamma for secondary production use
  ........
................
  r6393 | sshafroi | 2008-04-11 09:58:10 +0200 (Fri, 11 Apr 2008) | 1 line
  
  Updateing link
................
  r6394 | ssmiweve | 2008-04-11 12:01:52 +0200 (Fri, 11 Apr 2008) | 1 line
  
  SEARCH-4481 - Personberikelse ved null treff i bedrift har forsvunnet
................
  r6395 | ssmiweve | 2008-04-11 15:10:15 +0200 (Fri, 11 Apr 2008) | 1 line
  
  SEARCH-4600 - sesam.no/favicon.ico leads to a regular search for "favicon.ico"
................
  r6396 | ssmiweve | 2008-04-11 17:49:41 +0200 (Fri, 11 Apr 2008) | 1 line
  
  SEARCH-3509 - ?\195?\152ke ytelsen p?\195?\165 forsiden av nyhetss?\195?\184k
................
  r6397 | sshafroi | 2008-04-14 09:01:17 +0200 (Mon, 14 Apr 2008) | 1 line
  
  build
................
  r6445 | ssmiweve | 2008-04-15 14:31:19 +0200 (Tue, 15 Apr 2008) | 1 line
  
  better exception handling related to work going on in OPS-209
................
  r6446 | ssmiweve | 2008-04-15 14:36:29 +0200 (Tue, 15 Apr 2008) | 13 lines
  
  Merged revisions 6392-6445 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6417 | ssmiweve | 2008-04-14 22:21:33 +0200 (Mon, 14 Apr 2008) | 2 lines
    
    SEARCH-4613 - generic.sesam.no configuration files are loaded through apache
  ........
    r6440 | ssmiweve | 2008-04-15 13:42:19 +0200 (Tue, 15 Apr 2008) | 1 line
    
    SEARCH-4613 - generic.sesam.no configuration files are loaded through apache
  ........
................
  r6447 | ssmiweve | 2008-04-15 16:16:21 +0200 (Tue, 15 Apr 2008) | 1 line
  
  SEARCH-4620 - Fjerne un?\195?\184dige s?\195?\184k i XML- og RSS-interfacene 
v?\195?\165re (spesielt bildes?\195?\184ket som koster penger)
................
  r6465 | ssmiweve | 2008-04-16 11:52:22 +0200 (Wed, 16 Apr 2008) | 2 lines
  
  SEARCH-4613 - generic.sesam.no configuration files are loaded through apache
................
  r6466 | ssmiweve | 2008-04-16 11:53:08 +0200 (Wed, 16 Apr 2008) | 9 lines
  
  Merged revisions 6446-6465 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6464 | ssmiweve | 2008-04-16 11:07:07 +0200 (Wed, 16 Apr 2008) | 1 line
    
    SEARCH-4613 - generic.sesam.no configuration files are loaded through apache
  ........
................
  r6473 | ssmiweve | 2008-04-16 15:56:22 +0200 (Wed, 16 Apr 2008) | 1 line
  
  javadoc fix
................
  r6485 | ssmiweve | 2008-04-18 12:24:08 +0200 (Fri, 18 Apr 2008) | 29 lines
  
  Merged revisions 6466-6484 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6476 | ssmiweve | 2008-04-17 12:06:57 +0200 (Thu, 17 Apr 2008) | 1 line
    
    javadoc
  ........
    r6477 | ssmiweve | 2008-04-17 12:47:06 +0200 (Thu, 17 Apr 2008) | 1 line
    
    javadoc -- from 
http://sesat.no/pipermail/kernel-development/2008-April/000059.html
  ........
    r6478 | ssmiweve | 2008-04-17 12:47:17 +0200 (Thu, 17 Apr 2008) | 1 line
    
    http://sesat.no/pipermail/kernel-development/2008-April/000059.html
  ........
    r6479 | ssmiweve | 2008-04-17 22:58:05 +0200 (Thu, 17 Apr 2008) | 1 line
    
    SEARCH-4638 - Swedish request using generic.sesam without explicit port
  ........
    r6480 | ssmiweve | 2008-04-17 22:59:15 +0200 (Thu, 17 Apr 2008) | 1 line
    
    javadoc
  ........
    r6481 | ssmiweve | 2008-04-17 23:13:51 +0200 (Thu, 17 Apr 2008) | 1 line
    
    SEARCH-4638 - Swedish request using generic.sesam without explicit port
  ........
................
  r6486 | ssenrogn | 2008-04-18 14:09:41 +0200 (Fri, 18 Apr 2008) | 1 line
  
  Prettier logging.
................
  r6487 | ssenrogn | 2008-04-18 14:11:21 +0200 (Fri, 18 Apr 2008) | 1 line
  
  Added Eclipse files to ignore list.
................
  r6493 | ssmiweve | 2008-04-18 16:50:34 +0200 (Fri, 18 Apr 2008) | 9 lines
  
  Merged revisions 6485-6492 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6492 | ssmiweve | 2008-04-18 16:42:38 +0200 (Fri, 18 Apr 2008) | 2 lines
    
    SEARCH-4646 - sesam.se:9002 does not work with curl/wget
  ........
................
  r6494 | ssenrogn | 2008-04-18 21:49:44 +0200 (Fri, 18 Apr 2008) | 1 line
  
  Added missing fields to toString to make debug easier.
................
  r6495 | ssenrogn | 2008-04-18 21:50:35 +0200 (Fri, 18 Apr 2008) | 1 line
  
  Implemented toString to make debuging easier.
................
  r6496 | ssenrogn | 2008-04-18 21:52:34 +0200 (Fri, 18 Apr 2008) | 1 line
  
  SEARCH-4505 - readded handling of tab override on option level.
................
  r6500 | ssmiweve | 2008-04-19 20:06:49 +0200 (Sat, 19 Apr 2008) | 9 lines
  
  Merged revisions 6493-6499 via svnmerge from 
  http://sesat.no/svn/sesat-kernel/branches/2.16
  
  ........
    r6497 | ssmiweve | 2008-04-19 15:33:14 +0200 (Sat, 19 Apr 2008) | 2 lines
    
    SEARCH-4647 - Faulty host lookup leading to seemingly infinite loop + high 
load = crashed server.
  ........
................
  r6501 | ssmiweve | 2008-04-19 20:57:01 +0200 (Sat, 19 Apr 2008) | 2 lines
  
  SEARCH-4614 - sesat tests broken on windows machines
................



Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/2.10:1-4690,4692-4745 /branches/2.11:1-4933 
/branches/2.12:1-5051,5053-5106 /branches/2.13:1-5378 /branches/2.14:1-5508 
/branches/2.15:1-5995 /branches/2.16:1-6465 /branches/2.17:1-6389 
/branches/2.6:1-3877 /branches/2.7:1-4160 /branches/2.8:1-4446 
/branches/2.9:1-4626 /branches/MAP_SEARCHv2:1-4544

   + /branches/2.10:1-4690,4692-4745 /branches/2.11:1-4933 
/branches/2.12:1-5051,5053-5106 /branches/2.13:1-5378 /branches/2.14:1-5508 
/branches/2.15:1-5995 /branches/2.16:1-6499 /branches/2.17:1-6501 
/branches/2.6:1-3877 /branches/2.7:1-4160 /branches/2.8:1-4446 
/branches/2.9:1-4626 /branches/MAP_SEARCHv2:1-4544


Modified: 
trunk/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObject.java
===================================================================
--- 
trunk/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObject.java
  2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/data-model-api/src/main/java/no/sesat/search/datamodel/generic/StringDataObject.java
  2008-04-19 19:06:20 UTC (rev 6502)
@@ -26,32 +26,38 @@
 import static no.sesat.search.datamodel.access.ControlLevel.VIEW_CONSTRUCTION;
 import no.sesat.search.datamodel.access.AccessDisallow;
 
-/**
+/** DataObject wrapping a String providing getters for url encoded and xml 
escaped variants.
+ * 
+ * String should not be used directly during the rendering stage.
+ * Hence getString has the annontation 
<code>@AccessDisallow({VIEW_CONSTRUCTION})</code>.
+ * 
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Mck</a>
  * @version <tt>$Id$</tt>
  */
 @DataObject
 public interface StringDataObject extends Serializable{
-    /**
-     * 
+    /** The plain value of the string.
+     * Disallowed during rendering for security reasons.
      * @return 
      */
     @AccessDisallow({VIEW_CONSTRUCTION})
     String getString();
-    /**
+    /** The UTF8 url encoded variant of the string.
+     * Encoding must meet those requirements stated in java.net.URLEncoder
      * 
-     * @return 
+     * @return UTF8 url encoded variant of the string.
      */
     String getUtf8UrlEncoded();
-    /**
+    /** The ISO-88591 url encoded variant of the string.
+     * Encoding must meet those requirements stated in java.net.URLEncoder
      * 
-     * @return 
+     * @return ISO-88591 url encoded variant of the string.
      */
     String getIso88591UrlEncoded();
-    /**
+    /** The xml escaped variant of the string.
      * 
-     * @return 
+     * @return xmlescaped variant of the string.
      */
     String getXmlEscaped();
 }


Property changes on: trunk/generic.sesam
___________________________________________________________________
Name: svn:ignore
   - target

   + .project
.classpath
.settings
.checkstyle
target


Modified: 
trunk/generic.sesam/view-control/src/main/java/no/sesat/search/view/navigation/fast/FastNavigationController.java
===================================================================
--- 
trunk/generic.sesam/view-control/src/main/java/no/sesat/search/view/navigation/fast/FastNavigationController.java
   2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/generic.sesam/view-control/src/main/java/no/sesat/search/view/navigation/fast/FastNavigationController.java
   2008-04-19 19:06:20 UTC (rev 6502)
@@ -58,7 +58,7 @@
         final NavigationItem item = new BasicNavigationItem();
 
         if (search == null) {
-            LOG.error("Search for " + commandName + "not found.");
+            LOG.error("Search for '" + commandName + "' not found.");
             return item;
         }
 

Modified: trunk/site-spi/src/main/java/no/sesat/search/site/Site.java
===================================================================
--- trunk/site-spi/src/main/java/no/sesat/search/site/Site.java 2008-04-19 
18:57:01 UTC (rev 6501)
+++ trunk/site-spi/src/main/java/no/sesat/search/site/Site.java 2008-04-19 
19:06:20 UTC (rev 6502)
@@ -32,6 +32,7 @@
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import no.schibstedsok.commons.ioc.BaseContext;
 import org.apache.log4j.Level;
+import no.sesat.search.site.config.ResourceLoadException;
 import org.apache.log4j.Logger;
 
 /** A Site object identifies a Skin + Locale pairing.
@@ -123,6 +124,7 @@
 
     /** Creates a new instance of Site.
      * A null Context will result in a parentSiteName == siteName
+     * @throws IllegalArgumentException when there exists no skin matching the 
theSiteName argument.
      */
     private Site(final Context cxt, final String theSiteName, final Locale 
theLocale) {
 
@@ -149,22 +151,25 @@
                 }
             };
 
+
             final String parentSiteName;
             if(null != cxt){
-                parentSiteName = null != cxt.getParentSiteName(siteContext)
-                        ? 
ensureTrailingSlash(cxt.getParentSiteName(siteContext))
-                        : null;
+                // cxt.getParentSiteName(siteContext) is an expensive call due 
to resource load every call.
+                final String psn = cxt.getParentSiteName(siteContext);
+                parentSiteName = null != psn ? ensureTrailingSlash(psn) : null;
+                
             }else{
                 parentSiteName = siteName;
             }
-
             final String tsParentNameNoPort = null != parentSiteName
                     ? ensureTrailingSlash(parentSiteName.replaceAll(":.*$", 
""))
                     : null;
 
             LOG.debug(siteName + " parent is " + parentSiteName);
 
-            if(constructingDefault){
+            if(constructingDefault || DEFAULT.getName().equals(cxtName)){
+                // dont let the original DEFAULT have a parent
+                // OR let a port-explicit generic.sesam have a parent.
                 parent = null;
 
             }else{
@@ -266,7 +271,8 @@
      * @param cxt the cxt to use during creation. null will prevent 
constructing a new site.
      * @param siteName the virtual host name.
      * @param locale the locale desired
-     * @return the site bean.
+     * @throws IllegalArgumentException when there exists no skin matching the 
siteName argument.
+     * @return the site instance. never null.
      */
     public static Site valueOf(final Context cxt, final String siteName, final 
Locale locale) {
 
@@ -279,7 +285,8 @@
         final String uniqueName = getUniqueName(realSiteName,locale);
         try{
             INSTANCES_LOCK.readLock().lock();
-            LOG.debug("INSTANCES.get(" + uniqueName + ")");
+
+            LOG.trace("INSTANCES.get(" + uniqueName + ")");
             site = INSTANCES.get(uniqueName);
 
         }finally{

Modified: 
trunk/site-spi/src/main/java/no/sesat/search/site/config/AbstractResourceLoader.java
===================================================================
--- 
trunk/site-spi/src/main/java/no/sesat/search/site/config/AbstractResourceLoader.java
        2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/site-spi/src/main/java/no/sesat/search/site/config/AbstractResourceLoader.java
        2008-04-19 19:06:20 UTC (rev 6502)
@@ -38,6 +38,7 @@
 import no.sesat.search.site.Site;
 import no.sesat.search.site.SiteContext;
 import org.apache.log4j.Logger;
+import org.apache.log4j.MDC;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -261,6 +262,10 @@
      */
     public void run() {
         
+        // Inheriting from Site & UniqueId from parent thread is meaningless 
in a thread pool.
+        MDC.put(Site.NAME_KEY, context.getSite());
+        MDC.remove("UNIQUE_ID");
+        
         switch(resourceType.getPolymorphism()){
             case UP_HEIRARCHY:
                 // Properties inherent through the fallback process. Keys are 
*not* overridden.

Modified: 
trunk/site-spi/src/main/java/no/sesat/search/site/config/SpiClassLoader.java
===================================================================
--- 
trunk/site-spi/src/main/java/no/sesat/search/site/config/SpiClassLoader.java    
    2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/site-spi/src/main/java/no/sesat/search/site/config/SpiClassLoader.java    
    2008-04-19 19:06:20 UTC (rev 6502)
@@ -1,4 +1,4 @@
-/* Copyright (2006-2007) Schibsted Søk AS
+/* Copyright (2006-2008) Schibsted Søk AS
  * This file is part of SESAT.
  *
  *   SESAT is free software: you can redistribute it and/or modify
@@ -61,9 +61,6 @@
         parentSite = site.getParent() != null ? parentSiteClassLoader() : 
this.getClass().getClassLoader();
     }
 
-    /**
-     * [EMAIL PROTECTED]
-     */
     @Override
     public String toString() {
         return CLASS_LOADER_FOR + site.toString() + ", " + spi + "=>" + 
spi.getParent() +')';
@@ -111,7 +108,6 @@
         return jarName;
     }
 
-    /** [EMAIL PROTECTED] */
     @Override
     protected Class<?> findClass(final String className) throws 
ClassNotFoundException {
         

Modified: 
trunk/site-spi/src/test/java/no/sesat/search/site/config/FileResourceLoader.java
===================================================================
--- 
trunk/site-spi/src/test/java/no/sesat/search/site/config/FileResourceLoader.java
    2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/site-spi/src/test/java/no/sesat/search/site/config/FileResourceLoader.java
    2008-04-19 19:06:20 UTC (rev 6502)
@@ -133,6 +133,7 @@
         return projectName.replace('/', File.separatorChar);
     }
 
+    // Not a doubt in my mind someone could write this a shit load better. 
i'll buy a beer to them.
     @Override
     protected final URL getResource(final Site site) {
 
@@ -153,17 +154,23 @@
             String basedir = System.getProperty("basedir") + 
File.separatorChar;
             LOG.debug("project " + project);
             while(true){
-                final String basedirNormalised = new 
File(basedir).toURI().normalize().toString();
+                final String basedirNormalised = new 
File(basedir).toURI().normalize().toString()
+                        .replaceFirst("file:", "").replace('/', 
File.separatorChar);
+                
                 LOG.debug("basedirNormalised " + basedirNormalised);
-                assert !"/war".equals(basedirNormalised) : "At root of 
filesystem!";
-                if(basedirNormalised.endsWith(project) || 
basedirNormalised.endsWith(project + "war/")){
+                
+                assert ! (File.separatorChar + 
"war").equals(basedirNormalised) : "At root of filesystem!";
+                
+                if(basedirNormalised.endsWith(project) 
+                        || basedirNormalised.endsWith(project + "war" + 
File.separatorChar)){
+                    
                     LOG.debug("looking in " + basedir + suffix);
                     final File f = new File(basedir + suffix + getResource());
                     if(f.exists()){
                         return f.toURI().normalize().toURL();
                     }
                 }
-                if("generic.sesam/".equals(project)){
+                if(("generic.sesam" + File.separatorChar).equals(project)){
                     ++genericSesamLoop;
                     basedir = System.getProperty("basedir") + 
File.separatorChar;
                     for(int i = 0; i < genericSesamLoop; ++i){

Modified: 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/NavigationConfig.java
===================================================================
--- 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/NavigationConfig.java
   2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/NavigationConfig.java
   2008-04-19 19:06:20 UTC (rev 6502)
@@ -226,11 +226,13 @@
         @Override
         public String toString() {
             return "\nNavigation{" +
-                    "commandName='" + commandName + '\'' +
+                    "id='" + id + '\'' +
+                    ",commandName='" + commandName + '\'' +
                     ", tab='" + tab + '\'' +
                     ", out=" + out +
-                    ", navList=" + navList +
-                    ", resetNavSet=" + resetNavSet +
+                    ", excludeQuery=" + excludeQuery +
+                    ", prefix='" + prefix + '\'' +
+                    ", urlGenerator='" + urlGenerator + '\'' +
                     '}';
         }
 
@@ -373,7 +375,6 @@
         }
 
         public void setTab(final String tab) {
-
             this.tab = tab;
             // The tab property takes preference over any url parameters. 
intialse it here and use against urlGenerator.
             staticParameters.put(SearchTab.PARAMETER_KEY, tab);
@@ -417,12 +418,19 @@
 
         @Override
         public String toString() {
-
             return "Nav{"
                     + "id='" + id + '\''
                     + ", commandName='" + commandName + '\''
                     + ", field='" + field + '\''
+                    + ", tab='" + tab + '\''
+                    + ", backText='" + backText + '\''
+                    + ", out=" + out
+                    + ", maxsize=" + maxsize
+                    + ", autoNavigation=" + autoNavigation
                     + ", staticParameters=" + staticParameters
+                    + ", childNavs=" + (childNavs != null ? childNavs : "null")
+                    + ", parent='" + (parent != null ? parent.getId() : 
"null") + '\''
+                    + ", navigation='" + (navigation != null ? 
navigation.getId() : "null") + '\''
                     + '}';
         }
 

Modified: 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/OptionsNavigationConfig.java
===================================================================
--- 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/OptionsNavigationConfig.java
    2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/view-config-spi/src/main/java/no/sesat/search/view/navigation/OptionsNavigationConfig.java
    2008-04-19 19:06:20 UTC (rev 6502)
@@ -192,5 +192,21 @@
         public void setCommandName(String commandName) {
             this.commandName = commandName;
         }
+
+        @Override
+        public String toString() {
+            return "\nOption{" +
+                    "value='" + value + '\'' +
+                    ",displayName='" + displayName + '\'' +
+                    ", valueRef='" + valueRef + '\'' +
+                    ", defaultSelect=" + defaultSelect +
+                    ", defaultSelectValueRef='" + defaultSelectValueRef + '\'' 
+
+                    ", tab='" + tab + '\'' +
+                    ", useHitCount=" + useHitCount +
+                    ", commandName='" + commandName + '\'' +
+                    '}';
+        }
+
     }
+    
 }

Modified: 
trunk/view-control-spi/src/main/java/no/sesat/search/view/navigation/OptionNavigationController.java
===================================================================
--- 
trunk/view-control-spi/src/main/java/no/sesat/search/view/navigation/OptionNavigationController.java
        2008-04-19 18:57:01 UTC (rev 6501)
+++ 
trunk/view-control-spi/src/main/java/no/sesat/search/view/navigation/OptionNavigationController.java
        2008-04-19 19:06:20 UTC (rev 6502)
@@ -127,7 +127,6 @@
         final NavigationItem parentResult = 
dataModel.getNavigation().getNavigation(config.getParent().getId());
         final StringDataObject optionSelectedValue = 
dataModel.getParameters().getValue(config.getParent().getField());
 
-
         boolean selectionDone = false;
 
         for (final OptionsNavigationConfig.Option option : optionsToAdd) {
@@ -146,9 +145,18 @@
             }
             if (value != null) {
 
+                final Map<String,String> urlParameters;
+
+                if (option.getTab() != null) {
+                    urlParameters = new HashMap<String, String>(1);
+                    urlParameters.put(SearchTab.PARAMETER_KEY, 
option.getTab());
+                } else {
+                    urlParameters = Collections.<String, String> emptyMap();
+                }
+
                 final NavigationItem navigator = new BasicNavigationItem(
                         option.getDisplayName(),
-                        context.getUrlGenerator().getURL(value, 
config.getParent()),
+                        context.getUrlGenerator().getURL(value, 
config.getParent(), urlParameters),
                         -1);
 
                 parentResult.addResult(navigator);

Modified: 
trunk/war/src/main/java/no/sesat/search/http/filters/SiteLocatorFilter.java
===================================================================
--- trunk/war/src/main/java/no/sesat/search/http/filters/SiteLocatorFilter.java 
2008-04-19 18:57:01 UTC (rev 6501)
+++ trunk/war/src/main/java/no/sesat/search/http/filters/SiteLocatorFilter.java 
2008-04-19 19:06:20 UTC (rev 6502)
@@ -1,4 +1,4 @@
-/* Copyright (2006-2007) Schibsted Søk AS
+/* Copyright (2006-2008) Schibsted Søk AS
  * This file is part of SESAT.
  *
  *   SESAT is free software: you can redistribute it and/or modify
@@ -69,7 +69,6 @@
  * @author  <a href="mailto:[EMAIL PROTECTED]">Michael Semb Wever</a>
  * @version $Id$
  */
-
 public final class SiteLocatorFilter implements Filter {
 
     // Constants -----------------------------------------------------
@@ -91,7 +90,9 @@
     private static final String UNKNOWN = "unknown";
 
     
-    private static final String CONFIGURATION_RESOURCE= "/conf/" + 
Site.CONFIGURATION_FILE;
+    // Any request coming into Sesat with /conf/ is immediately returned as a 
404. 
+    // It should have been directed to a skin.
+    private static final String CONFIGURATION_RESOURCE= "/conf/";
 
     /** Changes to this list must also change the ProxyPass|ProxyPassReverse 
configuration in httpd.conf **/
     private static final Collection<String> EXTERNAL_DIRS =
@@ -99,7 +100,9 @@
                 PUBLISH_DIR, "/css/", "/images/", "/javascript/"
     }));
 
-    /** The context that we'll need to use every invocation of doFilter(..)  
**/
+    /** The context that we'll need to use every invocation of doFilter(..).
+     * @throws IllegalArgumentException when there exists no skin matching the 
siteContext.getSite() argument.
+     **/
     public static final Site.Context SITE_CONTEXT = new Site.Context(){
         public String getParentSiteName(final SiteContext siteContext) {
             // we have to do this manually instead of using SiteConfiguration,
@@ -108,14 +111,13 @@
             final Properties props = new Properties();
             final PropertiesLoader loader
                     = UrlResourceLoader.newPropertiesLoader(siteContext, 
Site.CONFIGURATION_FILE, props);
-            try{
-                loader.abut();
-                return props.getProperty(Site.PARENT_SITE_KEY);
-                
-            }catch(ResourceLoadException rle){
-                LOG.fatal("BROKEN SITE HIERARCHY." + rle.getMessage());
-                throw new VirtualMachineError(rle.getMessage()){};
+
+            loader.abut();
+            final String parentName = props.getProperty(Site.PARENT_SITE_KEY);
+            if(null == parentName && 0 == props.size()){
+                throw new IllegalArgumentException("Invalid site " + 
siteContext.getSite());
             }
+            return parentName;
         }
     };
 
@@ -167,9 +169,9 @@
             if(request instanceof HttpServletRequest) {
                 final HttpServletRequest httpServletRequest = 
(HttpServletRequest) request;
                 final HttpServletResponse  httpServletResponse = 
(HttpServletResponse) response;
-                if 
(httpServletRequest.getRequestURI().endsWith(CONFIGURATION_RESOURCE)){
+                if 
(httpServletRequest.getRequestURI().contains(CONFIGURATION_RESOURCE)){
                     /* We are looping, looking for a site search which does 
not exsist */
-                    LOG.debug("We are looping, looking for a site search which 
does not exist");
+                    LOG.info("We are looping, looking for a site search which 
does not exist");
                     httpServletResponse.reset();
                     
httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
                     return;
@@ -304,7 +306,7 @@
     /** The method to obtain the correct Site from the request.
      * It only returns a site with a locale supported by that site.
      ** @param servletRequest 
-     * @return 
+     * @return the site instance. or null if no such skin has been deployed.
      */
     public static Site getSite(final ServletRequest servletRequest) {
         // find the current site. Since we are behind a ajp13 connection 
request.getServerName() won't work!
@@ -322,52 +324,59 @@
 
         // Construct the site object off the browser's locale, even if it 
won't finally be used.
         final Locale locale = servletRequest.getLocale();
-        final Site result = Site.valueOf(SITE_CONTEXT, correctedVhost, locale);
-        final SiteConfiguration.Context siteConfCxt = new 
SiteConfiguration.Context(){
-            public PropertiesLoader newPropertiesLoader(
-                    final SiteContext siteCxt,
-                    final String resource,
-                    final Properties properties) {
 
-                return UrlResourceLoader.newPropertiesLoader(siteCxt, 
resource, properties);
+        final Site result;
+        try{
+            result = Site.valueOf(SITE_CONTEXT, correctedVhost, locale);
+            
+            final SiteConfiguration.Context siteConfCxt = new 
SiteConfiguration.Context(){
+                public PropertiesLoader newPropertiesLoader(
+                        final SiteContext siteCxt,
+                        final String resource,
+                        final Properties properties) {
+
+                    return UrlResourceLoader.newPropertiesLoader(siteCxt, 
resource, properties);
+                }
+                public Site getSite() {
+                    return result;
+                }
+            };
+            final SiteConfiguration siteConf = 
SiteConfiguration.instanceOf(siteConfCxt);
+            servletRequest.setAttribute(SiteConfiguration.NAME_KEY, siteConf);
+
+            if(LOG.isTraceEnabled()){ // MessageFormat.format(..) is expensive
+                LOG.trace(MessageFormat.format(
+                        LOCALE_DETAILS, locale.getLanguage(), 
locale.getCountry(), locale.getVariant()));
             }
-            public Site getSite() {
+
+            // Check if the browser's locale is supported by this skin. Use it 
if so.
+            if( siteConf.isSiteLocaleSupported(locale) ){
                 return result;
             }
-        };
-        final SiteConfiguration siteConf = 
SiteConfiguration.instanceOf(siteConfCxt);
-        servletRequest.setAttribute(SiteConfiguration.NAME_KEY, siteConf);
 
-        if(LOG.isTraceEnabled()){ // MessageFormat.format(..) is expensive
-            LOG.trace(MessageFormat.format(
-                    LOCALE_DETAILS, locale.getLanguage(), locale.getCountry(), 
locale.getVariant()));
-        }
-        
-        // Check if the browser's locale is supported by this skin. Use it if 
so.
-        if( siteConf.isSiteLocaleSupported(locale) ){
-            return result;
-        }
-        
-        // Use the skin's default locale. For some reason that fails use JVM's 
default.
-        final String[] prefLocale = null != 
siteConf.getProperty(SiteConfiguration.SITE_LOCALE_DEFAULT)
-                ? 
siteConf.getProperty(SiteConfiguration.SITE_LOCALE_DEFAULT).split("_")
-                : new String[]{Locale.getDefault().toString()};
+            // Use the skin's default locale. For some reason that fails use 
JVM's default.
+            final String[] prefLocale = null != 
siteConf.getProperty(SiteConfiguration.SITE_LOCALE_DEFAULT)
+                    ? 
siteConf.getProperty(SiteConfiguration.SITE_LOCALE_DEFAULT).split("_")
+                    : new String[]{Locale.getDefault().toString()};
 
-        switch(prefLocale.length){
+            switch(prefLocale.length){
 
-            case 3:
-                LOG.trace(result+INFO_USING_DEFAULT_LOCALE + prefLocale[0] + 
'_' + prefLocale[1] + '_' + prefLocale[2]);
-                return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0], prefLocale[1], prefLocale[2]));
+                case 3:
+                    LOG.trace(result+INFO_USING_DEFAULT_LOCALE + prefLocale[0] 
+ '_' + prefLocale[1] + '_' + prefLocale[2]);
+                    return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0], prefLocale[1], prefLocale[2]));
 
-            case 2:
-                LOG.trace(result+INFO_USING_DEFAULT_LOCALE + prefLocale[0] + 
'_' + prefLocale[1]);
-                return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0], prefLocale[1]));
+                case 2:
+                    LOG.trace(result+INFO_USING_DEFAULT_LOCALE + prefLocale[0] 
+ '_' + prefLocale[1]);
+                    return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0], prefLocale[1]));
 
-            case 1:
-            default:
-                LOG.trace(result+INFO_USING_DEFAULT_LOCALE + prefLocale[0]);
-                return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0]));
+                case 1:
+                default:
+                    LOG.trace(result+INFO_USING_DEFAULT_LOCALE + 
prefLocale[0]);
+                    return Site.valueOf(SITE_CONTEXT, correctedVhost, new 
Locale(prefLocale[0]));
 
+            }
+        }catch(IllegalArgumentException iae){
+            return null;
         }
     }
 
@@ -430,22 +439,28 @@
         LOG.trace("doBeforeProcessing()");
 
         final Site site = getSite(request);
+        
+        if(null != site){
 
-        final DataModel dataModel = getDataModel(request);
+            final DataModel dataModel = getDataModel(request);
 
-        if (null != dataModel && !dataModel.getSite().getSite().equals(site)) {
-            LOG.warn(WARN_FAULTY_BROWSER + 
dataModel.getBrowser().getUserAgent().getXmlEscaped());
-            // DataModelFilter will correct it
-        }
+            if (null != dataModel && 
!dataModel.getSite().getSite().equals(site)) {
+                LOG.warn(WARN_FAULTY_BROWSER + 
dataModel.getBrowser().getUserAgent().getXmlEscaped());
+                // DataModelFilter will correct it
+            }
 
-        request.setAttribute(Site.NAME_KEY, site);
-        request.setAttribute("startTime", FindResource.START_TIME);
-        MDC.put(Site.NAME_KEY, site.getName());
-        MDC.put("UNIQUE_ID", getRequestId(request));
+            request.setAttribute(Site.NAME_KEY, site);
+            request.setAttribute("startTime", FindResource.START_TIME);
+            MDC.put(Site.NAME_KEY, site.getName());
+            MDC.put("UNIQUE_ID", getRequestId(request));
+
+            /* Setting default encoding */
+            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding("UTF-8");
         
-        /* Setting default encoding */
-        request.setCharacterEncoding("UTF-8");
-        response.setCharacterEncoding("UTF-8");
+        }else{
+            throw new ServletException("SiteLocatorFilter with no Site :-(");
+        }
     }
 
     private void doAfterProcessing(final ServletRequest request, final 
ServletResponse response)

Modified: 
trunk/war/src/main/java/no/sesat/search/http/filters/UrlRewriteFilter.java
===================================================================
--- trunk/war/src/main/java/no/sesat/search/http/filters/UrlRewriteFilter.java  
2008-04-19 18:57:01 UTC (rev 6501)
+++ trunk/war/src/main/java/no/sesat/search/http/filters/UrlRewriteFilter.java  
2008-04-19 19:06:20 UTC (rev 6502)
@@ -34,6 +34,9 @@
 
 /** Override of tuckey's UrlRewriteFilter that supplies an inputstream to the 
skins's urlrewrite.xml
  *   instead of the default /WEB-INF/urlrewrite.xml
+ * 
+ * Make sure that any urlrewrite.xml has the attributes in the root element:
+ * &lt;urlrewrite decode-using="null" use-query-string="true"&gt;
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Mck</a>
  * @version <tt>$Id$</tt>
@@ -52,7 +55,6 @@
     
     // Public --------------------------------------------------------
     
-    /** [EMAIL PROTECTED] **/
     @Override
     public UrlRewriterContainer getUrlRewriterContainer(final ServletRequest 
request){
         

Modified: trunk/war/src/main/java/no/sesat/search/http/filters/UserFilter.java
===================================================================
--- trunk/war/src/main/java/no/sesat/search/http/filters/UserFilter.java        
2008-04-19 18:57:01 UTC (rev 6501)
+++ trunk/war/src/main/java/no/sesat/search/http/filters/UserFilter.java        
2008-04-19 19:06:20 UTC (rev 6502)
@@ -280,20 +280,23 @@
 
         LOG.debug("Url: " + url);
         LOG.debug("JndiName: " + jndi);
+        
+        if( null != url && null != jndi ){
 
-        final Properties properties = new Properties();
-        properties.put("java.naming.factory.initial", 
"org.jnp.interfaces.NamingContextFactory");
-        properties.put("java.naming.factory.url.pkgs", 
"org.jboss.naming:org.jnp.interfaces");
-        properties.put("java.naming.provider.url", url);
+            final Properties properties = new Properties();
+            properties.put("java.naming.factory.initial", 
"org.jnp.interfaces.NamingContextFactory");
+            properties.put("java.naming.factory.url.pkgs", 
"org.jboss.naming:org.jnp.interfaces");
+            properties.put("java.naming.provider.url", url);
 
-        try {
-            return (BasicUserService) new 
InitialContext(properties).lookup(jndi);
+            try {
+                return (BasicUserService) new 
InitialContext(properties).lookup(jndi);
 
-        } catch (final NamingException ne) {
-            // acceptable for sesat not to have to have a user service backend
-            LOG.debug(ne.getMessage(), ne);
-            return null;
+            } catch (final NamingException ne) {
+                // acceptable for sesat not to have to have a user service 
backend
+                LOG.debug(ne.getMessage(), ne);
+            }
         }
+        return null;
     }
 
 }

Modified: trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml
===================================================================
--- trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml    2008-04-19 18:57:01 UTC 
(rev 6501)
+++ trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml    2008-04-19 19:06:20 UTC 
(rev 6502)
@@ -23,7 +23,7 @@
     Description:
         Purpose of the document follows.
 -->
-<urlrewrite decode-using="null">
+<urlrewrite decode-using="null" use-query-string="true">
     <!-- Global rewrites applicable to every skin (sitesearch and country!) -->
 
     <!-- tomcat puts in the name of the welcome page -->

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to