Changeset 32448

Show
Ignore:
Timestamp:
13.09.2018 14:05:59 (12 months ago)
Author:
kjdon
Message:

params class changed, now returns false by default for shouldsave. so don't need to add any that we don't want saving in the session. turned hard coded strings into static string variables

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action
Files:
8 modified

Legend:

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

    r32063 r32448  
    8787 
    8888    /** 
    89      * tell the param class what its arguments are if an action has its own 
    90      * arguments, this should add them to the params object - particularly 
    91      * important for args that should not be saved 
     89     * tell the param class what its arguments are. 
     90     * if an action has its own arguments, this should add them to  
     91     * the params object - particularly 
     92     * important for args that need to be saved to the session 
    9293     */ 
    9394    public boolean addActionParameters(GSParams params) 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java

    r28964 r32448  
    2121import org.greenstone.gsdl3.util.DerbyWrapper; 
    2222import org.greenstone.gsdl3.util.GSConstants; 
     23import org.greenstone.gsdl3.util.GSParams; 
    2324import org.greenstone.gsdl3.util.GSXML; 
    2425import org.greenstone.gsdl3.util.GSXSLT; 
     
    4041    private final String DE_CLEAR_DATABASE = "cleardatabase"; 
    4142 
     43  // cgi args 
     44  private final String DE_PAGE_ARG = "dePage"; 
     45  private final String CURRENT_PAGE_ARG = "currentPage"; 
     46  private final String FILE_TO_ADD_ARG = "fileToAdd"; 
     47   
    4248    public Node process(Node message) 
    4349    { 
     
    5561        HashMap<String, Serializable> params = GSXML.extractParams(param_list, false); 
    5662 
    57         String collection = (String) params.get("c"); 
     63        String collection = (String) params.get(GSParams.COLLECTION); 
    5864 
    5965        int pageNum = -1; 
     
    6167        try 
    6268        { 
    63             pageNum = Integer.parseInt(((String) params.get("dePage"))); 
     69            pageNum = Integer.parseInt(((String) params.get(DE_PAGE_ARG))); 
    6470        } 
    6571        catch (Exception ex) 
     
    7278        try 
    7379        { 
    74             prevPageNum = Integer.parseInt((String) params.get("currentPage")); 
     80            prevPageNum = Integer.parseInt((String) params.get(CURRENT_PAGE_ARG)); 
    7581        } 
    7682        catch (Exception ex) 
     
    125131            { 
    126132                String paramName = paramIter.next(); 
    127                 if (paramName.startsWith("md___")) 
     133                if (paramName.startsWith(GSParams.MD_PREFIX)) 
    128134                { 
    129135                    Object paramValue = params.get(paramName); 
     
    270276        else if (subaction.toLowerCase().equals(DE_DEPOSIT_FILE)) 
    271277        { 
    272             String fileToAdd = (String) params.get("fileToAdd"); 
     278            String fileToAdd = (String) params.get(FILE_TO_ADD_ARG); 
    273279            File tempFile = new File(GlobalProperties.getGSDL3Home() + File.separator + "tmp" + File.separator + fileToAdd); 
    274280            if (tempFile.exists()) 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r32348 r32448  
    803803    } 
    804804 
    805     /** 
    806      * tell the param class what its arguments are if an action has its own 
    807      * arguments, this should add them to the params object - particularly 
    808      * important for args that should not be saved 
    809      */ 
    810     public boolean addActionParameters(GSParams params) 
    811     { 
    812         params.addParameter(GOTO_PAGE_ARG, false); 
    813         params.addParameter(ENRICH_DOC_ARG, false); 
    814         params.addParameter(EXPAND_DOCUMENT_ARG, false); 
    815         params.addParameter(EXPAND_CONTENTS_ARG, false); 
    816         params.addParameter(REALISTIC_BOOK_ARG, false); 
    817  
    818         return true; 
    819     } 
    820805     
    821806    private boolean needSectionContent(HashMap<String, Serializable> params) { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java

    r28964 r32448  
    3333     
    3434    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.FormatAction.class.getName()); 
     35 
     36  public static final String CLASSIFIER_ARG = "cl"; 
     37  public static final String DATA_ARG = "data"; 
     38   
    3539    XMLTransformer transformer = null; 
    3640 
     
    5660        String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER); 
    5761        String service = (String)params.get(GSParams.SERVICE); 
    58         String classifier = (String)params.get("cl"); 
     62        String classifier = (String)params.get(CLASSIFIER_ARG); 
    5963 
    6064        String to = ""; 
     
    7377        mr_request_message.appendChild(mr_request); 
    7478     
    75         String format_string = (String)params.get("data"); 
     79        String format_string = (String)params.get(DATA_ARG); 
    7680     
    7781        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java

    r28964 r32448  
    2727{ 
    2828 
     29  public static final String CONFIG_CHANGE_NAME_ARG = "configChangeName"; 
     30  public static final String CONFIG_CHANGE_VALUE_ARG = "configChangeValue"; 
     31   
    2932    /** process a request */ 
    3033    public Node process(Node message_node) 
     
    4851        HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false); 
    4952 
    50         if (params.get("configChangeName") != null && params.get("configChangeValue") != null) 
    51         { 
    52             String optionName = (String) params.get("configChangeName"); 
    53             String optionValue = (String) params.get("configChangeValue"); 
     53        if (params.get(CONFIG_CHANGE_NAME_ARG) != null && params.get(CONFIG_CHANGE_VALUE_ARG) != null) 
     54        { 
     55            String optionName = (String) params.get(CONFIG_CHANGE_NAME_ARG); 
     56            String optionValue = (String) params.get(CONFIG_CHANGE_VALUE_ARG); 
    5457 
    5558            changeConfig(optionName, optionValue); 
     
    100103            Element param_list = null; 
    101104            // add in the service params - except the ones only used by the action 
    102             HashMap service_params = (HashMap) params.get("s1"); 
     105            HashMap service_params = (HashMap) params.get(GSParams.SERVICE_PREFIX); 
    103106            if (service_params != null) 
    104107            { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java

    r28964 r32448  
    9797 
    9898        // service paramList 
    99         HashMap service_params = (HashMap) params.get("s1"); 
     99        HashMap service_params = (HashMap) params.get(GSParams.SERVICE_PREFIX); 
    100100        if (service_params == null) 
    101101        { // no query 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java

    r28964 r32448  
    8686                request_type_att = GSXML.REQUEST_TYPE_PROCESS; 
    8787                // add in the service params - except the ones only used by the action 
    88                 HashMap service_params = (HashMap) params.get("s1"); 
     88                HashMap service_params = (HashMap) params.get(GSParams.SERVICE_PREFIX); 
    8989                if (service_params != null) 
    9090                { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r31774 r32448  
    2121{ 
    2222 
    23   public static final String HITS_PER_PAGE = "hitsPerPage"; 
     23  public static final String HITS_PER_PAGE_ARG = "hitsPerPage"; 
    2424    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.QueryAction.class.getName()); 
     25   
     26    /** 
     27     * tell the param class what its arguments are. 
     28     * if an action has its own arguments, this should add them to  
     29     * the params object - particularly 
     30     * important for args that need to be saved to the session 
     31     */ 
     32    public boolean addActionParameters(GSParams params) 
     33    { 
     34      // some query services don't do paging themselves, in shich case we do it here. Let tell servlet to save the param just in case nothing else is doing that. 
     35      params.addServiceParameter(HITS_PER_PAGE_ARG, "20", true, false); 
     36        return true; 
     37    } 
    2538   
    2639    /** 
     
    351364    { 
    352365 
    353       String hits_pp = (String) service_params.get(HITS_PER_PAGE); 
     366      String hits_pp = (String) service_params.get(HITS_PER_PAGE_ARG); 
    354367      
    355368        int hits = 20; 
     
    427440  protected boolean addHitsParamToService(Document doc, Element service_description, String lang) { 
    428441    Element param_list = (Element)GSXML.getChildByTagName(service_description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    429     Element param = GSXML.createParameterDescription(doc, HITS_PER_PAGE, getTextString("param." + HITS_PER_PAGE, lang, "ServiceRack", null), GSXML.PARAM_TYPE_INTEGER, "20", null, null); 
     442    Element param = GSXML.createParameterDescription(doc, HITS_PER_PAGE_ARG, getTextString("param." + HITS_PER_PAGE_ARG, lang, "ServiceRack", null), GSXML.PARAM_TYPE_INTEGER, "20", null, null); 
    430443    Element query_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "query"); 
    431444    if (query_param != null) {