View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.profiler.rules;
18  
19  import java.io.Serializable;
20  
21  import org.apache.jetspeed.request.RequestContext;
22  
23  /***
24   * Resolves rule criterion based on a single criterion and 
25   * runtime request context state. Note all resolvers should
26   * look at the criterion's value if they fail to find it
27   * 
28   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
29   * @version $Id: RuleCriterionResolver.java 516448 2007-03-09 16:25:47Z ate $
30   */
31  public interface RuleCriterionResolver extends Serializable
32  {    
33      /*** resolve the parameter via the request parameter, then value */        
34      public static final String REQUEST = "request";
35  
36      /*** resolve the parameter via a session attribute */
37      public static final String SESSION = "session";
38      
39      /*** look in the request first, then session */
40      public static final String REQUEST_SESSION = "request.session";
41      
42      /*** look at hard-coded criterion value only */
43      public final static String  HARD_CODED = "hard.coded";
44      
45      /*** look for group, then role, then user */
46      public final static String GROUP_ROLE_USER = "group.role.user";
47  
48      /*** first check request parameter, then check user in the request context */             
49      public final static String USER = "user";
50      
51      /*** first check request parameter, then check group in the request context */             
52      public final static String GROUP = "group";
53      
54      /*** first check request parameter, then check role in the request context */             
55      public final static String ROLE = "role";
56      
57      /*** first check request parameter, then check media type in the request context */             
58      public final static String MEDIATYPE = "mediatype";
59      
60      /*** first check request parameter, then check country code in the request context */                 
61      public final static String COUNTRY = "country";
62  
63      /*** first check request parameter, then user agent in the request context */                 
64      public final static String USER_AGENT = "user.agent";
65      
66      /*** first check request parameter, then check language in the request context */                 
67      public final static String LANGUAGE = "language";
68      
69      public final static String ROLE_FALLBACK = "roles";
70  
71      /*** resolve the parameter via the request path, then value */        
72      public static final String PATH = "path";
73  
74      /*** resolve the parameter via the request path, then value */        
75      public static final String PAGE = "page";
76      
77      /*** look in the request path first, then session */
78      public static final String PATH_SESSION = "path.session";
79      
80      /*** look in user attributes */
81      public static final String USER_ATTRIBUTE = "user.attribute";
82      
83      /*** change the current navigation path */
84      public static final String NAVIGATION = "navigation";
85      
86      /***
87       * Resolver the value for a criterion.
88       * 
89       * @param context The request context.
90       * @param criterion The criterion being evaluated.
91       * @return The value of the criterion or null if not found.
92       *         Returns null to indicate to subclasses to continue processing.
93       */        
94      String resolve(RequestContext context, RuleCriterion criterion);
95      
96      /***
97       * Gets the control classification of the resolver.
98       * 
99       * @return The control class flag
100      */    
101     boolean isControl(RuleCriterion criterion);
102 
103     /***
104      * Gets the navigation classification of the resolver.
105      * 
106      * @return The control class flag
107      */    
108     boolean isNavigation(RuleCriterion criterion);
109     
110 }