1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.wsrp4j.util;
18  
19  public final class Constants {
20  
21      // locales
22      public static final String LOCALE_EN_US = "en";
23  
24      public static final String LOCALE_DE_DE = "de";
25  
26      // markup types
27      public static final String MIME_TYPE_HTML = "text/html";
28  
29      // character sets
30      public static final String UTF_8 = "UTF-8";
31  
32      // Constants for URL-Handling
33  
34      // tokens, tags etc.
35      public static final String REWRITE_START = "wsrp_rewrite";
36  
37      public static final String REWRITE_END = "/wsrp_rewrite";
38  
39      public static final String NEXT_PARAM = "&";
40  
41      public static final String NEXT_PARAM_AMP = "&";
42  
43      public static final String EQUALS = "=";
44  
45      public static final String PARAMS_START = "?";
46  
47      public static final String NAMESPACE_START = "_";
48  
49      // replacement tokens
50      public static final String REPLACE_START = "{";
51  
52      public static final String REPLACE_END = "}";
53  
54      // parameter names
55      public static final String URL_TYPE = "wsrp-urlType";
56  
57      public static final String NAVIGATIONAL_STATE = "wsrp-navigationalState";
58  
59      public static final String INTERACTION_STATE = "wsrp-interactionState";
60  
61      public static final String WINDOW_STATE = "wsrp-windowState";
62  
63      public static final String PORTLET_MODE = "wsrp-mode";
64  
65      public static final String URL = "wsrp-url";
66  
67      public static final String FRAGMENT_ID = "wsrp-fragmentID";
68  
69      public static final String SECURE_URL = "wsrp-secureURL";
70  
71      public static final String REWRITE_RESOURCE = "wsrp-requiresRewrite";
72  
73      public static final String FORM_PARAMETERS = "wsrp-formParameters";
74  
75      public static final String PORTLET_HANDLE = "wsrp-portletHandle";
76  
77      public static final String USER_CONTEXT_KEY = "wsrp-userContextKey";
78  
79      public static final String PORTLET_INSTANCE_KEY = "wsrp-portletInstanceKey";
80  
81      public static final String SESSION_ID = "wsrp-sessionID";
82  
83      // parameter values for url type
84      public static final String URL_TYPE_BLOCKINGACTION = "blockingAction";
85  
86      public static final String URL_TYPE_RENDER = "render";
87  
88      public static final String URL_TYPE_RESOURCE = "resource";
89  
90      // constants for parameter checker
91      public static final boolean NILLABLE_TRUE = true;
92  
93      public static final boolean NILLABLE_FALSE = false;
94  
95      // fault names as they appear on the wire
96      public static final String ACCESS_DENIED_FAULT = "AccessDenied";
97  
98      public static final String INCONSISTENT_PARAMETERS_FAULT = "InconsistenParameters";
99  
100     public static final String INVALID_REGISTRATION_FAULT = "InvalidRegistration";
101 
102     public static final String INVALID_COOKIE_FAULT = "InvalidCookie";
103 
104     public static final String INVALID_HANDLE_FAULT = "InvalidHandle";
105 
106     public static final String INVALID_SESSION_FAULT = "InvalidSession";
107 
108     public static final String INVALID_USER_CATEGORY_FAULT = "InvalidUserCategory";
109 
110     public static final String MISSING_PARAMETERS_FAULT = "MissingParameters";
111 
112     public static final String OPERATION_FAILED_FAULT = "OperationFailed";
113 
114     public static final String PORTLET_STATE_CHANGE_REQUIRED_FAULT = "PortletStateChangeRequired";
115 
116     public static final String UNSUPPORTED_LOCALE_FAULT = "UnsupportedLocale";
117 
118     public static final String UNSUPPORTED_MIME_TYPE_FAULT = "UnsupportedMimeType";
119 
120     public static final String UNSUPPORTED_MODE_FAULT = "UnsupportedMode";
121 
122     public static final String UNSUPPORTED_WINDOW_STATE_FAULT = "UnsupportedWindowState";
123 
124     private static final String[] knownParams = new String[] {
125             Constants.NAVIGATIONAL_STATE, Constants.INTERACTION_STATE,
126             Constants.PORTLET_MODE, Constants.WINDOW_STATE, Constants.URL,
127             Constants.FRAGMENT_ID, Constants.SECURE_URL, Constants.URL_TYPE,
128             Constants.PORTLET_HANDLE, Constants.PORTLET_INSTANCE_KEY,
129             Constants.SESSION_ID, Constants.USER_CONTEXT_KEY,
130             Constants.REWRITE_RESOURCE };
131 
132     public static boolean isWsrpURLParam(String param) {
133         if (!param.startsWith("wsrp-"))
134             return false;
135 
136         for (int i = 0; i < knownParams.length; i++)
137             if (param.equalsIgnoreCase(knownParams[i]))
138                 return true;
139 
140         return false;
141     }
142 
143     public static String[] getWsrpParameters() {
144         return knownParams;
145     }
146 
147 }