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

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

Added in the parameters necessary to do an inline template

  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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 public static final String ACTION = "a"; // the major type of action- eg query or browse or process
28 public static final String SUBACTION = "sa"; // subtype of action if we want different processing than the default
29 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
30 public static final String RESPONSE_ONLY = "ro"; // if == 1 do the request and pass back the response xml - no page formatting
31 public static final String OUTPUT = "o"; // if processing is to be done, what type of output - html/xml/other??
32 public static final String HTTPHEADERFIELDS = "hhf";
33 public static final String SERVICE = "s"; // the name of the service
34 public static final String CLUSTER = "c"; // these two are the same
35 public static final String SYSTEM = "s";
36 public static final String CONFIGURE = "c";
37 public static final String COLLECTION = "c";
38 public static final String LANGUAGE = "l";
39 public static final String DOCUMENT = "d";
40 public static final String DOCUMENT_TYPE = "dt";
41 public static final String RESOURCE = "r";
42 public static final String PROCESS_ID = "pid"; // if a request wasn't completed, this identifies the request - used when asking for a status update
43 public static final String COLLECTION_TYPE = "ct";
44
45 public static final String SIBLING = "sib"; // this should not be in here
46 // internal configure args
47 public static final String SYSTEM_SUBSET = "ss";
48 public static final String SYSTEM_CLUSTER = "sc";
49 public static final String SYSTEM_MODULE_NAME = "sn";
50 public static final String SYSTEM_MODULE_TYPE = "st";
51
52 public static final String EXPAND_DOCUMENT = "ed";
53 public static final String EXPAND_CONTENTS = "ec";
54 public static final String REALISTIC_BOOK = "book";
55
56 // used for filtering out a piece of the final page
57 public static final String EXCERPT_ID = "excerptid";
58 public static final String EXCERPT_TAG = "excerpttag";
59
60 public static final String INLINE_TEMPLATE = "ilt";
61 public static final String DISPLAY_METADATA = "dmd";
62
63 protected HashMap param_map = null;
64
65 public GSParams()
66 {
67 this.param_map = new HashMap(30);
68
69 // add in all the standard params
70 addParameter(ACTION, false);
71 addParameter(SUBACTION, false);
72 addParameter(REQUEST_TYPE, false);
73 addParameter(RESPONSE_ONLY, false);
74 addParameter(CLUSTER, false); // we don't want to save collection
75 //addParameter(COLLECTION);
76 addParameter(LANGUAGE, true);
77 addParameter(DOCUMENT, true);
78 addParameter(RESOURCE, true);
79 addParameter(OUTPUT, false);
80 addParameter(SERVICE, false);
81 addParameter(PROCESS_ID, true);
82 addParameter(SYSTEM_SUBSET, false);
83 addParameter(SYSTEM_CLUSTER, false);
84 addParameter(SYSTEM_MODULE_NAME, false);
85 addParameter(SYSTEM_MODULE_TYPE, false);
86 addParameter(SIBLING, false);
87 addParameter(DOCUMENT_TYPE, true);
88 addParameter(EXPAND_DOCUMENT, false);
89 addParameter(EXPAND_CONTENTS, false);
90 addParameter(REALISTIC_BOOK, false);
91 addParameter(INLINE_TEMPLATE, false);
92 addParameter(DISPLAY_METADATA, false);
93
94 //addParameter();
95 // ugly hack so we don't save the extlink param
96 addParameter("s0.ext", false);
97 addParameter(COLLECTION_TYPE, true); // collection type - mg or mgpp
98
99 // filtering args must be specified each time
100 addParameter(EXCERPT_ID, false);
101 addParameter(EXCERPT_TAG, false);
102 }
103
104 public boolean addParameter(String name, boolean save)
105 {
106 return addParameter(name, "", save);
107 }
108
109 public boolean addParameter(String name, String default_value, boolean save)
110 {
111 if (this.param_map.containsKey(name))
112 {
113 // already there so could not add
114 return false;
115 }
116
117 this.param_map.put(name, new Param(default_value, save));
118 return true;
119 }
120
121 public boolean setParamDefault(String name, String default_value)
122 {
123 Param p = (Param) this.param_map.get(name);
124 if (p == null)
125 return false;
126 p.default_value = default_value;
127 return true;
128 }
129
130 public boolean shouldSave(String name)
131 {
132 if (name.startsWith("p."))
133 return false;
134 Param p = (Param) this.param_map.get(name);
135 if (p == null)
136 return true; // if things are not in here, always save.
137 return p.save;
138 }
139
140 private class Param
141 {
142
143 public String default_value = null;
144 public boolean save = true;
145
146 public Param(String default_value, boolean save)
147 {
148 this.default_value = default_value;
149 this.save = save;
150 }
151 }
152}
Note: See TracBrowser for help on using the repository browser.