Changeset 32453


Ignore:
Timestamp:
09/13/18 14:18:16 (3 years ago)
Author:
kjdon
Message:

replacing hard coded param names with static string variables. set up save params for those params we need to save to the session.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java

    r32083 r32453  
    123123            return false;
    124124        }
     125
     126        // set up which params to save
     127        this.save_params.add(LEVEL_PARAM);
     128        this.save_params.add(RANK_PARAM);
     129        this.save_params.add(RAW_PARAM);
     130        this.save_params.add(FIELD_QUERY_PARAM);
     131        this.save_params.add(FIELD_STEM_PARAM);
     132        this.save_params.add(FIELD_CASE_PARAM);
     133        this.save_params.add(FIELD_ACCENT_PARAM);
     134        this.save_params.add(FIELD_FIELD_PARAM);
     135        this.save_params.add(FIELD_COMBINE_PARAM);
    125136       
    126137        // Get the default level out of <defaultLevel> (buildConfig.xml)
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java

    r30049 r32453  
    128128          getSearchParamDefaults(search_elem);
    129129        }
     130
     131        // store any that we need to save
     132        // previously these were all saved by default, so adding them all
     133        this.save_params.add(INDEX_PARAM);
     134        this.save_params.add(QUERY_PARAM);
     135        this.save_params.add(RAW_PARAM);
     136        this.save_params.add(MAXDOCS_PARAM);
     137        this.save_params.add(HITS_PER_PAGE_PARAM);
     138        this.save_params.add(START_PAGE_PARAM);
     139       
    130140        // add some format info to service map if there is any
    131141        // => lookin extra info first look in buildConfig
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractTextSearch.java

    r28966 r32453  
    7171    }
    7272
     73    public boolean configure(Element info, Element extra_info)
     74    {
     75        if (!super.configure(info, extra_info))
     76        {
     77            return false;
     78        }
     79
     80        logger.info("Configuring AbstractTextSearch...");
     81        // we need to set up the save_params - we want all our search settings saved by default
     82        this.save_params.add(INDEX_SUBCOLLECTION_PARAM);
     83        this.save_params.add(INDEX_LANGUAGE_PARAM);
     84        this.save_params.add(CASE_PARAM);
     85        this.save_params.add(STEM_PARAM);
     86        this.save_params.add(ACCENT_PARAM);
     87        this.save_params.add(MATCH_PARAM);
     88
     89        return true;
     90
     91    }
    7392    /** adds the standard query params into the service description */
    7493    protected void addStandardQueryParams(Element param_list, String lang)
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/BerryBasket.java

    r32308 r32453  
    6666    protected static final String DELETE_ITEM_SERVICE = "DeleteItem";
    6767
     68  // for AddItem
    6869    protected static final String ITEM_PARAM = "item";
     70  // for DeleteItems
     71  protected static final String ITEMS_PARAM = "items";
     72  // for SendMail
     73  protected static final String ADDRESS_PARAM = "address";
     74  protected static final String SUBJECT_PARAM = "subject";
     75  protected static final String CONTENT_PARAM = "content";
     76  protected static final String CC_PARAM = "cc";
     77  protected static final String BCC_PARAM = "bcc";
     78
     79 
    6980    protected static final String delimiter = "|";
    7081    protected static final int delay = 1800000;
     
    171182
    172183        }
     184
     185        // if any params should be saved in the session, add them to save_params here
     186        // this.save_params.add(XXX_PARAM);
    173187        return true;
    174188
     
    252266        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    253267
    254         String item = (String) params.get("item");
     268        String item = (String) params.get(ITEM_PARAM);
    255269        String collection = "";
    256270        int pos = item.indexOf(":");
     
    334348        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    335349
    336         String param = (String) params.get("items");
     350        String param = (String) params.get(ITEMS_PARAM);
    337351
    338352        if (param == null)
     
    496510        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
    497511
    498         String to = (String) params.get("address");
    499         String subject = (String) params.get("subject");
    500         String content = (String) params.get("content");
    501         String cc = (String) params.get("cc");
    502         String bcc = (String) params.get("bcc");
     512        String to = (String) params.get(ADDRESS_PARAM);
     513        String subject = (String) params.get(SUBJECT_PARAM);
     514        String content = (String) params.get(CONTENT_PARAM);
     515        String cc = (String) params.get(CC_PARAM);
     516        String bcc = (String) params.get(BCC_PARAM);
    503517
    504518        String mailhost = GlobalProperties.getProperty("mail.smtp.host");
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java

    r31344 r32453  
    8383        this.short_service_info.appendChild(dmr_service);
    8484
     85
     86        // what params do we want saved in the session?
     87        this.save_params.add(QUERY_PARAM);
     88        this.save_params.add(COLLECTION_PARAM);
     89        this.save_params.add(GROUP_PARAM);
     90        this.save_params.add(MAXDOCS_PARAM);
     91        this.save_params.add(HITS_PER_PAGE_PARAM);
     92       
    8593        // get any format info
    8694        Element format_info = (Element) GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r31771 r32453  
    109109    }
    110110
     111  // in configure we set up any params that should be saved to the session. At this stage, assuming none should be saved.
     112 
    111113    /** returns a specific service description */
    112114    protected Element getServiceDescription(Document doc, String service, String lang, String subset)
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java

    r32084 r32453  
    6464    }
    6565
     66  public boolean configure(Element info, Element extra_info)
     67  {
     68    if (!super.configure(info, extra_info))
     69      {
     70    return false;
     71      }
     72    logger.info("Configuring GS2LuceneSearch...");
     73
     74    // add our reverseSort param to be saved to the session
     75    this.save_params.add(SORT_ORDER_PARAM);
     76    return true;
     77  }
    6678    /** add in the Lucene specific params to TextQuery */
    6779    protected void addCustomQueryParams(Element param_list, String lang)
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r30834 r32453  
    2121// greenstone classes
    2222import java.lang.reflect.Method;
     23import java.util.ArrayList;
    2324import java.util.HashMap;
    2425
     
    3031import org.greenstone.gsdl3.util.Dictionary;
    3132import org.greenstone.gsdl3.util.GSFile;
     33import org.greenstone.gsdl3.util.GSParams;
    3234import org.greenstone.gsdl3.util.GSPath;
    3335import org.greenstone.gsdl3.util.GSXML;
     
    9597    protected HashMap<String, Node> format_info_map = null;
    9698
     99  /** the list of cgi params that this services are looking for, that need saving in the session */
     100  protected ArrayList<String> save_params = null;
     101  protected ArrayList<String> sensitive_params = null;
    97102    protected Element _globalFormat = null;
    98103
     
    159164    }
    160165
     166  public boolean addServiceParameters(GSParams params) {
     167
     168    if (params == null) {
     169      logger.error("params is null!!!");
     170      return false;
     171    }
     172   
     173    for (int i=0; i<save_params.size(); i++) {
     174      logger.error("adding save param "+save_params.get(i));
     175      params.addServiceParameter(save_params.get(i), "", true, false);
     176    }
     177    for (int i=0; i<sensitive_params.size(); i++) {
     178      params.addServiceParameter(sensitive_params.get(i), "",   false, true);
     179    }
     180    return true;
     181
     182  }
    161183    /** the no-args constructor */
    162184    public ServiceRack()
     
    166188        this.short_service_info = this.desc_doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
    167189        this.format_info_map = new HashMap<String, Node>();
     190        this.save_params = new ArrayList<String>();
     191        this.sensitive_params = new ArrayList<String>();
    168192    }
    169193
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/UserTracker.java

    r28966 r32453  
    1616public class UserTracker extends ServiceRack
    1717{
    18     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.DocXMLUtil.class.getName());
     18    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.UserTracker.class.getName());
    1919
    2020    /**************************************************
     
    2727    String[] services = { RECORD_USER_ACTION, GET_ACTIVITY_ON_PAGE };
    2828
     29  // the parameters these services use
     30  protected static final String USER_PARAM = "username";
     31  protected static final String COLLECTION_PARAM = "collection";
     32  protected static final String SITE_PARAM = "site";
     33  protected static final String OID_PARAM = "oid";
     34  protected static final String ACTION_PARAM = "action";
     35 
    2936    /** configure this service */
    3037    public boolean configure(Element info, Element extra_info)
     
    3542        }
    3643
    37         logger.info("Configuring DocXMLUtil...");
     44        logger.info("Configuring UserTracker...");
    3845        this.config_info = info;
    3946
     
    4653        }
    4754
     55        // should any of the params be saved to the session?
     56        // assuming not at this stage. But if they do need to be, then
     57        // sture them here in save_params.
     58        // this.save_params.add(XXX_PARAM);
    4859        return true;
    4960    }
     
    7889
    7990        HashMap<String, Serializable> params = GSXML.extractParams(paramList, true);
    80         String username = (String) params.get("username");
    81         String collection = (String) params.get("collection");
    82         String site = (String) params.get("site");
    83         String oid = (String) params.get("oid");
    84         String action = (String) params.get("action");
     91        String username = (String) params.get(USER_PARAM);
     92        String collection = (String) params.get(COLLECTION_PARAM);
     93        String site = (String) params.get(SITE_PARAM);
     94        String oid = (String) params.get(OID_PARAM);
     95        String action = (String) params.get(ACTION_PARAM);
    8596
    8697        DerbyWrapper database = new DerbyWrapper(GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB");
     
    106117
    107118            HashMap<String, Serializable> params = GSXML.extractParams(paramList, true);
    108             String collection = (String) params.get("collection");
    109             String site = (String) params.get("site");
    110             String oid = (String) params.get("oid");
     119            String collection = (String) params.get(COLLECTION_PARAM);
     120            String site = (String) params.get(SITE_PARAM);
     121            String oid = (String) params.get(OID_PARAM);
    111122
    112123            DerbyWrapper database = new DerbyWrapper(GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + "usersDB");
Note: See TracChangeset for help on using the changeset viewer.