Changeset 24861 for main/trunk/greenstone3
- Timestamp:
- 2011-12-06T12:49:05+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSParams.java
r24019 r24861 22 22 23 23 /** keeps track of the interface parameters, and their defaults */ 24 public class GSParams { 24 public 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 HTTPHEADERFIELDS = "hhf"; 32 public static final String SERVICE = "s"; // the name of the service 33 public static final String CLUSTER = "c"; // these two are the same 34 public static final String SYSTEM = "s"; 35 public static final String CONFIGURE = "c"; 36 public static final String COLLECTION = "c"; 37 public static final String LANGUAGE = "l"; 38 public static final String DOCUMENT = "d"; 39 public static final String DOCUMENT_TYPE = "dt"; 40 public static final String RESOURCE = "r"; 41 public static final String PROCESS_ID = "pid"; // if a request wasn't completed, this identifies the request - used when asking for a status update 42 public static final String COLLECTION_TYPE = "ct"; 25 43 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 HTTPHEADERFIELDS = "hhf"; 32 public static final String SERVICE = "s"; // the name of the service 33 public static final String CLUSTER = "c"; // these two are the same 34 public static final String SYSTEM = "s"; 35 public static final String CONFIGURE = "c"; 36 public static final String COLLECTION = "c"; 37 public static final String LANGUAGE = "l"; 38 public static final String DOCUMENT = "d"; 39 public static final String DOCUMENT_TYPE = "dt"; 40 public static final String RESOURCE = "r"; 41 public static final String PROCESS_ID = "pid"; // if a request wasn't completed, this identifies the request - used when asking for a status update 42 public static final String COLLECTION_TYPE = "ct"; 43 44 public static final String SIBLING = "sib"; // this should not be in here 45 // internal configure args 46 public static final String SYSTEM_SUBSET = "ss"; 47 public static final String SYSTEM_CLUSTER = "sc"; 48 public static final String SYSTEM_MODULE_NAME = "sn"; 49 public static final String SYSTEM_MODULE_TYPE = "st"; 44 public static final String SIBLING = "sib"; // this should not be in here 45 // internal configure args 46 public static final String SYSTEM_SUBSET = "ss"; 47 public static final String SYSTEM_CLUSTER = "sc"; 48 public static final String SYSTEM_MODULE_NAME = "sn"; 49 public static final String SYSTEM_MODULE_TYPE = "st"; 50 50 51 52 51 public static final String EXPAND_DOCUMENT = "ed"; 52 public static final String EXPAND_CONTENTS = "ec"; 53 53 public static final String REALISTIC_BOOK = "book"; 54 54 55 // used for filtering out a piece of the final page 56 public static final String EXCERPT_ID = "excerptid"; 57 public static final String EXCERPT_TAG = "excerpttag"; 58 protected HashMap param_map = null; 59 60 public GSParams() { 61 this.param_map = new HashMap(30); 55 // used for filtering out a piece of the final page 56 public static final String EXCERPT_ID = "excerptid"; 57 public static final String EXCERPT_TAG = "excerpttag"; 58 protected HashMap param_map = null; 62 59 63 // add in all the standard params 64 addParameter(ACTION, false); 65 addParameter(SUBACTION, false); 66 addParameter(REQUEST_TYPE, false); 67 addParameter(RESPONSE_ONLY, false); 68 addParameter(CLUSTER, false); // we don't want to save collection 69 //addParameter(COLLECTION); 70 addParameter(LANGUAGE, true); 71 addParameter(DOCUMENT, true); 72 addParameter(RESOURCE, true); 73 addParameter(OUTPUT, false); 74 addParameter(SERVICE, false); 75 addParameter(PROCESS_ID, true); 76 addParameter(SYSTEM_SUBSET, false); 77 addParameter(SYSTEM_CLUSTER, false); 78 addParameter(SYSTEM_MODULE_NAME, false); 79 addParameter(SYSTEM_MODULE_TYPE, false); 80 addParameter(SIBLING, false); 81 addParameter(DOCUMENT_TYPE, true); 82 addParameter(EXPAND_DOCUMENT, false); 83 addParameter(EXPAND_CONTENTS, false); 84 addParameter(REALISTIC_BOOK, false); 85 86 //addParameter(); 87 // ugly hack so we don't save the extlink param 88 addParameter("s0.ext", false); 89 addParameter(COLLECTION_TYPE, true); // collection type - mg or mgpp 60 public GSParams() 61 { 62 this.param_map = new HashMap(30); 90 63 91 // filtering args must be specified each time 92 addParameter(EXCERPT_ID, false); 93 addParameter(EXCERPT_TAG, false); 94 } 95 96 public boolean addParameter(String name, boolean save) { 97 return addParameter(name, "", save); 98 } 99 100 public boolean addParameter(String name, String default_value, boolean save) { 101 if (this.param_map.containsKey(name)) { 102 // already there so could not add 103 return false; 64 // add in all the standard params 65 addParameter(ACTION, false); 66 addParameter(SUBACTION, false); 67 addParameter(REQUEST_TYPE, false); 68 addParameter(RESPONSE_ONLY, false); 69 addParameter(CLUSTER, false); // we don't want to save collection 70 //addParameter(COLLECTION); 71 addParameter(LANGUAGE, true); 72 addParameter(DOCUMENT, true); 73 addParameter(RESOURCE, true); 74 addParameter(OUTPUT, false); 75 addParameter(SERVICE, false); 76 addParameter(PROCESS_ID, true); 77 addParameter(SYSTEM_SUBSET, false); 78 addParameter(SYSTEM_CLUSTER, false); 79 addParameter(SYSTEM_MODULE_NAME, false); 80 addParameter(SYSTEM_MODULE_TYPE, false); 81 addParameter(SIBLING, false); 82 addParameter(DOCUMENT_TYPE, true); 83 addParameter(EXPAND_DOCUMENT, false); 84 addParameter(EXPAND_CONTENTS, false); 85 addParameter(REALISTIC_BOOK, false); 86 87 //addParameter(); 88 // ugly hack so we don't save the extlink param 89 addParameter("s0.ext", false); 90 addParameter(COLLECTION_TYPE, true); // collection type - mg or mgpp 91 92 // filtering args must be specified each time 93 addParameter(EXCERPT_ID, false); 94 addParameter(EXCERPT_TAG, false); 104 95 } 105 96 106 this.param_map.put(name, new Param(default_value, save)); 107 return true; 108 } 109 110 public boolean setParamDefault(String name, String default_value) { 111 Param p = (Param)this.param_map.get(name); 112 if (p==null) return false; 113 p.default_value = default_value; 114 return true; 115 } 116 117 public boolean shouldSave(String name) { 118 if (name.startsWith("p.")) return false; 119 Param p = (Param)this.param_map.get(name); 120 if (p== null) return true; // if things are not in here, always save. 121 return p.save; 122 } 123 124 private class Param { 97 public boolean addParameter(String name, boolean save) 98 { 99 return addParameter(name, "", save); 100 } 125 101 126 public String default_value = null; 127 public boolean save = true; 102 public boolean addParameter(String name, String default_value, boolean save) 103 { 104 if (this.param_map.containsKey(name)) 105 { 106 // already there so could not add 107 return false; 108 } 128 109 129 public Param(String default_value, boolean save) { 130 this.default_value = default_value; 131 this.save = save; 110 this.param_map.put(name, new Param(default_value, save)); 111 return true; 132 112 } 133 } 113 114 public boolean setParamDefault(String name, String default_value) 115 { 116 Param p = (Param) this.param_map.get(name); 117 if (p == null) 118 return false; 119 p.default_value = default_value; 120 return true; 121 } 122 123 public boolean shouldSave(String name) 124 { 125 if (name.startsWith("p.")) 126 return false; 127 Param p = (Param) this.param_map.get(name); 128 if (p == null) 129 return true; // if things are not in here, always save. 130 return p.save; 131 } 132 133 private class Param 134 { 135 136 public String default_value = null; 137 public boolean save = true; 138 139 public Param(String default_value, boolean save) 140 { 141 this.default_value = default_value; 142 this.save = save; 143 } 144 } 134 145 } 135 136
Note:
See TracChangeset
for help on using the changeset viewer.