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

Last change on this file since 14641 was 14641, checked in by anna, 17 years ago

Added the collection type (ct) parameter.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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 public static final String COLLECTION_TYPE = "ct";
24
25 public static final String SIBLING = "sib"; // this should not be in here
26 // internal configure args
27 public static final String SYSTEM_SUBSET = "ss";
28 public static final String SYSTEM_CLUSTER = "sc";
29 public static final String SYSTEM_MODULE_NAME = "sn";
30 public static final String SYSTEM_MODULE_TYPE = "st";
31
32 public static final String EXPAND_DOCUMENT = "ed";
33 public static final String EXPAND_CONTENTS = "ec";
34 protected HashMap param_map = null;
35
36 public GSParams() {
37 this.param_map = new HashMap(30);
38
39 // add in all the standard params
40 addParameter(ACTION, false);
41 addParameter(SUBACTION, false);
42 addParameter(REQUEST_TYPE, false);
43 addParameter(RESPONSE_ONLY, false);
44 addParameter(CLUSTER, false); // we don't want to save collection
45 //addParameter(COLLECTION);
46 addParameter(LANGUAGE, true);
47 addParameter(DOCUMENT, true);
48 addParameter(RESOURCE, true);
49 addParameter(OUTPUT, false);
50 addParameter(SERVICE, false);
51 addParameter(PROCESS_ID, true);
52 addParameter(SYSTEM_SUBSET, false);
53 addParameter(SYSTEM_CLUSTER, false);
54 addParameter(SYSTEM_MODULE_NAME, false);
55 addParameter(SYSTEM_MODULE_TYPE, false);
56 addParameter(SIBLING, false);
57 addParameter(DOCUMENT_TYPE, true);
58 addParameter(EXPAND_DOCUMENT, false);
59 addParameter(EXPAND_CONTENTS, false);
60 //addParameter();
61 // ugly hack so we don't save the extlink param
62 addParameter("s0.ext", false);
63 addParameter(COLLECTION_TYPE, true); // collection type - mg or mgpp
64 }
65
66 public boolean addParameter(String name, boolean save) {
67 return addParameter(name, "", save);
68 }
69
70 public boolean addParameter(String name, String default_value, boolean save) {
71 if (this.param_map.containsKey(name)) {
72 // already there so could not add
73 return false;
74 }
75
76 this.param_map.put(name, new Param(default_value, save));
77 return true;
78 }
79
80 public boolean setParamDefault(String name, String default_value) {
81 Param p = (Param)this.param_map.get(name);
82 if (p==null) return false;
83 p.default_value = default_value;
84 return true;
85 }
86
87 public boolean shouldSave(String name) {
88 if (name.startsWith("p.")) return false;
89 Param p = (Param)this.param_map.get(name);
90 if (p== null) return true; // if things are not in here, always save.
91 return p.save;
92 }
93
94 private class Param {
95
96 public String default_value = null;
97 public boolean save = true;
98
99 public Param(String default_value, boolean save) {
100 this.default_value = default_value;
101 this.save = save;
102 }
103 }
104}
105
106
Note: See TracBrowser for help on using the repository browser.