Author: ssmiweve
Date: 2008-01-23 12:03:35 +0100 (Wed, 23 Jan 2008)
New Revision: 6017
Added:
tags/alpha-deployments/200801231204-sesat-kernel/
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
Removed:
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
Log:
sesat alpha deployment
Copied: tags/alpha-deployments/200801231204-sesat-kernel (from rev 6011, trunk)
Deleted:
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
===================================================================
--- trunk/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
2008-01-23 07:43:26 UTC (rev 6011)
+++
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
2008-01-23 11:03:35 UTC (rev 6017)
@@ -1,141 +0,0 @@
-/*
- * Copyright (2006-2007) Schibsted Søk AS
- * This file is part of SESAT.
- *
- * SESAT is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * SESAT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
- */
-package no.sesat.search.http.servlet;
-
-import java.io.UnsupportedEncodingException;
-import java.util.logging.Level;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import no.sesat.search.datamodel.DataModel;
-import no.sesat.search.datamodel.generic.StringDataObject;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.log4j.Logger;
-
-/**
- * Logs different statistics with ajax
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Kjaerstad</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Mck</a>
- * @version <tt>$Id: 3361 $</tt>
- *
- */
-public final class BoomerangServlet extends HttpServlet {
-
- private static final Logger LOG = Logger.getLogger(BoomerangServlet.class);
- private static final Logger ACCESS = Logger.getLogger("no.sesat.Access");
-
- private static final String CEREMONIAL = "/boomerang";
-
- @Override
- public void destroy() { }
-
- @Override
- public void init() { }
-
- @Override
- protected void doGet(final HttpServletRequest req, final
HttpServletResponse res)
- throws ServletException, IOException {
-
- // clients must not cache these requests
- res.setHeader("Cache-Control", "no-cache, must-revalidate,
post-check=0, pre-check=0");
- res.setHeader("Pragma", "no-cache"); // for old browsers
- res.setDateHeader("Expires", 0); // to be double-safe
-
- if(req.getServletPath().startsWith(CEREMONIAL)){
-
- // ceremonial boomerang
- final StringBuffer url = req.getRequestURL();
- if(null != req.getQueryString()){
- url.append('?' + req.getQueryString());
- }
-
- // pick out the entrails
- final String grub = url.substring(
- url.indexOf(CEREMONIAL) + CEREMONIAL.length() + 1,
- url.indexOf("/", url.indexOf(CEREMONIAL) +
CEREMONIAL.length() + 1));
- LOG.debug(grub);
-
- // the url to return to
- final String destination = url.substring(
- url.indexOf("/", url.indexOf(CEREMONIAL) +
CEREMONIAL.length() + 1) + 1);
-
- // grub it up
- final Map<String,String> entrails = new HashMap<String,String>();
- if(0 < grub.length()){
- final StringTokenizer tokeniser = new StringTokenizer(grub,
";");
- while(tokeniser.hasMoreTokens()){
- final String[] entry = tokeniser.nextToken().split("=");
- entrails.put(entry[0], 1 < entry.length ? entry[1] :
entry[0]);
- }
- }
- entrails.put("boomerang", destination);
- kangerooGrub(entrails);
-
- LOG.debug("Ceremonial boomerang to " + destination.toString());
- res.sendRedirect(destination.toString());
-
- }else{
-
- // hunting boomerang, just grub
- final DataModel datamodel = (DataModel)
req.getSession().getAttribute(DataModel.KEY);
- kangerooGrub(datamodel.getParameters().getValues());
-
- }
-
- }
-
- private void kangerooGrub(final Map<String,?> params){
-
- final List<String> paramKeys = new ArrayList<String>(params.keySet());
-
- Collections.sort(paramKeys);
-
- final StringBuilder bob = new StringBuilder("<boomerang>");
-
- for(String key : paramKeys){
- try {
-
- final String value = params.get(key) instanceof
StringDataObject
- ? ((StringDataObject) params.get(key)).getXmlEscaped()
- : StringEscapeUtils.escapeXml((String)
params.get(key));
-
- // it's critical for the logparser that we write valid xml
- final String keyEscaped =
StringEscapeUtils.escapeXml(URLDecoder.decode(key, "UTF-8"));
- if (!keyEscaped.contains("%")) {
- bob.append('<' + keyEscaped + '>' + value + "</" +
keyEscaped + '>');
- }else{
- bob.append("<doubled-url-encoded-tag-ignored-here/>");
- }
- }catch (UnsupportedEncodingException ex) {
- LOG.error("Failed to kangerooGrub " + key, ex);
- }
- }
- bob.append("</boomerang>");
- ACCESS.info(bob.toString());
- }
-}
Copied:
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
(from rev 6015,
trunk/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java)
===================================================================
---
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
(rev 0)
+++
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/java/no/sesat/search/http/servlet/BoomerangServlet.java
2008-01-23 11:03:35 UTC (rev 6017)
@@ -0,0 +1,150 @@
+/*
+ * Copyright (2006-2007) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+ */
+package no.sesat.search.http.servlet;
+
+import java.io.UnsupportedEncodingException;
+import java.util.logging.Level;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import no.sesat.search.datamodel.DataModel;
+import no.sesat.search.datamodel.generic.StringDataObject;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+
+/**
+ * Logs different statistics with ajax
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Kjaerstad</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mck</a>
+ * @version <tt>$Id: 3361 $</tt>
+ *
+ */
+public final class BoomerangServlet extends HttpServlet {
+
+ private static final Logger LOG = Logger.getLogger(BoomerangServlet.class);
+ private static final Logger ACCESS = Logger.getLogger("no.sesat.Access");
+
+ private static final String CEREMONIAL = "/boomerang";
+
+ @Override
+ public void destroy() { }
+
+ @Override
+ public void init() { }
+
+ @Override
+ protected void doGet(final HttpServletRequest req, final
HttpServletResponse res)
+ throws ServletException, IOException {
+
+ // clients must not cache these requests
+ res.setHeader("Cache-Control", "no-cache, must-revalidate,
post-check=0, pre-check=0");
+ res.setHeader("Pragma", "no-cache"); // for old browsers
+ res.setDateHeader("Expires", 0); // to be double-safe
+
+ if(req.getServletPath().startsWith(CEREMONIAL)){
+
+ // ceremonial boomerang
+ final StringBuffer url = req.getRequestURL();
+ if(null != req.getQueryString()){
+ url.append('?' + req.getQueryString());
+ }
+
+ // pick out the entrails
+ final String grub = url.substring(
+ url.indexOf(CEREMONIAL) + CEREMONIAL.length() + 1,
+ url.indexOf("/", url.indexOf(CEREMONIAL) +
CEREMONIAL.length() + 1));
+ LOG.debug(grub);
+
+ // the url to return to
+ final String destination = url.substring(
+ url.indexOf("/", url.indexOf(CEREMONIAL) +
CEREMONIAL.length() + 1) + 1);
+
+ // grub it up
+ final Map<String,String> entrails = new HashMap<String,String>();
+ if(0 < grub.length()){
+ final StringTokenizer tokeniser = new StringTokenizer(grub,
";");
+ while(tokeniser.hasMoreTokens()){
+ final String[] entry = tokeniser.nextToken().split("=");
+ entrails.put(entry[0], 1 < entry.length ? entry[1] :
entry[0]);
+ }
+ }
+ entrails.put("boomerang", destination);
+ kangerooGrub(entrails);
+
+ LOG.debug("Ceremonial boomerang to " + destination.toString());
+ if(req.getHeader("User-agent").matches("(Googlebot|Slurp|Yahoo\\!
Slurp)")){
+ // crawlers like permanent redirects. and we're not interested
in their clicks so ok to cache.
+ res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
+ res.setHeader("Location", destination.toString());
+ res.setHeader("Connection", "close");
+
+ }else{
+ // default behaviour for users.
+ res.sendRedirect(destination.toString());
+ }
+
+ }else{
+
+ // hunting boomerang, just grub
+ final DataModel datamodel = (DataModel)
req.getSession().getAttribute(DataModel.KEY);
+ kangerooGrub(datamodel.getParameters().getValues());
+
+ }
+
+ }
+
+ private void kangerooGrub(final Map<String,?> params){
+
+ final List<String> paramKeys = new ArrayList<String>(params.keySet());
+
+ Collections.sort(paramKeys);
+
+ final StringBuilder bob = new StringBuilder("<boomerang>");
+
+ for(String key : paramKeys){
+ try {
+
+ final String value = params.get(key) instanceof
StringDataObject
+ ? ((StringDataObject) params.get(key)).getXmlEscaped()
+ : StringEscapeUtils.escapeXml((String)
params.get(key));
+
+ // it's critical for the logparser that we write valid xml
+ final String keyEscaped =
StringEscapeUtils.escapeXml(URLDecoder.decode(key, "UTF-8"));
+ if (!keyEscaped.contains("%")) {
+ bob.append('<' + keyEscaped + '>' + value + "</" +
keyEscaped + '>');
+ }else{
+ bob.append("<doubled-url-encoded-tag-ignored-here/>");
+ }
+ }catch (UnsupportedEncodingException ex) {
+ LOG.error("Failed to kangerooGrub " + key, ex);
+ }
+ }
+ bob.append("</boomerang>");
+ ACCESS.info(bob.toString());
+ }
+}
Deleted:
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
===================================================================
--- trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml 2008-01-23 07:43:26 UTC
(rev 6011)
+++
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
2008-01-23 11:03:35 UTC (rev 6017)
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
"../dtds/urlrewrite3.0.dtd">
-<!-- Copyright (2007) Schibsted Søk AS
- * This file is part of SESAT.
- *
- * SESAT is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * SESAT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
-
- Document : urlrewrite.xml
- Created on : 19 March 2007, 14:43
- Author : mick
- Version : $Id$
- Description:
- Purpose of the document follows.
--->
-<urlrewrite decode-using="null">
- <!-- Global rewrites applicable to every skin (sitesearch and country!) -->
-
- <!-- tomcat puts in the name of the welcome page -->
- <rule><from>^/index.jsp$</from><to>/</to></rule>
- <rule><from>^/robots.txt$</from><to>/robots.jsp</to></rule>
- <rule><from>^/psearch/(.*)$</from><to>/search/$1</to></rule>
-
-
- <!-- Everything non-specified falls back to the default search
(unspecified c parameter) -->
- <!-- TODO more work is needed to exclude
- - /search/(.*)
- - /map/(.*)
- - /servlet/(.*)
- - /dtds/(.*)
- - /export/(.*)
- - /static/(.*)
- - /tradedoubler/(.*)
- - before enabling the following very generic rewrite.
- -->
- <!--rule><from>^/(.+)$</from><to>/search/?q=$1</to></rule-->
-</urlrewrite>
Copied:
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
(from rev 6016, trunk/war/src/main/webapp/WEB-INF/urlrewrite.xml)
===================================================================
---
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
(rev 0)
+++
tags/alpha-deployments/200801231204-sesat-kernel/war/src/main/webapp/WEB-INF/urlrewrite.xml
2008-01-23 11:03:35 UTC (rev 6017)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
"../dtds/urlrewrite3.0.dtd">
+<!-- Copyright (2007) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+
+ Document : urlrewrite.xml
+ Created on : 19 March 2007, 14:43
+ Author : mick
+ Version : $Id$
+ Description:
+ Purpose of the document follows.
+-->
+<urlrewrite decode-using="null">
+ <!-- Global rewrites applicable to every skin (sitesearch and country!) -->
+
+ <!-- tomcat puts in the name of the welcome page -->
+ <rule><from>^/index.jsp$</from><to>/</to></rule>
+ <rule><from>^/robots.txt$</from><to>/robots.jsp</to></rule>
+ <rule><from>^/psearch/(.*)$</from><to>/search/$1</to></rule>
+
+
+ <!-- Everything non-specified falls back to the default search
(unspecified c parameter) -->
+ <!-- We make the presumption that all the following urls (that we must
still honour) contain a second '/'
+ - /search/(.*)
+ - /map/(.*)
+ - /servlet/(.*)
+ - /dtds/(.*)
+ - /export/(.*)
+ - /static/(.*)
+ - /tradedoubler/(.*)
+ -->
+ <rule><from>^/([^/]+)$</from><to>/search/?q=$1</to></rule>
+</urlrewrite>
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits