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

Last change on this file since 21000 was 16869, checked in by kjdon, 16 years ago

added license message

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