//# 0 errors, 144 messages
//#
/*
    //#uritransformer.java:1:1: class: net.sourceforge.pebble.web.filter.UriTransformer
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.web.filter;

import net.sourceforge.pebble.domain.*;
import net.sourceforge.pebble.permalink.DefaultPermalinkProvider;
import net.sourceforge.pebble.api.permalink.PermalinkProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Responsible for converting an incoming URI to a real URI used by Pebble.
 *
 * @author    Simon Brown
 */
public class UriTransformer {
    //#uritransformer.java:45: method: void net.sourceforge.pebble.web.filter.UriTransformer.net.sourceforge.pebble.web.filter.UriTransformer()
    //#uritransformer.java:45: end of method: void net.sourceforge.pebble.web.filter.UriTransformer.net.sourceforge.pebble.web.filter.UriTransformer()

  /** literal used at the start of category URIs */
  private static final String CATEGORIES = "/categories";

  /** literal used at the start of category URIs, in regex form */
  private static final String CATEGORIES_REGEX = "\\/categories\\/";

  /** literal used at the start of tag URIs */
  private static final String TAGS = "/tags/";

  /** literal used at the start of tag URIs, in regex form */
  private static final String TAGS_REGEX = "\\/tags\\/";

  /** literal used at the start of author URIs */
  private static final String AUTHORS = "/authors/";

  /** literal used at the start of tag URIs, in regex form */
  private static final String AUTHORS_REGEX = "\\/authors\\/";

  /** the log used by this class */
  private static Log log = LogFactory.getLog(UriTransformer.class);
    //#uritransformer.java:66: method: net.sourceforge.pebble.web.filter.UriTransformer.net.sourceforge.pebble.web.filter.UriTransformer__static_init
    //#uritransformer.java:66: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: net.sourceforge.pebble.web.filter.UriTransformer__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Descendant_Table[net/sourceforge/pebble/web/filter/UriTransformer]
    //#output(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/api/permalink/PermalinkProvider;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/domain/Blog;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/domain/MultiBlog;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.web.filter.UriTransformer__static_init): log
    //#post(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Descendant_Table[net/sourceforge/pebble/web/filter/UriTransformer] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/api/permalink/PermalinkProvider;)Ljava/lang/String; == &getUri
    //#post(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/domain/Blog;)Ljava/lang/String; == &getUri
    //#post(net.sourceforge.pebble.web.filter.UriTransformer__static_init): __Dispatch_Table.getUri(Ljava/lang/String;Lnet/sourceforge/pebble/domain/MultiBlog;)Ljava/lang/String; == &getUri
    //#post(net.sourceforge.pebble.web.filter.UriTransformer__static_init): init'ed(log)
    //#uritransformer.java:66: end of method: net.sourceforge.pebble.web.filter.UriTransformer.net.sourceforge.pebble.web.filter.UriTransformer__static_init

