roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r428921 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated: CommentServlet.java OldFeedRequest.java OldPageRequest.java RedirectServlet.java
Date Fri, 04 Aug 2006 23:14:14 GMT
Author: agilliland
Date: Fri Aug  4 16:14:13 2006
New Revision: 428921

URL: http://svn.apache.org/viewvc?rev=428921&view=rev
Log:
adding redirect servlet to handle backwards compatability for old pre-3.0 urls.


Added:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldFeedRequest.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageRequest.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/RedirectServlet.java
Removed:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/CommentServlet.java

Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldFeedRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldFeedRequest.java?rev=428921&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldFeedRequest.java
(added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldFeedRequest.java
Fri Aug  4 16:14:13 2006
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.velocity.deprecated;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.pojos.WeblogTemplate;
+
+
+/**
+ * Represents a request for an *old* Roller weblog feed.
+ * 
+ * any of /rss/*, /atom/*, /flavor/*
+ *
+ * While these urls are no longer used we do provide redirect support for them
+ * for users who have upgraded from earlier versions.  We keep this class to
+ * help with parsing these urls since they are fairly complex.
+ */
+public class OldFeedRequest {
+    
+    private static Log mLogger = LogFactory.getLog(OldFeedRequest.class);
+    
+    private static Set feedServlets = new HashSet();
+    
+    private String context = null;
+    private String flavor = null;
+    private String weblogHandle = null;
+    private String weblogCategory = null;
+    private boolean excerpts = false;
+    
+    
+    static {
+        // initialize our servlet list
+        feedServlets.add("rss");
+        feedServlets.add("flavor");
+        feedServlets.add("atom");
+    }
+    
+    
+    /**
+     * Construct the WeblogFeedRequest by parsing the incoming url
+     */
+    public OldFeedRequest(HttpServletRequest request) throws Exception {
+        
+        // parse the request object and figure out what we've got
+        mLogger.debug("parsing url "+request.getRequestURL());
+        
+        String servlet = request.getServletPath();
+        String pathInfo = request.getPathInfo();
+        
+        // what servlet is our destination?
+        if(servlet != null) {
+            // strip off the leading slash
+            servlet = servlet.substring(1);
+            
+            if(feedServlets.contains(servlet)) {
+                this.context = "weblog";
+                this.flavor = servlet;
+            } else {
+                // not a request to a feed servlet
+                throw new Exception("not a weblog feed request, "+request.getRequestURL());
+            }
+        } else {
+            throw new Exception("not a weblog feed request, "+request.getRequestURL());
+        }
+        
+        // parse the path info
+        if(pathInfo != null && pathInfo.trim().length() > 1) {
+            // strip off the leading slash
+            pathInfo = pathInfo.substring(1);
+            String[] pathElements = pathInfo.split("/");
+            
+            if(pathElements[0].length() > 0) {
+                this.weblogHandle = pathElements[0];
+            }
+            
+        } else {
+            
+            // no path info means this was a non-weblog request
+            // we handle a few exceptions for this which include
+            //   /rss - main rss feed
+            //   /atom - main atom feed
+            //   /flavor - main flavor feed
+            
+            this.context = "main";
+        }
+        
+        /* 
+         * parse request parameters
+         *
+         * the only params we currently care about are:
+         *   flavor - defines the feed type
+         *   catname - specifies a weblog category
+         *   path - specifies a weblog category
+         *   excerpts - specifies the feed should only include excerpts
+         *
+         */
+        if(request.getParameter("flavor") != null) {
+            this.flavor = request.getParameter("flavor");
+        }
+        
+        if(request.getParameter("path") != null) {
+            this.weblogCategory = request.getParameter("path");
+        }
+        
+        if(request.getParameter("catname") != null) {
+            this.weblogCategory = request.getParameter("catname");
+        }
+        
+        if(request.getParameter("excerpts") != null) {
+            this.excerpts = Boolean.valueOf(request.getParameter("excerpts")).booleanValue();
+        }
+        
+        // one small final adjustment.
+        // if our flavor is "flavor" then that means someone is just getting
+        // the default flavor, which is rss, so let's set that
+        if(this.flavor.equals("flavor")) {
+            this.flavor = "rss";
+        }
+        
+    }
+    
+
+    public String getContext() {
+        return context;
+    }
+
+    public String getFlavor() {
+        return flavor;
+    }
+
+    public String getWeblogHandle() {
+        return weblogHandle;
+    }
+
+    public String getWeblogCategory() {
+        return weblogCategory;
+    }
+
+    public boolean isExcerpts() {
+        return excerpts;
+    }
+
+}

Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageRequest.java?rev=428921&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageRequest.java
(added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageRequest.java
Fri Aug  4 16:14:13 2006
@@ -0,0 +1,216 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.ui.rendering.velocity.deprecated;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.pojos.WeblogTemplate;
+import org.apache.roller.util.Utilities;
+
+
+/**
+ * Represents an *old* request for a Roller weblog page.
+ * 
+ * any url from ... /page/*
+ * 
+ * While these urls are no longer used we do provide redirect support for them
+ * for users who have upgraded from earlier versions.  We keep this class to
+ * help with parsing these urls since they are fairly complex.
+ */
+public class OldPageRequest {
+    
+    private static Log mLogger = LogFactory.getLog(OldPageRequest.class);
+    
+    // various page types
+    public static final String MAIN = "main";
+    public static final String PERMALINK = "permalink";
+    public static final String ARCHIVE = "archive";
+    
+    private String context = null;
+    private String pageType = null;
+    private String weblogHandle = null;
+    private String weblogAnchor = null;
+    private String weblogPage = null;
+    private String weblogCategory = null;
+    private String weblogDate = null;
+    
+    
+    /**
+     * Construct the WeblogPageRequest by parsing the incoming url
+     */
+    public OldPageRequest(HttpServletRequest request) throws Exception {
+        
+        // parse the request object and figure out what we've got
+        mLogger.debug("parsing url "+request.getRequestURL());
+        
+        String servlet = request.getServletPath();
+        String pathInfo = request.getPathInfo();
+        
+        // make sure this request was destined for the page servlet
+        if(servlet != null) {
+            // strip off the leading slash
+            servlet = servlet.substring(1);
+            
+            if("page".equals(servlet)) {
+                this.context = "weblog";
+            } else {
+                // not a request to the page servlet
+                throw new Exception("not a weblog page request, "+request.getRequestURL());
+            }
+        } else {
+            throw new Exception("not a weblog page request, "+request.getRequestURL());
+        }
+        
+        
+        /*
+         * parse path info
+         *
+         * we expect one of the following forms of urls ...
+         *
+         * [handle] - get default page for user for today's date
+         * [handle]/[date] - get default page for user for specified date
+         * [handle]/[pagelink] - get specified page for today's date
+         * [handle]/[pagelink]/[date] - get specified page for specified date
+         * [handle]/[pagelink]/[anchor] - get specified page & entry (by anchor)
+         * [handle]/[pagelink]/[date]/[anchor] - get specified page & entry (by anchor)
+         */
+        if(pathInfo != null && pathInfo.trim().length() > 1) {
+            // strip off the leading slash
+            pathInfo = pathInfo.substring(1);
+            String[] pathElements = pathInfo.split("/");
+            
+            if ( pathElements.length == 1 ) {
+                
+                // /handle
+                this.weblogHandle = pathElements[0];
+                this.weblogPage = WeblogTemplate.DEFAULT_PAGE;
+                this.pageType = MAIN;
+                
+            } else if ( pathElements.length == 2 ) {
+                
+                // /handle/date or /handle/page
+                this.weblogHandle = pathElements[0];
+                this.weblogPage = WeblogTemplate.DEFAULT_PAGE;
+                
+                if(this.isValidDateString(pathElements[1])) {
+                    this.weblogDate = pathElements[1];
+                    this.pageType = ARCHIVE;
+                } else {
+                    this.weblogPage = pathElements[1];
+                    this.pageType = MAIN;
+                }
+                
+            } else if ( pathElements.length == 3 ) {
+                
+                // /handle/page/date or /handle/page/anchor
+                this.weblogHandle = pathElements[0];
+                this.weblogPage = pathElements[1];
+                
+                if(this.isValidDateString(pathElements[2])) {
+                    this.weblogDate = pathElements[2];
+                    this.pageType = ARCHIVE;
+                } else {
+                    this.weblogAnchor = pathElements[2];
+                    this.pageType = PERMALINK;
+                }
+                
+            } else if ( pathElements.length == 4 ) {
+                
+                // /handle/page/date/anchor
+                this.weblogHandle = pathElements[0];
+                this.weblogPage = pathElements[1];
+                this.weblogDate = pathElements[2];
+                this.weblogAnchor = pathElements[3];
+                this.pageType = PERMALINK;
+            }
+            
+        } else {
+            // invalid request ... path info is empty
+            throw new Exception("not a weblog page request, "+request.getRequestURL());
+        }
+        
+        
+        /*
+         * parse request parameters
+         *
+         * the only params we currently care about are:
+         *   anchor - specifies a weblog entry
+         *   entry - specifies a weblog entry
+         *   catname - specifies a weblog category
+         */
+        if(request.getParameter("anchor") != null) {
+            this.weblogAnchor = request.getParameter("anchor");
+            this.pageType = PERMALINK;
+        }
+        
+        if(request.getParameter("entry") != null) {
+            this.weblogAnchor = request.getParameter("entry");
+            this.pageType = PERMALINK;
+        }
+        
+        if(request.getParameter("catname") != null) {
+            String cat = request.getParameter("catname");
+            
+            this.weblogCategory = cat;
+            this.pageType = ARCHIVE;
+        }
+
+    }
+    
+    
+    private boolean isValidDateString(String dateString) {
+        return (dateString != null && dateString.length() > 3 && StringUtils.isNumeric(dateString));
+    }
+
+    public String getContext() {
+        return context;
+    }
+
+    public String getWeblogHandle() {
+        return weblogHandle;
+    }
+
+    public String getWeblogAnchor() {
+        return weblogAnchor;
+    }
+
+    public String getWeblogPage() {
+        return weblogPage;
+    }
+
+    public String getWeblogCategory() {
+        return weblogCategory;
+    }
+
+    public String getWeblogDate() {
+        return weblogDate;
+    }
+
+    public String getPageType() {
+        return pageType;
+    }
+    
+}

Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/RedirectServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/RedirectServlet.java?rev=428921&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/RedirectServlet.java
(added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/RedirectServlet.java
Fri Aug  4 16:14:13 2006
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.velocity.deprecated;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.config.RollerRuntimeConfig;
+import org.apache.roller.util.URLUtilities;
+
+
+/**
+ * Redirect pre-3.0 urls to new location using 301 redirects.
+ *
+ * @web.servlet name="RedirectServlet" load-on-startup="9"
+ * @web.servlet-mapping url-pattern="/language/*"
+ * @web.servlet-mapping url-pattern="/comments/*"
+ * @web.servlet-mapping url-pattern="/resource/*"
+ * @web.servlet-mapping url-pattern="/rsd/*"
+ * @web.servlet-mapping url-pattern="/flavor/*"
+ * @web.servlet-mapping url-pattern="/rss/*"
+ * @web.servlet-mapping url-pattern="/atom/*"
+ * @web.servlet-mapping url-pattern="/page/*"
+ * @web.servlet-mapping url-pattern="/search/*"
+ * @web.servlet-mapping url-pattern="/xmlrpc/*"
+ * @web.servlet-mapping url-pattern="/editor/*"
+ * @web.servlet-mapping url-pattern="/admin/*"
+ */
+public class RedirectServlet extends HttpServlet {
+    
+    private static Log log = LogFactory.getLog(RedirectServlet.class);
+    
+    public static final String LanguageServlet = "language";
+    public static final String CommentsServlet = "comments";
+    public static final String ResourceServlet = "resource";
+    public static final String RsdServlet = "rsd";
+    public static final String FlavorServlet = "flavor";
+    public static final String RssServlet = "rss";
+    public static final String AtomServlet = "atom";
+    public static final String PageServlet = "page";
+    public static final String SearchServlet = "search";
+    public static final String XmlrpcServlet = "xmlrpc";
+    public static final String EditorUI = "editor";
+    public static final String AdminUI = "admin";
+    
+    
+    /**
+     * Handle GET requests.
+     *
+     * All we are doing is calculating the new url for the given resource and
+     * sending a 301 redirect to it's new location.
+     */
+    public void doGet(HttpServletRequest request, HttpServletResponse response) 
+            throws ServletException, IOException {
+        
+        String redirectUrl = null;
+        
+        // figure out what servlet the request was destined for and parse
+        String servlet = request.getServletPath();
+        if(servlet != null && servlet.trim().length() > 1) {
+            
+            // strip off the leading slash
+            servlet = servlet.substring(1);
+            
+            // strip off trailing slash if needed
+            if(servlet.endsWith("/")) {
+                servlet = servlet.substring(0, servlet.length() - 1);
+            }
+        } else {
+            // bad request, 404
+        }
+        
+        log.debug("uri = "+request.getRequestURI());
+        log.debug("path info = "+request.getPathInfo());
+        
+        
+        // language servlet
+        if(LanguageServlet.equals(servlet)) {
+            redirectUrl = figureLanguageRedirect(request);
+            
+        // comments servlet
+        } else if(CommentsServlet.equals(servlet)) {
+            // old comments page was an extension of page servlet
+            // so redirects are the same
+            redirectUrl = figurePageRedirect(request);
+            
+        // resource servlet
+        } else if(ResourceServlet.equals(servlet)) {
+            redirectUrl = figureResourceRedirect(request);
+            
+        // rsd servlet
+        } else if(RsdServlet.equals(servlet)) {
+            redirectUrl = figureRsdRedirect(request);
+            
+        // flavor servlet
+        } else if(FlavorServlet.equals(servlet)) {
+            redirectUrl = figureFeedRedirect(request);
+            
+        // rss servlet
+        } else if(RssServlet.equals(servlet)) {
+            redirectUrl = figureFeedRedirect(request);
+            
+        // atom servlet
+        } else if(AtomServlet.equals(servlet)) {
+            redirectUrl = figureFeedRedirect(request);
+            
+        // page servlet
+        } else if(PageServlet.equals(servlet)) {
+            redirectUrl = figurePageRedirect(request);
+            
+        // search servlet
+        } else if(SearchServlet.equals(servlet)) {
+            redirectUrl = figureSearchRedirect(request);
+            
+        // xmlrpc servlet
+        } else if(XmlrpcServlet.equals(servlet)) {
+            redirectUrl = figureXmlrpcRedirect(request);
+            
+        // editor UI
+        } else if(EditorUI.equals(servlet)) {
+            redirectUrl = figureEditorRedirect(request);
+            
+        // admin UI
+        } else if(AdminUI.equals(servlet)) {
+            redirectUrl = figureAdminRedirect(request);
+        }
+        
+        if(redirectUrl != null) {
+            log.debug("redirecting to "+redirectUrl);
+            
+            // send an HTTP 301 response
+            response.setStatus(response.SC_MOVED_PERMANENTLY);
+            response.setHeader("Location", redirectUrl);
+        } else {
+            // no redirect, send 404
+            response.sendError(response.SC_NOT_FOUND);
+        }
+    }
+    
+    
+    // language servlet has no new equivalent, so just redirect to weblog homepage
+    private String figureLanguageRedirect(HttpServletRequest request) {
+        
+        String newUrl = RollerRuntimeConfig.getRelativeContextURL();
+        
+        String pathInfo = request.getPathInfo();
+        if(pathInfo == null) {
+            return null;
+        } else {
+            pathInfo = pathInfo.substring(1);
+        }
+        
+        String[] pathElements = pathInfo.split("/", 2);
+        return newUrl+"/"+pathElements[0]+"/";
+    }
+    
+    
+    // redirect to new weblog resource location
+    private String figureResourceRedirect(HttpServletRequest request) {
+        
+        String newUrl = RollerRuntimeConfig.getRelativeContextURL();
+        
+        String pathInfo = request.getPathInfo();
+        if(pathInfo == null) {
+            return null;
+        } else {
+            pathInfo = pathInfo.substring(1);
+        }
+        
+        String[] pathElements = pathInfo.split("/", 2);
+        if(pathElements.length != 2) {
+            return null;
+        }
+        
+        return newUrl+"/"+pathElements[0]+"/resource/"+pathElements[1];
+    }
+    
+    
+    // redirect to new weblog rsd location
+    private String figureRsdRedirect(HttpServletRequest request) {
+        
+        String newUrl = RollerRuntimeConfig.getRelativeContextURL();
+        
+        String pathInfo = request.getPathInfo();
+        if(pathInfo == null) {
+            return null;
+        } else {
+            pathInfo = pathInfo.substring(1);
+        }
+        
+        String[] pathElements = pathInfo.split("/", 2);
+        return newUrl+"/"+pathElements[0]+"/rsd";
+    }
+    
+    
+    // redirect to new weblog feed location
+    private String figureFeedRedirect(HttpServletRequest request) {
+        
+        OldFeedRequest feedRequest = null;
+        try {
+            // get parsed version of old feed request
+            feedRequest = new OldFeedRequest(request);
+        } catch (Exception ex) {
+            return null;
+        }
+        
+        String weblog = feedRequest.getWeblogHandle();
+        if(weblog == null) {
+            // must be site-wide feed
+            weblog = RollerRuntimeConfig.getProperty("site.frontpage.weblog.handle");
+        }
+        
+        String newUrl = RollerRuntimeConfig.getRelativeContextURL();
+        newUrl += "/"+weblog+"/feed/entries/"+feedRequest.getFlavor();
+        
+        Map params = new HashMap();
+        if(feedRequest.getWeblogCategory() != null) {
+            params.put("cat", URLUtilities.encode(feedRequest.getWeblogCategory()));
+        }
+        if(feedRequest.isExcerpts()) {
+            params.put("excerpts", "true");
+        }
+        
+        return newUrl + URLUtilities.getQueryString(params);
+    }
+    
+    
+    // redirect to new weblog page location
+    private String figurePageRedirect(HttpServletRequest request) {
+        
+        OldPageRequest pageRequest = null;
+        try {
+            // get parsed version of old page request
+            pageRequest = new OldPageRequest(request);
+        } catch (Exception ex) {
+            return null;
+        }
+        
+        StringBuffer url = new StringBuffer();
+        Map params = new HashMap();
+        
+        url.append(RollerRuntimeConfig.getRelativeContextURL());
+        url.append("/").append(pageRequest.getWeblogHandle()).append("/");
+        
+        if(pageRequest.getWeblogPage() != null && 
+                !"Weblog".equals(pageRequest.getWeblogPage())) {
+            
+            // a custom page name, so they get the new /weblog/page/name url
+            url.append("page/").append(pageRequest.getWeblogPage());
+            
+            // we also allow for params on custom pages
+            if(pageRequest.getWeblogDate() != null) {
+                params.put("date", pageRequest.getWeblogDate());
+            }
+            if(pageRequest.getWeblogCategory() != null) {
+                params.put("cat", URLUtilities.encode(pageRequest.getWeblogCategory()));
+            }
+            if(pageRequest.getWeblogAnchor() != null) {
+                params.put("entry", URLUtilities.encode(pageRequest.getWeblogAnchor()));
+            }
+            
+        } else if(pageRequest.getWeblogAnchor() != null) {
+            
+            // permalink url
+            url.append("entry/").append(URLUtilities.encode(pageRequest.getWeblogAnchor()));
+            
+        } else if(pageRequest.getWeblogCategory() != null && pageRequest.getWeblogDate()
== null) {
+            String cat = pageRequest.getWeblogCategory();
+            if(pageRequest.getWeblogCategory().startsWith("/")) {
+                cat = pageRequest.getWeblogCategory().substring(1);
+            }
+            
+            url.append("category/").append(URLUtilities.encode(cat));
+            
+        } else if(pageRequest.getWeblogDate() != null && pageRequest.getWeblogCategory()
== null) {
+            url.append("date/").append(pageRequest.getWeblogDate());  
+            
+        } else {
+            if(pageRequest.getWeblogDate() != null) {
+                params.put("date", pageRequest.getWeblogDate());
+            }
+            if(pageRequest.getWeblogCategory() != null) {
+                params.put("cat", URLUtilities.encode(pageRequest.getWeblogCategory()));
+            }
+        }
+        
+        return url.toString() + URLUtilities.getQueryString(params);
+    }
+    
+    
+    // redirect to new search servlet
+    private String figureSearchRedirect(HttpServletRequest request) {
+        
+        String newUrl = RollerRuntimeConfig.getRelativeContextURL();
+        
+        String pathInfo = request.getPathInfo();
+        if(pathInfo == null) {
+            return null;
+        } else {
+            pathInfo = pathInfo.substring(1);
+        }
+        
+        String[] pathElements = pathInfo.split("/", 2);
+        newUrl += "/"+pathElements[0]+"/search";
+        
+        // query params
+        Map params = new HashMap();
+        if(request.getParameter("q") != null && 
+                request.getParameter("q").trim().length() > 0) {
+            
+            params.put("q", request.getParameter("q"));
+            
+            if(request.getParameter("c") != null && 
+                request.getParameter("c").trim().length() > 0) {
+                params.put("cat", request.getParameter("c"));
+            }
+        }
+        
+        return newUrl + URLUtilities.getQueryString(params);
+    }
+    
+    
+    // redirect to new xmlrpc location
+    private String figureXmlrpcRedirect(HttpServletRequest request) {
+        
+        return URLUtilities.getXmlrpcURL(true);
+    }
+    
+    
+    // redirect to new editor UI location
+    private String figureEditorRedirect(HttpServletRequest request) {
+        
+        return RollerRuntimeConfig.getRelativeContextURL()+"/roller-ui/";
+    }
+    
+    
+    // redirect to new admin UI location
+    private String figureAdminRedirect(HttpServletRequest request) {
+        
+        return RollerRuntimeConfig.getRelativeContextURL()+"/roller-ui/";
+    }
+    
+}



Mime
View raw message