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

Last change on this file since 11010 was 11010, checked in by kjdon, 18 years ago

no longer save the collection param - so cross collection services work. also don't save params that start with 'p.'

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