source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSParams.java@ 28958

Last change on this file since 28958 was 28958, checked in by davidb, 10 years ago

Remote Greenstone user authenticaton stopped working, because the code working with the DerbyWrapper had changed, and now gliserver.pl could no longer instantiate another JVM that would access the Derby DB (via the users2DBtxt.java) when wanting to check if a user authenticates. Instead, a new GS3 service has been written, Authentication.remoteAuthentication(). This is called from the authentication-ping system action URL that the new ServletRealmCheck.java pings when it is called by gliserver.pl

  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/*
2 * GSParams.java
3 * Copyright (C) 2008 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.gsdl3.util;
20
21import java.util.HashMap;
22
23/** keeps track of the servlet parameters, and their defaults */
24public class GSParams
25{
26
27 // cgi parameter names
28 public static final String ACTION = "a"; // the major type of action- eg query or browse or process
29 public static final String SUBACTION = "sa"; // subtype of action if we want different processing than the default
30 public static final String REQUEST_TYPE = "rt"; // whether the request is just to display the service form, or to actually do a request to the service
31 public static final String RESPONSE_ONLY = "ro"; // if == 1 do the request and pass back the response xml - no page formatting
32 public static final String OUTPUT = "o"; // if processing is to be done, what type of output - html/xml/other??
33 public static final String SERVICE = "s"; // the name of the service
34
35 public static final String UN = "un"; // username for authenticated-ping
36 public static final String PW = "pw"; // pwd for authenticated-ping
37
38 public static final String CLUSTER = "c"; // these two are the same
39 public static final String COLLECTION = "c";
40 public static final String COLLECTION_TYPE = "ct"; // collection type - mg, mgpp, lucene etc
41
42 public static final String LANGUAGE = "l";
43 public static final String DOCUMENT = "d";
44 public static final String DOCUMENT_TYPE = "dt";
45 public static final String START_PAGE = "startPage";
46 public static final String S_START_PAGE = "s1.startPage";
47 public static final String HREF = "href"; // url. might be an external url, or a relative one that needs translating
48 public static final String RELATIVE_LINK = "rl"; // whether the href url is relative to the collection or not.
49 public static final String EXTERNAL_LINK_TYPE = "el"; // for an external link, go direct to the page or frame it in the collection
50 public static final String PROCESS_ID = "pid"; // if a request wasn't completed, this identifies the request - used when asking for a status update
51
52 public static final String HTTP_HEADER_FIELDS = "hhf";
53 public static final String QUICK_SEARCH = "qs";
54
55 // internal configure args
56 public static final String SYSTEM_SUBSET = "ss";
57 public static final String SYSTEM_CLUSTER = "sc";
58 public static final String SYSTEM_MODULE_NAME = "sn";
59 public static final String SYSTEM_MODULE_TYPE = "st";
60
61 // used for filtering out a piece of the final page
62 public static final String EXCERPT_ID = "excerptid";
63 public static final String EXCERPT_TAG = "excerpttag";
64
65 public static final String INLINE_TEMPLATE = "ilt";
66 public static final String DISPLAY_METADATA = "dmd";
67 public static final String FILE_LOCATION = "fl";
68 public static final String DOC_EDIT = "docEdit";
69 public static final String AJAX_LOAD_BYPASS = "alb";
70
71 //Administration
72 public static final String PASSWORD = "password";
73 public static final String S_PASSWORD = "s1.password";
74 public static final String S_NEW_PASSWORD = "s1.newPassword";
75 public static final String S_OLD_PASSWORD = "s1.oldPassword";
76
77 //Facets
78 public static final String S_FACETS = "s1.facets";
79 public static final String S_FACETS_QUERIES = "s1.facetQueries";
80
81 // some standard arg values
82 public static final String SYSTEM_ACTION = "s";
83
84 // rss feeds
85 public static final String RSS_ACTION = "rss";
86
87 public static final String EXTERNAL_LINK_TYPE_DIRECT = "direct";
88 public static final String EXTERNAL_LINK_TYPE_FRAMED = "frame";
89
90 public static final String DEBUG = "debug";
91
92 protected HashMap<String, Param> param_map = null;
93
94 public GSParams()
95 {
96 this.param_map = new HashMap<String, Param>(30);
97
98 // add in all the standard params
99 addParameter(ACTION, false);
100 addParameter(SUBACTION, false);
101 addParameter(REQUEST_TYPE, false);
102 addParameter(RESPONSE_ONLY, false);
103 addParameter(CLUSTER, false); // we don't want to save cluster/collection
104 addParameter(LANGUAGE, true);
105 addParameter(DOCUMENT, true);
106 addParameter(DOCUMENT_TYPE, false);
107 addParameter(QUICK_SEARCH, false);
108 addParameter(START_PAGE, false);
109 addParameter(S_START_PAGE, false);
110 // should the following two just be in doc action??
111 addParameter(HREF, false);
112 addParameter(RELATIVE_LINK, false);
113 addParameter(OUTPUT, false);
114 addParameter(SERVICE, false);
115 addParameter(PROCESS_ID, true);
116 addParameter(SYSTEM_SUBSET, false);
117 addParameter(SYSTEM_CLUSTER, false);
118 addParameter(SYSTEM_MODULE_NAME, false);
119 addParameter(SYSTEM_MODULE_TYPE, false);
120 addParameter(INLINE_TEMPLATE, false);
121 addParameter(DISPLAY_METADATA, false);
122 addParameter(AJAX_LOAD_BYPASS, false);
123 addParameter(DOC_EDIT, false);
124 addParameter(PASSWORD, false);
125 addParameter(S_PASSWORD, false);
126 addParameter(S_NEW_PASSWORD, false);
127 addParameter(S_OLD_PASSWORD, false);
128
129 addParameter(S_FACETS, false);
130 addParameter(S_FACETS_QUERIES, false);
131
132 addParameter(COLLECTION_TYPE, true);
133 addParameter(EXTERNAL_LINK_TYPE, false);
134 // filtering args must be specified each time
135 addParameter(EXCERPT_ID, false);
136 addParameter(EXCERPT_TAG, false);
137
138 addParameter(DEBUG, true);
139 }
140
141 public boolean addParameter(String name, boolean save)
142 {
143 return addParameter(name, "", save);
144 }
145
146 public boolean addParameter(String name, String default_value, boolean save)
147 {
148 if (this.param_map.containsKey(name))
149 {
150 // already there so could not add
151 return false;
152 }
153
154 this.param_map.put(name, new Param(default_value, save));
155 return true;
156 }
157
158 public boolean setParamDefault(String name, String default_value)
159 {
160 Param p = this.param_map.get(name);
161 if (p == null)
162 return false;
163 p.default_value = default_value;
164 return true;
165 }
166
167 public boolean shouldSave(String name)
168 {
169 // p. is used to store previous settings
170 if (name.startsWith("p.") || name.startsWith("md___"))
171 return false;
172 Param p = this.param_map.get(name);
173 if (p == null)
174 return true; // if things are not in here, always save.
175 return p.save;
176 }
177
178 private class Param
179 {
180
181 public String default_value = null;
182 public boolean save = true;
183
184 public Param(String default_value, boolean save)
185 {
186 this.default_value = default_value;
187 this.save = save;
188 }
189 }
190}
Note: See TracBrowser for help on using the repository browser.