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.consumer.driver;
18  
19  import oasis.names.tc.wsrp.v1.types.ClientData;
20  
21  import org.apache.wsrp4j.consumer.WSRPBaseRequest;
22  import org.apache.wsrp4j.log.LogManager;
23  import org.apache.wsrp4j.log.Logger;
24  
25  public abstract class GenericWSRPBaseRequestImpl implements WSRPBaseRequest {
26  
27      protected Logger logger = LogManager.getLogManager().getLogger(
28              GenericWSRPBaseRequestImpl.class);
29  
30      public abstract String getSessionID();
31  
32      public abstract String getPortletInstanceKey();
33  
34      public abstract String getNavigationalState();
35  
36      public abstract String getWindowState();
37  
38      public abstract String getMode();
39  
40      public abstract ClientData getClientData();
41  
42      public abstract String[] getLocales();
43  
44      public abstract String[] getModes();
45  
46      public abstract String[] getWindowStates();
47  
48      public abstract String[] getMimeTypes();
49  
50      public abstract String[] getCharacterEncodingSet();
51  
52      public boolean isModeSupported(String wsrpMode) {
53          final String MN = "isModeSupported(String)";
54  
55          if (logger.isLogging(Logger.TRACE_HIGH)) {
56              logger.entry(Logger.TRACE_HIGH, MN);
57          }
58  
59          if (wsrpMode == null)
60              throw new IllegalArgumentException("mode must not be null");
61  
62          String[] mods = getModes();
63          for (int i = 0; i < mods.length; i++) {
64              if (wsrpMode.equalsIgnoreCase(mods[i])) {
65                  return true;
66              }
67          }
68  
69          if (logger.isLogging(Logger.TRACE_HIGH)) {
70              logger.exit(Logger.TRACE_HIGH, MN);
71          }
72  
73          return false;
74      }
75  
76      public boolean isWindowStateSupported(String wsrpWindowState) {
77          final String MN = "isWindowStateSupported(String)";
78  
79          if (logger.isLogging(Logger.TRACE_HIGH)) {
80              logger.entry(Logger.TRACE_HIGH, MN);
81          }
82  
83          if (wsrpWindowState == null)
84              throw new IllegalArgumentException("window state must not be null");
85  
86          String[] stats = getWindowStates();
87          for (int i = 0; i < stats.length; i++) {
88              if (wsrpWindowState.equalsIgnoreCase(stats[i])) {
89                  return true;
90              }
91          }
92  
93          if (logger.isLogging(Logger.TRACE_HIGH)) {
94              logger.exit(Logger.TRACE_HIGH, MN);
95          }
96  
97          return false;
98      }
99  
100     public abstract String getUserAuthentication();
101 }