1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.profiler;
18
19 import java.security.Principal;
20 import java.util.Collection;
21 import java.util.Map;
22
23 import org.apache.jetspeed.profiler.rules.PrincipalRule;
24 import org.apache.jetspeed.profiler.rules.ProfilingRule;
25 import org.apache.jetspeed.profiler.rules.RuleCriterion;
26 import org.apache.jetspeed.request.RequestContext;
27
28 /***
29 * ProfilerService
30 * Jetspeed-2 Profiler service.
31 * Locates portal resources given a set of request parameters, properties, and attributes
32 * The Profiler is invoked during the request processing pipeline.
33 * It requires that the request context is already populated with the portal request and response,
34 * and capability and user information. The request context parameters, properties and attributes
35 * make up the profile criterion which the profiler uses to locate portal resources:
36 * 1. page
37 * 2. navigations
38 * 3. document lists
39 *
40 * In all cases, a fallback algorithm should be applied to fallback
41 * to default portal resources.
42 *
43 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
44 * @version $Id: Profiler.java 516881 2007-03-11 10:34:21Z ate $
45 */
46 public interface Profiler
47 {
48
49
50 /***
51 * Get the Profile object using the request parameters.
52 *
53 * @param context The request context
54 * @param locatorName The name of the profile locator to find i.e. "page", "docset", ...
55 * @return a new Profile Locator object or null if failed to find a appropriate locator.
56 */
57 ProfileLocator getProfile(RequestContext context, String locatorName) throws ProfilerException;
58
59 /***
60 *
61 * <p>
62 * getDefaultProfile
63 * </p>
64 * Intstead of using the princpal found within the request, the DEFAULT_RULE_PRINCIPAL is used.
65 *
66 * @param context The request context
67 * @param locatorName The name of the profile locator to find i.e. "page", "docset", ...
68 * @return a new Profile Locator object or null if failed to find a appropriate locator.
69 */
70 ProfileLocator getDefaultProfile(RequestContext context, String locatorName) throws ProfilerException;
71
72 /***
73 * Get the Profile object using the request parameters and the rule.
74 *
75 * @param context The request context
76 * @return a new Profile Locator object or null if failed to find a appropriate locator.
77 */
78 ProfileLocator getProfile(RequestContext context, ProfilingRule rule) throws ProfilerException;
79
80 /***
81 * Creates a new ProfileLocator object that can be managed by
82 * the current Profiler implementation
83 *
84 * @param context The request context
85 * @return A new ProfileLocator object
86 */
87 ProfileLocator createLocator(RequestContext context);
88
89 /***
90 * For a given principal, lookup the associated profiling rule to that principal name.
91 *
92 * @param principal Lookup the profiling rule based on this principal.
93 * @param locatorName the unique name of a locator for this principal/rule/locator
94 * @return The rule found or null if not found
95 */
96 ProfilingRule getRuleForPrincipal(Principal principal, String locatorName);
97
98 /***
99 * For a given principal, associate a profiling rule to that principal name.
100 * TODO: this API should be secured and require admin role
101 *
102 * @param principal
103 * Lookup the profiling rule based on this principal.
104 * @param locatorName
105 * the unique name of a locator for this principal/rule/locator
106 * @param The
107 * rule used to find profiles for this user
108 */
109 void setRuleForPrincipal(Principal principal, ProfilingRule rule,
110 String locatorName);
111
112 /***
113 * Lookup the portal's default profiling rule.
114 *
115 * @return The portal's default profiling rule.
116 */
117 ProfilingRule getDefaultRule();
118
119 /***
120 * @return
121 */
122 Collection getRules();
123
124 /***
125 * Given a rule id, get the rule
126 *
127 * @param id
128 * @return the rule
129 */
130 ProfilingRule getRule(String id);
131
132 /***
133 * For a given principal, find all supported locators and return a string
134 * array of locator names.
135 *
136 * @param principal
137 * The given principal.
138 * @return array of String locator names
139 */
140 String[] getLocatorNamesForPrincipal(Principal principal);
141
142 /***
143 * For a given principal, find all supported locators and return a
144 * collection of principal rules.
145 *
146 * @param principal
147 * The given principal.
148 * @return collection of PrincipalRules
149 */
150 Collection getRulesForPrincipal(Principal principal);
151
152 /***
153 * Gets all supported locators for a principal.
154 *
155 * @param context
156 * @param principal
157 * @return
158 * @throws ProfilerException
159 */
160 Map getProfileLocators(RequestContext context, Principal principal)
161 throws ProfilerException;
162
163 /***
164 *
165 * <p>
166 * getDefaultProfileLocators
167 * </p>
168 * Gets all the supported locators for the DEFAULT_RULE_PRINCIPAL
169 *
170 * @param context
171 * @return
172 * @throws ProfilerException
173 */
174 Map getDefaultProfileLocators(RequestContext context)
175 throws ProfilerException;
176
177
178
179
180
181 void storeProfilingRule(ProfilingRule rule) throws ProfilerException;
182
183
184
185
186
187 void deleteProfilingRule(ProfilingRule rule) throws ProfilerException;
188
189
190
191
192
193 void storePrincipalRule(PrincipalRule rule) throws ProfilerException;
194
195
196
197
198
199 void deletePrincipalRule(PrincipalRule rule) throws ProfilerException;
200
201 /***
202 * Factory for Profiling Rule. The boolean argument specifies whether to
203 * obtain a new instance of a standard profiling rule or of a fallback rule.
204 *
205 * @param standard
206 * true if standard rule is requested, false if fallback
207 * @return New instance of a (standard or fallback) Profiling Rule
208 * @throws ClassNotFoundException
209 * if the beanfactory couldn't instantiate the bean
210 */
211 public ProfilingRule createProfilingRule(boolean standard)
212 throws ClassNotFoundException;
213
214 /***
215 * Factory for PrincipalRule, the container to connect profiling rule and
216 * (user) prinicpal
217 * <p>
218 * Replaces the previous Class.forName and .instantiate logic with the
219 * Spring based factory.
220 *
221 * @return New instance of a principal rule
222 * @throws ClassNotFoundException
223 * if the beanfactory couldn't instantiate the bean
224 */
225 public PrincipalRule createPrincipalRule() throws ClassNotFoundException;
226
227 /***
228 * Factory for Rule Criterion
229 * <p>
230 *
231 * @return New instance of a rule criterion
232 * @throws ClassNotFoundException
233 * if the beanfactory couldn't instantiate the bean
234 */
235 public RuleCriterion createRuleCriterion() throws ClassNotFoundException;
236
237
238
239 /***
240 * Resets the default rule for this portal
241 * @param defaultRule
242 * The default rule to set.
243 */
244 public void setDefaultRule(String defaultRule);
245
246 }