| 1 | |
package org.webslinger.rules; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import javax.servlet.ServletException; |
| 5 | |
import javax.servlet.ServletRequest; |
| 6 | |
import javax.servlet.http.HttpServletRequest; |
| 7 | |
import javax.servlet.http.HttpSession; |
| 8 | |
|
| 9 | |
import org.webslinger.Webslinger; |
| 10 | |
|
| 11 | |
public class ThemeMatcher implements PathMatcher { |
| 12 | |
private final PathMatcher next; |
| 13 | |
|
| 14 | 2 | public ThemeMatcher(PathMatcher next) { |
| 15 | 2 | this.next = next; |
| 16 | 2 | } |
| 17 | |
|
| 18 | |
public boolean matches(ServletRequest request, String servletPath) throws IOException, ServletException { |
| 19 | 56 | if (!servletPath.startsWith("/Theme/")) return false; |
| 20 | 2 | servletPath = servletPath.substring(7); |
| 21 | 2 | String themeName = (String) request.getAttribute("THEME"); |
| 22 | 2 | if (!servletPath.startsWith(themeName)) return false; |
| 23 | 2 | if (servletPath.charAt(themeName.length()) != '/') return false; |
| 24 | 2 | return next.matches(request, servletPath.substring(themeName.length() + 1)); |
| 25 | |
} |
| 26 | |
|
| 27 | |
public String toString() { |
| 28 | 0 | return "ThemeMatcher(" + next + ")"; |
| 29 | |
} |
| 30 | |
} |