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

Last change on this file since 25461 was 25461, checked in by sjm84, 12 years ago

A minor format edit and adding a docEdit cgi parameter to control when the on-page format editing is on

  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 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 interface 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 CLUSTER = "c"; // these two are the same
36 public static final String COLLECTION = "c";
37 public static final String COLLECTION_TYPE = "ct"; // collection type - mg, mgpp, lucene etc
38
39 public static final String LANGUAGE = "l";
40 public static final String DOCUMENT = "d";
41 public static final String DOCUMENT_TYPE = "dt";
42 public static final String HREF = "href"; // url. might be an external url, or a relative one that needs translating
43 public static final String RELATIVE_LINK = "rl"; // whether the href url is relative to the collection or not.
44 public static final String EXTERNAL_LINK_TYPE = "el"; // for an external link, go direct to the page or frame it in the collection
45 public static final String PROCESS_ID = "pid"; // if a request wasn't completed, this identifies the request - used when asking for a status update
46
47 public static final String HTTPHEADERFIELDS = "hhf";
48
49 // internal configure args
50 public static final String SYSTEM_SUBSET = "ss";
51 public static final String SYSTEM_CLUSTER = "sc";
52 public static final String SYSTEM_MODULE_NAME = "sn";
53 public static final String SYSTEM_MODULE_TYPE = "st";
54
55 // used for filtering out a piece of the final page
56 public static final String EXCERPT_ID = "excerptid";
57 public static final String EXCERPT_TAG = "excerpttag";
58
59 public static final String INLINE_TEMPLATE = "ilt";
60 public static final String DISPLAY_METADATA = "dmd";
61 public static final String FILE_LOCATION = "fl";
62 public static final String DOC_EDIT = "docEdit";
63
64 //Administration
65 public static final String PASSWORD = "password";
66 public static final String S_PASSWORD = "s1.password";
67 public static final String S_NEW_PASSWORD = "s1.newPassword";
68 public static final String S_OLD_PASSWORD = "s1.oldPassword";
69
70 // some standard arg values
71 public static final String SYSTEM_ACTION = "s";
72
73 public static final String EXTERNAL_LINK_TYPE_DIRECT = "direct";
74 public static final String EXTERNAL_LINK_TYPE_FRAMED = "frame";
75
76 protected HashMap param_map = null;
77
78 public GSParams()
79 {
80 this.param_map = new HashMap(30);
81
82 // add in all the standard params
83 addParameter(ACTION, false);
84 addParameter(SUBACTION, false);
85 addParameter(REQUEST_TYPE, false);
86 addParameter(RESPONSE_ONLY, false);
87 addParameter(CLUSTER, false); // we don't want to save cluster/collection
88 addParameter(LANGUAGE, true);
89 addParameter(DOCUMENT, true);
90 addParameter(DOCUMENT_TYPE, true);
91 // should the following two just be in doc action??
92 addParameter(HREF, false);
93 addParameter(RELATIVE_LINK, false);
94 addParameter(OUTPUT, false);
95 addParameter(SERVICE, false);
96 addParameter(PROCESS_ID, true);
97 addParameter(SYSTEM_SUBSET, false);
98 addParameter(SYSTEM_CLUSTER, false);
99 addParameter(SYSTEM_MODULE_NAME, false);
100 addParameter(SYSTEM_MODULE_TYPE, false);
101 addParameter(INLINE_TEMPLATE, false);
102 addParameter(DISPLAY_METADATA, false);
103 addParameter(DOC_EDIT, false);
104 addParameter(PASSWORD, false);
105 addParameter(S_PASSWORD, false);
106 addParameter(S_NEW_PASSWORD, false);
107 addParameter(S_OLD_PASSWORD, false);
108
109 addParameter(COLLECTION_TYPE, true);
110 addParameter(EXTERNAL_LINK_TYPE, false);
111 // filtering args must be specified each time
112 addParameter(EXCERPT_ID, false);
113 addParameter(EXCERPT_TAG, false);
114 }
115
116 public boolean addParameter(String name, boolean save)
117 {
118 return addParameter(name, "", save);
119 }
120
121 public boolean addParameter(String name, String default_value, boolean save)
122 {
123 if (this.param_map.containsKey(name))
124 {
125 // already there so could not add
126 return false;
127 }
128
129 this.param_map.put(name, new Param(default_value, save));
130 return true;
131 }
132
133 public boolean setParamDefault(String name, String default_value)
134 {
135 Param p = (Param) this.param_map.get(name);
136 if (p == null)
137 return false;
138 p.default_value = default_value;
139 return true;
140 }
141
142 public boolean shouldSave(String name)
143 {
144 // p. is used to store previous settings
145 if (name.startsWith("p."))
146 return false;
147 Param p = (Param) this.param_map.get(name);
148 if (p == null)
149 return true; // if things are not in here, always save.
150 return p.save;
151 }
152
153 private class Param
154 {
155
156 public String default_value = null;
157 public boolean save = true;
158
159 public Param(String default_value, boolean save)
160 {
161 this.default_value = default_value;
162 this.save = save;
163 }
164 }
165}
Note: See TracBrowser for help on using the repository browser.