Changeset 3645


Ignore:
Timestamp:
2003-01-06T15:23:47+13:00 (21 years ago)
Author:
kjdon
Message:

actions tidied up a bit, ResourceAction changed to DocumentAction, BuildAction removed, more general ProcessAction added

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/action
Files:
2 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/Action.java

    r3568 r3645  
    1818    protected XMLConverter converter_=null;
    1919    /** cgi args converter */
    20     protected CGIArgConverter cgi_=null;
     20    protected GSCGI cgi_ = null;
    2121    /** a transformer class to transform xml using xslt */
    2222    protected XMLTransformer transformer_=null;
    23 
    2423    /** a reference to the message router that it must talk to to
    2524     * get info. it may be a communicator acting as a proxy, but it
    2625     doesn't care about that */
    2726    protected ModuleInterface mr_=null;
    28 
    2927
    3028    public Action() {
     
    4139       mr_ = m;
    4240    }
    43 
    44     public void setCGIConverter(CGIArgConverter cgi) {
     41    /** sets the GSCGI object - used to convert between short and long names
     42     * of params */
     43    public void setCGI(GSCGI cgi) {
    4544    cgi_ = cgi;
     45    // add in any action specific params
     46    addCGIParams();
    4647    }
    4748    public void configure() {
    4849    // does nothing yet
    4950    }
    50 
     51    /** any action specific cgi params should be added to the GSCGI object-
     52     * overwrite this if a new action has its own params
     53     * using cgi_.addStaticParam(param-name) */
     54    protected void addCGIParams() {
     55   
     56    }
    5157    /** process takes an xml representation of cgi args
    5258     * and returns the page of results - may be in html/xml/other
     
    6066    }
    6167   
     68    /** the main process method - must be implemented in subclass */
    6269    abstract public Element process(Element xml_in);
    6370   
    64 
     71   
    6572}
    6673
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r3568 r3645  
    4040    HashMap params = GSXML.extractParams(cgi_param_list);
    4141
    42     String collection = (String)params.get("collection");
    43     String service_name=(String)params.get("serviceName");
     42    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
     43    String service_name=(String)params.get(GSCGI.SERVICE_ARG);
    4444    service_name+= "Applet";
    4545   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r3604 r3645  
    5151
    5252    // extract the params from the cgi-request, and check that we have a coll specified
    53     // first convert short to long names
    5453    Element cgi_paramList = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    55     cgi_.toLong(cgi_paramList);
    5654    HashMap params = GSXML.extractParams(cgi_paramList);
    5755
    58     String collection = (String)params.get("collection");
     56    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    5957    if (collection == null || collection.equals("")) {
    6058        System.err.println("BrowseAction Error:classifierbrowse, need to specify a collection!");
     
    9088   
    9189    // if there is a cl field in the cgi params, get the classifier info
    92     String node = (String)params.get("classifier");
     90    String node = (String)params.get("cl");
    9391   
    9492    if (node!=null && !node.equals("")) {
     
    110108       
    111109        // content - contains the classifier node, may be more than one
    112         // call this resource list for now
     110        // call this document list for now
    113111        Element query_content = doc_.createElement(GSXML.CONTENT_ELEM);
    114112        mr_query_request.appendChild(query_content);
    115113       
    116         Element resource_list = doc_.createElement(GSXML.RESOURCE_ELEM+GSXML.LIST_MODIFIER);
    117         Element resource = doc_.createElement(GSXML.RESOURCE_ELEM);
    118         resource.setAttribute(GSXML.NAME_ATT, node);
    119         resource_list.appendChild(resource);
    120         query_content.appendChild(resource_list);
     114        Element document_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
     115        Element document = doc_.createElement(GSXML.DOCUMENT_ELEM);
     116        document.setAttribute(GSXML.NAME_ATT, node);
     117        document_list.appendChild(document);
     118        query_content.appendChild(document_list);
    121119       
    122120        Element mr_query_response = (Element)mr_.process(mr_query_message);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r3568 r3645  
    1414public class PageAction extends Action {
    1515
     16    public static final String SHORT_ACTION_NAME = "p";
     17    public static final String HOME_PAGE = "home";
     18    public static final String ABOUT_PAGE = "about";
     19
     20    public String getActionShortName() {
     21    return SHORT_ACTION_NAME;
     22    }
    1623    public Element process (Element message) {
    1724   
     
    2027    String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
    2128    if (page_name.equals("")) { // if no page specified, assume home page
    22         page_name = "home";
     29        page_name = HOME_PAGE;
    2330    }
    2431   
     
    3037    // add the system stuff from message
    3138    page.appendChild(doc_.importNode(GSXML.getChildByTagName(message, GSXML.CONFIGURATION_ELEM), true));
    32    
    33     if (page_name.equals("home")) {
     39    // add the cgi args request
     40    Element cgi_request = (Element)doc_.importNode(request, true);
     41    page.appendChild(cgi_request);
     42
     43    if (page_name.equals(HOME_PAGE)) {
    3444        return homePage(page, request);
    35     } else if (page_name.equals("about")) {
     45    } else if (page_name.equals(ABOUT_PAGE)) {
    3646        return aboutPage(page, request);
    3747    } else {
     
    111121    HashMap params = GSXML.extractParams(cgi_paramList);
    112122   
    113     String coll_name = (String)params.get("collection");
    114     if (coll_name == null || coll_name.equals("")) {
    115         coll_name = (String)params.get("serviceCluster"); // cluster name
    116     }
     123    String coll_name = (String)params.get(GSCGI.COLLECTION_ARG);
    117124    if (coll_name == null || coll_name.equals("")) {
    118125        System.err.println("PageAction Error: about page requested with no collection or cluster specified!");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r3603 r3645  
    5959    HashMap params = GSXML.extractParams(cgi_param_list);
    6060
    61     String collection = (String)params.get("collection");
     61    String collection = (String)params.get(GSCGI.COLLECTION_ARG);
    6262    if (collection == null || collection.equals("")) {
    6363        System.err.println("QueryAction Error: no collection was specified!");
     
    7777
    7878    Element mr_info_response = (Element) mr_.process(mr_info_message);
    79     System.out.println("describe response from query=");
    80     System.out.println(converter_.getString(mr_info_response));
    8179    String path = GSXML.RESPONSE_ELEM;
    8280    path = GSPath.appendLink(path, GSXML.SERVICE_ELEM);
     
    8785        System.out.println("adding shortnames");
    8886        // add short names to the params in the param list
    89         cgi_.addShortNames(pl);
     87        cgi_.paramListAddShortNames(pl);
    9088        // for each param in the description, overwrite teh default value with the currently set value if present
    9189        Element param = (Element)pl.getFirstChild();
     
    116114        }
    117115    }
    118     System.out.println(converter_.getString(pl));
    119116   
    120117    // part of the data for the description is the cgi-params
     
    148145    // for now, just create a whole new request
    149146   
    150     // check that there are some resources - for now check the list, but later should use a numdocs metadata elem
     147    // check that there are some documents - for now check the list, but later should use a numdocs metadata elem
    151148    path = GSXML.RESPONSE_ELEM;
    152149    path = GSPath.appendLink(path, GSXML.CONTENT_ELEM);
    153     path = GSPath.appendLink(path, GSXML.RESOURCE_ELEM+GSXML.LIST_MODIFIER);
    154    
    155     Element resource_list = (Element)GSXML.getNodeByPath(mr_query_response,
    156                                  path); // resourceList not present if no docs found
    157     if (resource_list == null) {
     150    path = GSPath.appendLink(path, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
     151   
     152    Element document_list = (Element)GSXML.getNodeByPath(mr_query_response,
     153                                 path); // documentList not present if no docs found
     154    if (document_list == null) {
    158155       
    159156        Element result_response = (Element)GSXML.getChildByTagName(mr_query_response, GSXML.RESPONSE_ELEM);
     
    182179   
    183180    // the first part of the content is the doc list
    184     meta_content.appendChild(doc_.importNode(resource_list, true));
     181    meta_content.appendChild(doc_.importNode(document_list, true));
    185182   
    186183    // the second part of the content is the metadata list
Note: See TracChangeset for help on using the changeset viewer.