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

Last change on this file since 14403 was 14403, checked in by xiao, 17 years ago

add in two constant parameters.

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