  /**
   * Checks for URI patterns and converts them to the appropriate action.
   *
   * @param uri     the initial URI
   * @param blog    the current Blog instance
   *
   * @return    the URI to used to service the original request (could be
   *            the same)
   */
  public String getUri(String uri, Blog blog) {
    PermalinkProvider permalinkProvider = blog.getPermalinkProvider();
    //#uritransformer.java:78: method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, Blog)
    //#uritransformer.java:78: Warning: method not available
    //#    -- call on PermalinkProvider net.sourceforge.pebble.domain.Blog:getPermalinkProvider()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, Blog)
    //#    unanalyzed callee: PermalinkProvider net.sourceforge.pebble.domain.Blog:getPermalinkProvider()
    //#input(String getUri(String, Blog)): blog
    //#input(String getUri(String, Blog)): log
    //#input(String getUri(String, Blog)): net/sourceforge/pebble/permalink/DefaultPermalinkProvider.__Descendant_Table[net/sourceforge/pebble/permalink/DefaultPermalinkProvider]
    //#input(String getUri(String, Blog)): net/sourceforge/pebble/permalink/DefaultPermalinkProvider.__Dispatch_Table.setBlog(Lnet/sourceforge/pebble/domain/Blog;)V
    //#input(String getUri(String, Blog)): this
    //#input(String getUri(String, Blog)): uri
    //#output(String getUri(String, Blog)): return_value
    //#pre[1] (String getUri(String, Blog)): blog != null
    //#pre[2] (String getUri(String, Blog)): log != null
    //#presumption(String getUri(String, Blog)): net.sourceforge.pebble.domain.Blog:getPermalinkProvider(...)@78 != null
    //#post(String getUri(String, Blog)): return_value != null
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:isBlogEntryPermalink
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlogEntry
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.BlogEntry:getId
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:isDayPermalink
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:getDay
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Day:getMonth
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Month:getYear
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Year:getYear
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Month:getMonth
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Day:getDay
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:isMonthPermalink
    //#unanalyzed(String getUri(String, Blog)): Effects-of-calling:net.sourceforge.pebble.api.permalink.PermalinkProvider:getMonth
    //#test_vector(String getUri(String, Blog)): uri: Addr_Set{null}, Inverse{null}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@105: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@107: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@115: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@127: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@129: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@139: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@141: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@149: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:endsWith(...)@156: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@119: {1}, {0}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@119: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@160: {1}, {0}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@160: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@192: {1}, {0}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@192: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@195: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@216: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@219: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@226: {1}, {0}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@226: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@84: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@97: {1}, {0}
    //#test_vector(String getUri(String, Blog)): java.lang.String:equals(...)@97: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:matches(...)@100: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:matches(...)@122: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:matches(...)@134: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:matches(...)@186: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@112: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@146: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@153: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@162: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@168: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@174: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@180: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@198: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@201: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@204: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@207: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@210: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@213: {0}, {1}
    //#test_vector(String getUri(String, Blog)): java.lang.String:startsWith(...)@222: {0}, {1}
    DefaultPermalinkProvider defaultPermalinkProvider = new DefaultPermalinkProvider();
    defaultPermalinkProvider.setBlog(permalinkProvider.getBlog());
    //#uritransformer.java:80: Warning: method not available
    //#    -- call on Blog net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlog()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, Blog)
    //#    unanalyzed callee: Blog net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlog()

    log.trace("URI before transformation : " + uri);
    //#uritransformer.java:82: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:trace(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, Blog)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:trace(Object)

    if (uri == null || uri.trim().equals("")) {
      uri = "/";
    }

    // try to transform the URI with the permalink provider in use
    String result = getUri(uri, permalinkProvider);
    if (result == null) {
      // for backwards compatibility, try the default permalink provider
      result = getUri(uri, defaultPermalinkProvider);
    }

    // if the result is still null, try the other URL patterns to transform the URI
    if (result == null) {
      if (uri.equals("/categories") || uri.equals("/categories/")) {
        // URI of the form /categories/
        result = "/viewCategories.action";
      } else if (uri.matches(CATEGORIES_REGEX + ".*\\/.*xml")) {
          // URI of the form /category[/subcategories]/[rss|rdf|atom].xml
          int indexOfLastSlash = uri.lastIndexOf("/");
          String categoryId = uri.substring(CATEGORIES.length(), indexOfLastSlash);

          if (uri.endsWith("rdf.xml")) {
            result = "/feed.action?category=" + categoryId + "&flavor=rdf";
          } else if (uri.endsWith("atom.xml")) {
            result = "/feed.action?category=" + categoryId + "&flavor=atom";
          } else {
            result = "/feed.action?category=" + categoryId + "&flavor=rss20";
          }
      } else if (uri.startsWith(CATEGORIES)) {
        // URI of the form /categories/category/
        String category = uri.substring(CATEGORIES.length(), uri.length());
        if (category.endsWith("/")) {
          category = category.substring(0, category.length()-1);
        }
        result = "/viewCategory.action?category=" + category;
      } else if (uri.equals("/tags") || uri.equals("/tags/")) {
          // URI of the form /tags/
          result = "/viewTags.action";
      } else if (uri.matches(TAGS_REGEX + ".*\\/.*xml")) {
        // URI of the form /tags/tag/[rss|rdf|atom].xml
        int indexOfLastSlash = uri.lastIndexOf("/");
        String tag = uri.substring(TAGS.length(), indexOfLastSlash);

        if (uri.endsWith("rdf.xml")) {
          result = "/feed.action?tag=" + tag + "&flavor=rdf";
        } else if (uri.endsWith("atom.xml")) {
          result = "/feed.action?tag=" + tag + "&flavor=atom";
        } else {
          result = "/feed.action?tag=" + tag + "&flavor=rss20";
        }
      } else if (uri.matches(AUTHORS_REGEX + ".*\\/.*xml")) {
        // URI of the form /authors/username/[rss|rdf|atom].xml
        int indexOfLastSlash = uri.lastIndexOf("/");
        String author = uri.substring(AUTHORS.length(), indexOfLastSlash);

        if (uri.endsWith("rdf.xml")) {
          result = "/feed.action?author=" + author + "&flavor=rdf";
        } else if (uri.endsWith("atom.xml")) {
          result = "/feed.action?author=" + author + "&flavor=atom";
        } else {
          result = "/feed.action?author=" + author + "&flavor=rss20";
        }
      } else if (uri.startsWith(TAGS)) {
        // URI of the form /tags/tag/
        String tag = uri.substring(TAGS.length(), uri.length());
        if (tag.endsWith("/")) {
          tag = tag.substring(0, tag.length()-1);
        }
        result = "/viewTag.action?tag=" + Tag.encode(tag);
    //#uritransformer.java:152: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Tag:encode(String)
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, Blog)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Tag:encode(String)
      } else if (uri.startsWith(AUTHORS)) {
        // URI of the form /authors/usename/
        String author = uri.substring(AUTHORS.length(), uri.length());
        if (author.endsWith("/")) {
          author = author.substring(0, author.length()-1);
        }
        result = "/aboutAuthor.action?user=" + author;
      } else if (uri.equals("/pages/") || uri.equals("/pages")) {
        result = "/viewStaticPage.action?name=index";
      } else if (uri.startsWith("/pages/")) {
        // url matches /pages/xyz.html
        String name = uri.substring(7, uri.length()-5);

        result = "/viewStaticPage.action?name=";
        result += name;
      } else if (uri.startsWith("/images/")) {
        // url matches /images/xyz.xyz
        String name = uri.substring(7, uri.length());

        result = "/file.action?type=" + FileMetaData.BLOG_IMAGE + "&name=";
        result += name;
      } else if (uri.startsWith("/files/")) {
        // url matches /files/xyz.xyz
        String name = uri.substring(6, uri.length());

        result = "/file.action?type=" + FileMetaData.BLOG_FILE + "&name=";
        result += name;
      } else if (uri.startsWith("/theme/")) {
        // url matches /files/xyz.xyz
        String name = uri.substring(6, uri.length());

        result = "/file.action?type=" + FileMetaData.THEME_FILE + "&name=";
        result += name;
      } else if (uri.matches("\\/help\\/\\w*\\.html")) {
        // url matches /help/xyz.html
        String name = uri.substring(6, uri.length());

        result = "/viewHelp.secureaction?name=";
        result += name.substring(0, name.length()-5);
      } else if (uri.equals("/help") || uri.equals("/help/")) {
        // url matches /help/
        result = "/viewHelp.secureaction?name=index";
      } else if (uri.equals("/responses/rss.xml")) {
        // url is for a response feed
        result = "/responseFeed.action?flavor=rss20";
      } else if (uri.startsWith("/responses/rss.xml?entry=")) {
        // url is for a response feed
        result = "/responseFeed.action?flavor=rss20&" + uri.substring("/responses/rss.xml?".length());
      } else if (uri.startsWith("/rss.xml")) {
        // url matches rss.xml
        result = "/feed.action?flavor=rss20";
      } else if (uri.startsWith("/feed.xml")) {
        // url matches feed.xml
        result = "/feed.action?flavor=rss20";
      } else if (uri.startsWith("/rdf.xml")) {
        // url matches rdf.xml
        result = "/feed.action?flavor=rdf";
      } else if (uri.startsWith("/responses/atom.xml")) {
        // url is for a response feed
        result = "/responseFeed.action?flavor=atom";
      } else if (uri.startsWith("/atom.xml")) {
        // url matches atom.xml
        result = "/feed.action?flavor=atom";
      } else if (uri.equals("/today.html")) {
        // URI of the form /today.html
        result = "/viewDay.action";
      } else if (uri.equals("/about.html")) {
        // URI of the form /about.html
        result = "/about.action";
      } else if (uri.startsWith("/blogentries/")) {
        // view blog entries by page /blogentries/1.html
        String page = uri.substring(13, uri.length()-5);
        result = "/viewBlogEntriesByPage.action?page=" + page;
      } else if (uri.equals("/") || uri.equals("/index.jsp") || uri.equals("/index.html")) {
          result = "/viewHomePage.action";
      } else {
        result = uri;
      }
    }

