1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.profiler.rules.impl;
18
19 import org.apache.jetspeed.PortalReservedParameters;
20 import org.apache.jetspeed.om.page.Page;
21 import org.apache.jetspeed.profiler.rules.RuleCriterion;
22 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
23 import org.apache.jetspeed.request.RequestContext;
24
25 /***
26 * PathSessionResolver
27 *
28 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
29 * @version $Id: PathSessionResolver.java 516448 2007-03-09 16:25:47Z ate $
30 */
31 public class PathSessionResolver implements RuleCriterionResolver
32 {
33
34
35
36 public String resolve(RequestContext context, RuleCriterion criterion)
37 {
38 String path = null;
39 Page page = context.getPage();
40
41 if (page != null)
42 {
43 path = page.getId();
44 }
45 else
46 {
47 path = context.getPath();
48 if (path != null)
49 path = mapPath(context, path);
50 }
51
52 if ((path == null) || path.equals("/"))
53 {
54 String key = this.getClass() + "." + criterion.getName();
55 path = (String)context.getSessionAttribute(key);
56 if (path == null)
57 {
58 path = criterion.getValue();
59 }
60 }
61 return path;
62 }
63
64 private String mapPath(RequestContext context, String originalPath)
65 {
66 String path = originalPath;
67 if (path.endsWith(".psml"))
68 {
69 return originalPath;
70 }
71 for (int ix=0; ix < REGEX_MAP.length; ix++)
72 {
73 if (path.matches(REGEX_MAP[ix][0]))
74 {
75 path = REGEX_MAP[ix][1];
76 context.setPath(path);
77 context.setAttribute(PortalReservedParameters.PATH_ATTRIBUTE, originalPath);
78 break;
79 }
80 }
81 return path;
82 }
83
84
85 static String[][] REGEX_MAP =
86 {
87 {".*//.(...|....)", "/Public/content.psml"}
88
89
90
91
92 };
93
94
95
96
97
98 public boolean isControl(RuleCriterion criterion)
99 {
100 return false;
101 }
102
103 public boolean isNavigation(RuleCriterion criterion)
104 {
105 return false;
106 }
107
108 }