    log.trace("URI after transformation : " + result);
    //#uritransformer.java:233: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:trace(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, Blog)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:trace(Object)

    return result;
    //#uritransformer.java:235: end of method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, Blog)
  }

  /**
   * Checks for URI patterns and converts them to the appropriate action.
   *
   * @param uri     the initial URI
   * @param blog    the current Blog instance
   *
   * @return    the URI to used to service the original request (could be
   *            the same)
   */
  public String getUri(String uri, MultiBlog blog) {
    String result;

    log.trace("URI before transformation : " + uri);
    //#uritransformer.java:250: method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, MultiBlog)
    //#uritransformer.java:250: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:trace(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, MultiBlog)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:trace(Object)
    //#input(String getUri(String, MultiBlog)): log
    //#input(String getUri(String, MultiBlog)): uri
    //#output(String getUri(String, MultiBlog)): return_value
    //#pre[1] (String getUri(String, MultiBlog)): log != null
    //#post(String getUri(String, MultiBlog)): return_value != null
    //#test_vector(String getUri(String, MultiBlog)): uri: Addr_Set{null}, Inverse{null}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:equals(...)@252: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:equals(...)@268: {1}, {0}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:equals(...)@268: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:matches(...)@270: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:startsWith(...)@256: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:startsWith(...)@259: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:startsWith(...)@262: {0}, {1}
    //#test_vector(String getUri(String, MultiBlog)): java.lang.String:startsWith(...)@265: {0}, {1}

    if (uri == null || uri.trim().equals("")) {
      uri = "/";
    }

    if (uri.startsWith("/rss.xml")) {
      // url matches rss.xml
      result = "/feed.action?flavor=rss20";
    } else if (uri.startsWith("/feed.xml")) {
      // url matches feed.xml
      result = "/feed.action?flavor=rss20";
    } else if (uri.startsWith("/rdf.xml")) {
      // url matches rdf.xml
      result = "/feed.action?flavor=rdf";
    } else if (uri.startsWith("/atom.xml")) {
      // url matches atom.xml
      result = "/feed.action?flavor=atom";
    } else if (uri.equals("/") || uri.equals("/index.jsp") || uri.equals("/index.html")) {
        result = "/viewHomePage.action";
    } else if (uri.matches("\\/help\\/\\w*\\.html")) {
      // url matches /help/xyz.html
      String name = uri.substring(6, uri.length());

      result = "/viewHelp.secureaction?name=";
      result += name.substring(0, name.length()-5);
    } else {
      result = uri;
    }

    log.trace("URI after transformation : " + result);
    //#uritransformer.java:280: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:trace(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, MultiBlog)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:trace(Object)

    return result;
    //#uritransformer.java:282: end of method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, MultiBlog)
  }

  /**
   * Checks for URI patterns and converts them to the appropriate action, using
   * the specified permalink provider.
   *
   * @param uri   the initial URI
   * @param permalinkProvider   a PermalinkProvider instance to try and
   *                            transform the URI with
   *
   * @return    the URI to used to service the original request (could be
   *            the same)
   */
  private String getUri(String uri, PermalinkProvider permalinkProvider) {
    String result = null;
    //#uritransformer.java:297: method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, PermalinkProvider)
    //#input(String getUri(String, PermalinkProvider)): permalinkProvider
    //#input(String getUri(String, PermalinkProvider)): uri
    //#output(String getUri(String, PermalinkProvider)): return_value
    //#pre[1] (String getUri(String, PermalinkProvider)): permalinkProvider != null
    //#presumption(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.domain.Day:getMonth(...)@308 != null
    //#presumption(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.domain.Day:getMonth(...)@309 != null
    //#presumption(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.domain.Month:getYear(...)@308 != null
    //#presumption(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.domain.Month:getYear(...)@316 != null
    //#post(String getUri(String, PermalinkProvider)): init'ed(return_value)
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlogEntry(...)@300: Addr_Set{null}, Inverse{null}
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:getDay(...)@305: Addr_Set{null}, Inverse{null}
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:getMonth(...)@313: Addr_Set{null}, Inverse{null}
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:isBlogEntryPermalink(...)@299: {0}, {1}
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:isDayPermalink(...)@304: {0}, {1}
    //#test_vector(String getUri(String, PermalinkProvider)): net.sourceforge.pebble.api.permalink.PermalinkProvider:isMonthPermalink(...)@312: {0}, {1}

    if (permalinkProvider.isBlogEntryPermalink(uri)) {
    //#uritransformer.java:299: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isBlogEntryPermalink(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isBlogEntryPermalink(String)
      BlogEntry blogEntry = permalinkProvider.getBlogEntry(uri);
    //#uritransformer.java:300: Warning: method not available
    //#    -- call on BlogEntry net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlogEntry(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: BlogEntry net.sourceforge.pebble.api.permalink.PermalinkProvider:getBlogEntry(String)
      if (blogEntry != null) {
        result = "/viewBlogEntry.action?entry=" + blogEntry.getId();
    //#uritransformer.java:302: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.BlogEntry:getId()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.BlogEntry:getId()
      }
    } else if (permalinkProvider.isDayPermalink(uri)) {
    //#uritransformer.java:304: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isDayPermalink(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isDayPermalink(String)
      Day day = permalinkProvider.getDay(uri);
    //#uritransformer.java:305: Warning: method not available
    //#    -- call on Day net.sourceforge.pebble.api.permalink.PermalinkProvider:getDay(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Day net.sourceforge.pebble.api.permalink.PermalinkProvider:getDay(String)
      if (day != null) {
        result = "/viewDay.action";
        result += "?year=" + day.getMonth().getYear().getYear();
    //#uritransformer.java:308: Warning: method not available
    //#    -- call on Month net.sourceforge.pebble.domain.Day:getMonth()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Month net.sourceforge.pebble.domain.Day:getMonth()
    //#uritransformer.java:308: Warning: method not available
    //#    -- call on Year net.sourceforge.pebble.domain.Month:getYear()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Year net.sourceforge.pebble.domain.Month:getYear()
    //#uritransformer.java:308: Warning: method not available
    //#    -- call on int net.sourceforge.pebble.domain.Year:getYear()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: int net.sourceforge.pebble.domain.Year:getYear()
        result += "&month=" + day.getMonth().getMonth();
    //#uritransformer.java:309: Warning: method not available
    //#    -- call on Month net.sourceforge.pebble.domain.Day:getMonth()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Month net.sourceforge.pebble.domain.Day:getMonth()
    //#uritransformer.java:309: Warning: method not available
    //#    -- call on int net.sourceforge.pebble.domain.Month:getMonth()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: int net.sourceforge.pebble.domain.Month:getMonth()
        result += "&day=" + day.getDay();
    //#uritransformer.java:310: Warning: method not available
    //#    -- call on int net.sourceforge.pebble.domain.Day:getDay()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: int net.sourceforge.pebble.domain.Day:getDay()
      }
    } else if (permalinkProvider.isMonthPermalink(uri)) {
    //#uritransformer.java:312: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isMonthPermalink(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: bool net.sourceforge.pebble.api.permalink.PermalinkProvider:isMonthPermalink(String)
      Month month = permalinkProvider.getMonth(uri);
    //#uritransformer.java:313: Warning: method not available
    //#    -- call on Month net.sourceforge.pebble.api.permalink.PermalinkProvider:getMonth(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Month net.sourceforge.pebble.api.permalink.PermalinkProvider:getMonth(String)
      if (month != null) {
        result = "/viewMonth.action";
        result += "?year=" + month.getYear().getYear();
    //#uritransformer.java:316: Warning: method not available
    //#    -- call on Year net.sourceforge.pebble.domain.Month:getYear()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: Year net.sourceforge.pebble.domain.Month:getYear()
    //#uritransformer.java:316: Warning: method not available
    //#    -- call on int net.sourceforge.pebble.domain.Year:getYear()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: int net.sourceforge.pebble.domain.Year:getYear()
        result += "&month=" + month.getMonth();
    //#uritransformer.java:317: Warning: method not available
    //#    -- call on int net.sourceforge.pebble.domain.Month:getMonth()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.filter.UriTransformer
    //#    method: String getUri(String, PermalinkProvider)
    //#    unanalyzed callee: int net.sourceforge.pebble.domain.Month:getMonth()
      }
    }

    return result;
    //#uritransformer.java:321: end of method: String net.sourceforge.pebble.web.filter.UriTransformer.getUri(String, PermalinkProvider)
  }

}    //#uritransformer.java:: end of class: net.sourceforge.pebble.web.filter.UriTransformer
